Skip to content

Preparations for source-level analyses

Info

Preparations for inverse modeling involve the installation of FreeSurfer. If you do not intend to run the source reconstruction steps of MNE-BIDS-Pipeline, you can skip the instructions on this page.

Additionally, to visualize the source reconstruction steps and add those images to the pipeline reports, the pipeline must be run on a machine capable of 3D rendering (i.e., not a headless server). If you must use a headless server, you should either prefix the pipeline command with xvfb-run (to use xvfb to emulate a display), or alternatively you can install a different version of one of our dependencies (the 3D library vtk) that does offscreen rendering (see these instructions on the MNE-Python website).

Warning

FreeSurfer does not natively run on Windows. We are currently working on ways to make it possible to use it on Windows, too.

💡 Prerequisites

To perform inverse modeling, or also called source estimation or source localization, we need to ensure that a couple prerequisites are met. Essentially, starting from a collection of 2-dimensional MRI images of coronal, axial, and sagittal slices of a participant's head, we need to construct a 3-dimensional representation of the brain, skull, and scalp. Furthermore, it's highly advantegous to attach labels to different brain areas according to common anatomical atlases, so that we could, for example, restrict subsequent analyses to specific cortical regions, and compare activation in these regions across participants.

BIDS raw datasets, however, do not include any of these 3D representations and parcellations. (Note that, however, these derivatives are sometimes distributed along with a datasets inside a derivatives/ folder). Instead, they ship e.g. with T1-weighted images only (and, sometimes, include FLASH images too).

📦 Install FreeSurfer

Before running the source-analysis parts of the pipeline, you need to create the above-mentioned 3D surfaces and parcellations. This is done using the FreeSurfer tool. FreeSurfer is a free software package that runs on macOS and Linux.

To install FreeSurfer, follow the official download and installation nstructions.

Info

The only currently tested FreeSurfer version is 6.0.

🧠 Generate surfaces and brain parcellation

MNE-BIDS-Pipeline provides a convenient way to invoke FreeSurfer. After adjusting your configuration file, invoke FreeSurfer via in the following way:

Run in your terminal
mne_bids_pipeline --steps=freesurfer --config=/path/to/your/custom_config.py

This will run the recon-all command to create the required surfaces.

Info

This process is very computationally expensive, and will usually take several hours to complete. It's a good idea to let this command run over night.

🏃🏿‍♀️ Run source-level analyses

Now you are ready to run MNE-BIDS-Pipeline, including all parts of inverse modeling. To perform the projection, MNE-Python will first need to detect brain, skull, and skin, so it can then start constructing the actual BEM conductor model. These BEM surfaces can be created based on FLASH MRI (best option) or T1-weighted MRI images (second-best). See the respective configuration options to control BEM surface creation.