Versions Compared

Key

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

...

This app aims at computing the mean transformation matrix across all runs of a MEG session to correct the head position of all runs thanks to this matrix. This mean transformation matrix is stored in an empty .fif file, which then can be passed as a parameter in mne.preprocessing.maxwell_filter (destination parameter).

GitHub repository

...

Discuss if these datatypes must be updated.

Inputs of the App:

...

Files

Format

Datatype

Description

Optional

MEG signal

.fif

meg/fif

first run

No

MEG signal

.fif

meg/fif

second run

No

Yes

MEG signal

.fif

meg/fif

nth run

Yes

Info

At least two runs are required.

2. The MEG signal we want to preprocess

...

.

Output of the App:

Files

Format

Datatype

Description

Raw file

.fif

meg/fif-override

  • Info and fake data created

  • the mean transformation matrix is contained in raw.info["dev_head_t"]["trans"]

Besides, in the output directory, there are the optional files we will use that can be used in a next App and the MEG file we want to preprocess. This is mandatory, because the App that will be run after app-mean-transformation-matrix will can take as input all the files in app-mean-transformation-matrix’s matrix’s output directory corresponding to the datatype of the input of the next App .

Steps:

The python file mean-transformation-matrix.py is composed of several functions:

  • mean_transformation_matrix()

  1. Extract the transformation matrix from each file

  2. Create info object of the empty .fif file

  3. Compute the mean of all matrices across all files and add it to the info of the empty .fif file

  4. Create fake data to put into the .fif file

  5. Create raw object

  • main()

...

Read all the input files by parsing the config.json

...

Raise a ValueError if only one file was given

...

Read the MEG data we want to preprocess later and save it

...

Read the optional files that will be used in the next preprocessing Apps and, if they exist, copy them in the output directory

...

(see How to run Apps one after another).

Parameters of the App

The parameters of the App correspond to the parameters passed to the Python functions used in the App. They are listed in the Their default values proposed in Brainlife or in config.json.example when you test your App locally, then when you register you App on Brainlife, you enter them and a config.json is created by Brainlife.Here, we used the parameters set by default by mne correspond to the default values of MNE Python 0.23.

Next improvements

  • Rename it into “app-compute-realigment-matrix”?

  • Allow the user to compute a destination.fif that is not the mean of all the runs but a specific run (this option is available is mne-bids-pipeline. To do so, it would be best not to save the entire .fif file (i.e. the MEG signals) but to extract the raw.info[“dev_head_t"]["trans"] from this run and put it in an empty fif file, like we do when we compute the mean of the runs (it would save space).

  • Make sure that it is okay to run this app after of before app-head-pos, the order must not matter.