Folders

class brukerapi.folders.Folder(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

A representation of a generic folder. It implements several functions to simplify the folder manipulation.

__init__(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

The constructor for Folder class.

Parameters:
  • path – path to a folder

  • parent – parent Folder object

  • recursive – recursively create sub-folders

  • dataset_index – only data sets listed here will be indexed

Returns:

validate()

Validate whether the given path exists an leads to a folder. :return: :raises NotADirectoryError:

__str__() str

Return str(self).

make_children_map()

Build a dictionary for fast name lookups.

__getattr__(name: str)

Access individual files in folder. Dataset and JCAMPDX instances are not loaded, to access the data and parameters, to load the data, use context manager, or the load() function.

Example:

with folder.fid as fid
    data = fid.data
    te = fid.EffectiveTE
Parameters:

name – Name of Dataset, JCAMPDX, or Folder

Returns:

__getitem__(name)

Access individual files in folder, dict style. Dataset and JCAMPDX instances are not loaded, to access the data and parameters, to load the data, use context manager, or the load() function.

Example:

with folder['fid'] as fid
    data = fid.data
    te = fid.EffectiveTE
Parameters:

name – Name of Dataset, JCAMPDX, or Folder object

Returns:

query(query)

Query each dataset in the folder recursively.

Parameters:

query

Returns:

clean(node: Folder | None = None) Folder

Remove empty folders from the tree

Parameters:

node

Returns:

tree without empty folders

get_dataset_list() list

List of Dataset instances contained in folder

get_dataset_list_rec() list

List of Dataset instances contained in folder

get_jcampdx_list() list

List of JCAMPDX instances contained in folder

get_experiment_list() list

List of Experiment instances contained in folder and its sub-folders

get_processing_list() list

List of Processing instances contained in folder and its sub-folders

get_study_list() list

List of Study instances contained in folder and its sub-folders

make_tree(*, recursive: bool = True) list[Folder | Dataset | JCAMPDX]

Build a folder tree with optimized traversal.

static contains(path: str | Path, required: list) bool

Checks whether folder specified by path contains all required files.

print(level=0, recursive=None)

Print structure of the Folder instance.

Parameters:
  • level – level of hierarchy

  • recursive – print recursively

Returns:

to_dict(props=None)

Properties of every dataset in the folder, keyed by dataset id.

__weakref__

list of weak references to the object

class brukerapi.folders.Study(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

Representation of the Bruker Study folder. The folder contains a subject info and a number of experiment folders.

Tutorial How to work with Bruker study?

__init__(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

The constructor for Study class.

Parameters:
  • path – path to a folder

  • parent – parent Folder object

  • recursive – recursively create sub-folders

Returns:

validate()

Validate whether the given path exists an leads to a Study folder.

Raises:

NotStudyFolder: if the path does not lead to folder, or the folder does not contain a subject file

get_dataset(exp_id: str | None = None, proc_id: str | None = None) Dataset

Get a Dataset from the study folder. Fid data set is returned if exp_id is specified, 2dseq data set is returned if exp_id and proc_id are specified.

Parameters:
  • exp_id – name of the experiment folder

  • proc_id – name of the processing folder

Returns:

fid, or 2dseq Dataset

class brukerapi.folders.Experiment(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

Representation of the Bruker Experiment folder. The folder can contain fid and rawdata.SUBTYPE data sets. It can contain multiple Processing instances.

__init__(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

The constructor for Experiment class.

Parameters:
  • path – path to a folder

  • parent – parent Folder object

  • recursive – recursively create sub-folders

Returns:

validate()

Validate whether the given path exists an leads to a Experiment folder.

Raises:

NotExperimentFolder: if the path does not lead to folder, or the folder does not contain an acqp file

class brukerapi.folders.Processing(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)
__init__(path: str | Path, parent: Folder | None = None, recursive: bool | None = None, dataset_index: list | None = None, dataset_state: dict | None = None)

The constructor for Processing class.

Parameters:
  • path – path to a folder

  • parent – parent Folder object

  • recursive – recursively create sub-folders

Returns:

validate()

Validate whether the given path exists an leads to a Processing folder.

Raises:

NotProcessingFolder: if the path does not lead to folder, or the folder does not contain an visu_pars file