ando.tools.generator package¶
Subpackages¶
Submodules¶
ando.tools.generator.AnDOGenerator module¶
-
class
ando.tools.generator.AnDOGenerator.AnDOData(sub_id, ses_id, modality='ephys')¶ Bases:
objectRepresentation of a AnDO Data, as specified by in the [ephys BEP](https://bids.neuroimaging.io/bep032)
The AnDOData object can track multiple realizations of split, run, task but only a single realization of session and subject, i.e. to represent multiple session folders, multiple AnDOData objects are required.
- Parameters
sub_id (str) – subject identifier, e.g. ‘0012’ or ‘j.s.smith’
ses-id (str) – session identifier, e.g. ‘20210101’ or ‘007’
tasks (list) – list of strings, the task identifiers used in the session
runs (list or dict) – list of integers, the run identifiers used in the session. In case of more than one task a dictionary needs to be provided with the task as keys and the list of run identifiers as corresponding values
-
property
basedir¶
-
generate_data_files(mode='link')¶ Add datafiles to AnDO structure
- Parameters
mode (str) – Can be either ‘link’, ‘copy’ or ‘move’.
-
generate_metadata_files()¶ Copy registered metadata files into BIDS structure
This method currently only takes the file postfix into account to determine the target folder.
-
generate_structure()¶ Generate the required folders for storing the dataset
- Returns
Path of created data folder
- Return type
path
-
get_data_folder(mode='absolute')¶ Generate the relative path to the folder of the data files
- Parameters
mode (str) – Return the absolute or local path to the data folder. Valid values: ‘absolute’, ‘local’
- Returns
Path of the data folder
- Return type
pathlib.Path
-
register_data_files(*files, task=None, run=None)¶ Register data with the AnDO data structure.
- Parameters
*files (path to files to be added as data files.) – If multiple files are provided they are treated as a single data files split into multiple chunks and will be enumerated according to the order they are provided in.
-
register_metadata_files(*files)¶ Register metadata with the AnDO data structure.
- Parameters
*files (list) – path to files to be added as metadata files. File content needs to be according with AnDO guidelines as files will only be moved to the their correct location based on the file name
-
validate()¶ Validate the generated structure using the AnDO validator
- Returns
True if validation was successful. False if it failed.
- Return type
bool
-
ando.tools.generator.AnDOGenerator.create_file(source, destination, mode)¶ Create a file at a destination location
- Parameters
source (str) – Source location of the file.
destination (str) – Destination location of the file.
mode (str) – File creation mode. Valid parameters are ‘copy’, ‘link’ and ‘move’.
- Raises
ValueError – In case of invalid creation mode.
-
ando.tools.generator.AnDOGenerator.extract_structure_from_csv(csv_file)¶ Load csv file that contains folder structure information and return it as pandas.datafram.
- Parameters
csv_file (str) – The file to be loaded.
- Returns
A dataframe containing the essential columns for creating an AnDO structure
- Return type
pandas.dataframe
-
ando.tools.generator.AnDOGenerator.generate_struct(csv_file, pathToDir)¶ Create structure with csv file given in argument This file must contain a header row specifying the provided data. Accepted titles are defined in the BEP. Essential information of the following attributes needs to be present. Essential columns are ‘sub_id’ and ‘ses_id’.
- Parameters
csv_file (str) – Csv file that contains a list of directories to create.
pathToDir (str) – Path to directory where the directories will be created.
-
ando.tools.generator.AnDOGenerator.main()¶ Notes
Usage via command line: AnDOGenerator.py [-h] pathToCsv pathToDir
- positional arguments:
pathToCsv Path to your folder
pathToDir Path to your csv file
- optional arguments:
- -h, --help
show this help message and exit