Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This issue, regarding bad channels, was also discussed here Où stocker l'information "bad channels", and it was decided that the App that detects bad channels will only returns a BIDS-compliant channels.tsv and this file will be used in other Apps to populate the raw.info['bads'].

Add how to handle events.tsv

Channels.tsv

Steps to create a BIDS compliant channels.tsv

...

The output datatype of the App that detects bad channels is meg/fif-override (see https://brainlife.io/datatype/608195ce89df435fd26893c1), but as pointed out here Où stocker l'information "bad channels", MNE Python functions used the info stored in raw.info['bads']. So, we need to update raw.info['bads']with the info of channels.tsv. If raw.info['bads'] is not compliant with the info of channels.tsv, a warning is displayed to the user to tell him that, by default, only bad channels from channels.tsv are considered as bad: the info of his MEG file will be updated with those channels. The comparison between channels.tsv and raw.info['bads'] is performed at the beginning of each App thanks to helper.py (see Create a helper.py file).

Is it a good idea to display this warning message? It can confused the users (they don’t have to know that channels info can be stored in raw.info.

Events.tsv

The events info is stored in raw.info['events'], but this info shouldn’t be manually changed, it is changed by the MNE Python function:

...

  1. Create a BIDS path using mne_bids

  2. Get all the info needed to create the events file

  3. if we create fixed length events: we need to extract the event id

  4. if we extract existing events we use mne.read_events()

  5. Convert the MEG file into a BIDS structure using mne_bids.write_raw_bids() and specify events_data and events_id

  6. Extract the events.tsv from the BIDS path

  7. Save it in the output directory

...

To create epochs we use the MNE function mne.Epochs() that takes as parameters the raw MEG file but also the matrix of events. So, we can’t give to this function the events.tsv directly, we need to extract the matrix of events from it.

...

Note

This code works well on fixed length events but was not tested on data with existing events!!!!

Delete the BIDS folder created

To get BIDS compliant events.tsv and channels.tsv, we created a BIDS folder. When the Apps creating these files run on Brainlife, the BIDS folder, which is useless, is in the outputs files. Besides, its presence may be confusing for the App users:

...

So in main , we add the line:

Code Block
rm -r bids

after running the app.