bep032tools.generator package
Subpackages
Submodules
bep032tools.generator.BEP032Generator module
- class bep032tools.generator.BEP032Generator.BEP032Data(sub_id, ses_id, modality='ephys')
Bases:
object
Representation of a BEP032 Data, as specified by in the [ephys BEP](https://bids.neuroimaging.io/bep032)
The BEP032Data 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 BEP032Data objects are required. To include multiple realizations of tasks or runs, call the register_data method for each set of parameters separately.
- Parameters
sub_id (str) – subject identifier, e.g. ‘0012’ or ‘j.s.smith’
ses-id (str) – session identifier, e.g. ‘20210101’ or ‘007’
tasks (str) – task identifier of data files
runs (str) – run identifier of data files
- property basedir
- generate_all_metadata_files()
- generate_metadata_file_channels(output)
- generate_metadata_file_contacts(output)
- generate_metadata_file_dataset_description(output)
- generate_metadata_file_ephys(output)
- generate_metadata_file_participants(output)
- generate_metadata_file_probes(output)
- generate_metadata_file_scans(output)
- generate_metadata_file_sessions(output)
- generate_metadata_file_tasks(output)
- classmethod 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’. Optional columns are ‘runs’, ‘tasks’ and ‘data_file’ (only single file per sub_id, ses_id combination supported). ‘data_file’ needs to be a valid path to a nix or nwb file.
- Parameters
csv_file (str) – Csv file that contains sub_id and ses_id and optional columns
pathToDir (str) – Path to directory where the directories will be created.
- 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
- organize_data_files(mode='link')
Add datafiles to BEP032 structure
- Parameters
mode (str) – Can be either ‘link’, ‘copy’ or ‘move’.
- register_data_files(*files, task=None, run=None)
Register data with the BEP032 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.
task (str) – task name used
run (str) – run name used
- validate()
Validate the generated structure using the BEP032 validator
- Parameters
output_folder (str) – path to the folder to validate
- Returns
True if validation was successful. False if it failed.
- Return type
bool
- bep032tools.generator.BEP032Generator.create_file(source, destination, mode, exist_ok=False)
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’.
exist_ok (bool) – If False, raise an Error if the destination already exist. Default: False
- Raises
ValueError – In case of invalid creation mode.
- bep032tools.generator.BEP032Generator.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 BEP032 structure
- Return type
pandas.dataframe
- bep032tools.generator.BEP032Generator.main()
Notes
Usage via command line: BEP032Generator.py [-h] pathToCsv pathToDir
- positional arguments:
pathToCsv Path to your csv file
pathToDir Path to your folder
- optional arguments:
- -h, --help
show this help message and exit