This is a collaborative space. In order to contribute, send an email to maximilien.chaumon@icm-institute.org
On any page, type the letter L on your keyboard to add a "Label" to the page, which will make search easier.
Create a helper.py file
We decided to split the MEG/EEG preprocessing and processing steps into several Brainlife Apps to allow the user more freedom. Some pieces of Python code are the same across all Apps: at first they were just copied pasted from one App to another, but to facilitate code maintenance, we decided to put all these shared pieces in a single Python file called helper.py
.
This Python file is stored in an independent GitHub repository (brainlife_apps_helper) that is linked to each App thanks to the GitHub functionality submodule
.
At first, the file helper.py
was present in all App repositories, so if we changed a helper.py
from one app, we had to change manually all the others helper.py
because we want this file to be the same for all Apps. We had to do this because Brainlife downloaded App repositories instead of cloning it, and submodules are not kept when a repository is downloaded. So Soichi switched back to clone repository.
The functions in this helper.py
available are described below.
Function convert_parameters_to_None()
This function converts all parameters whose value is an empty string to None
(see Null value of an optional parameter).
Function read_optional_files()
Some Apps accept optional files but handling them requires several steps
(see Error when an optional file is not available in a dataset, Error when running a pipeline with optional files, Handling optional file, How to use the meg/fif-override datatype ).
Jun 22, 2021
Optional files are datatype dependent, so this function can’t be used for other datatypes than meg/fif
and meg/fif-override
. When other datatypes will be used, each datatype must have their own read_optional_files()
(the function can be called for instance read_optionale_files_from_megfif()
)
Function update_data_info_bads()
Bad channels are marked as bad in channels.tsv
, but MNE Python functions look for this info in raw.info['bads']
, so the later must be compliant with the former (see How to create a BIDS compliant channels.tsv and events.tsv files, Où stocker l'information "bad channels").
Function message_optional_files_in_reports()
In the HTML reports produced by app-bad-channels and app-maxwell-filter, we specify if the optional files are provided or not thanks to messages that are created in this function.
Function define_kwargs()
In the Apps, we use **kwargs
when calling the function that will process the data. But the **kwargs
doesn’t correspond exactly to config.json
created by Brainlife, so the Python dictionary config
that corresponds to config.json
must be preprocessed (see Structure of configuration file generated by BL).