Realistic head model: FEM with DUNEuro
[TUTORIAL UNDER REVISION]
Authors: Takfarinas Medani, Juan Garcia-Prieto, Francois Tadel, Sophie Schrader, Anand Joshi, Christian Engwer, Carsten Wolters, John Mosher and Richard Leahy
This tutorial explains how to use DUNEuro to compute the forward model using the finite element method (FEM). The FEM methods use the realistic volume mesh of the head generated from the segmentation of the MRI. The FEM models provide more accurate results than the spherical forward models and more realistic geometry and tissue propriety than the BEM methods.
The scope of this page is limited to a basic example (head model with 3 layers), more advanced options for head model generation and forward model options are discussed in the tutorial about FEM mesh generation. We assume that you have already followed the introduction tutorials (or at least the head modeling tutorial), we will not discuss the general principles of forward modeling here.
DUNEuro is an open-source C++ software library for solving partial differential equations (PDE) in neurosciences using mesh bases methods. It is based on the DUNE library and its main features include solving the EEG and MEG forward problem and providing simulations for brain stimulation.
As distributed on the DUNEuro GitLab, the source code works only on Linux operating systems. Interfaces to Matlab and Python are possible, but you need to install and compile duneuro by yourself (more documentation). For Brainstorm, we adapted this code and were able to generate binaries for the main operating systems (Windows, Linux and MacOS), which are downloaded automatically when needed ($HOME/.brainstorm/bst-duneuro). This project is available on our GitHub repository bst-duneuro.
We would like to thank the DUNEuro team for their help with this integration work: Carsten Wolters, Christian Engwer, Sophie Schrader, Andreas Nuessing, Tim Erdbruegger, Marios Antonakakis, Johannes Vorwerk & Maria Carla Piastra.
Please cite the following papers if you use this software in your work:
Takfarinas Medani, Juan Garcia-Prieto, Francois Tadel, Sophie Schrader, Marios Antonakakis, Anand Joshi, Christian Engwer, Carsten H. Wolters, John C. Mosher, Richard M. Leahy, "Realistic head modeling of electromagnetic brain activity: an integrated Brainstorm-DUNEuro pipeline from MRI data to the FEM solutions," Proc. SPIE 11595, Medical Imaging 2021: Physics of Medical Imaging, 1159554 (15 February 2021);https://doi.org/10.1117/12.2580935 |(you can find the drafted version here: pdf).
Please cite the corresponding papers from the duneuro website.
- You have a working copy of Brainstorm installed on your computer.
The minimal requirement for FEM mesh generation is the iso2mesh toolbox, which is automatically added when it's required (this needs internet connexion). For advanced mesh, the list of the available methods are listed and explained in this tutorial.
The FEM mesh visualization and mesh processing options are integrated with Brainstorm. The use of these options requires also the installation of the iso2mesh.
FEM head model
In order to use the FEM computations of the electromagnetic field (EEG/MEG), the volume mesh of the head is required. Brainstorm integrates most of the modern open-source tools to generate realistic head mesh, either from nested surface mesh or from individual MR images (T1 or T1 and T2).
Volume mesh generation
The basic model is the three realistic layers extracted from the subject's MRI (scalp, inner skull, outer skull), plus the source space (cortical surface).
The process of the generation of these surfaces is interactively integrated with a brainstorm. In the case you do not have any way to calculate the inner skull and outer skull surfaces, Brainstorm can generate rough approximations based on the subject's cortex and head surfaces and ICBM152's inner and outer skull surfaces. The surfaces created with Brainstorm are by construction non-intersecting. Thus, from these surfaces, you can generate the FEM mesh.
Right-click on the subject and then "Generate FEM Mesh", then select the 'iso2mesh' method with the option "MergMesh". Keep the default values for the mesh resolution option (for more documentation please visite iso2mesh webpage).
The other mesh generation's methods are explained on this tutorial.
Volume mesh visualisation
In this tutorial, we use the ICBM head model template distributed with Brainstorm, however you can apply for any subject corectely imported to brainstorm.
When the FEM mesh generation is correctly completed, a new node will appear on the anatomy window. The name of the node flow this format :
"FEM 'numberOfVertices'V ('method', 'numberOfTissues' layers)"
Brainstorm offers also an interactive option to display FEM mesh. The following figure represents the surface mesh on the left (inner, outer and head) and on the right, the final FEM mesh generated by iso2mesh.
If intersections are present on the surfaces mesh, the iso2mesh FEM mesh generation fails (tetgen) and an error will be displayed on the screen. If you face this problem, you need to check the surfaces and/or regenerate new surfaces from the MRI.
If you still want to use the intersecting surfaces, you can try with the "MergSurf" option, however, it can fails. This option can correct the intersection and create new nodes and elements. We do not recommend to use these models for EEG/MEG forward head computations. This is a research topic and it's still under investigation by the FEM communities.
FEM Forward model
First, on the anatomy view, you need to select the head model. In the case where you have multiple FEM head models, brainstorm uses the model displayed on green color. You need also to select the cortex to use as the source space.
Then, switch to the view "Functional data (sorted by subjects)", 2nd button above the database explore. Right-click on the subject > Compute head model. Select DUNEuro FEM on the list.
For the 'Source space,' we recommend using the 'Cortex surface'. For the forward modeling method. Both EEG/MEG computations are possible (depending on your data), and you can mixe between the available forward methods for each modality.
When you press OK, the panel related to DUNEuro options is displayed where you have the possibilities to change the options.
At this level, the basic options are the list head's tissues and their conductivities. Brainstorm reads these parameters from the selected head model.
FEM tissues or layers: Brainstorm detects automatically the number of layers on your model. Users can select the desired layers to include for the FEM computation. According to the modalities, the recommended selections are:
- For EEG: select all the layers
- For MEG: use only select the inner layers (here brain)
- For SEEG: use only the inner layers
- For ECOG: use only the inner layers
- Any combinations that include MEG: use all the layers
FEM conductivities: Brainstorm detects automatically the number of layers and assigns the default isotropic value for each layer. However, you have the possibility to change these values according to your model.
For advanced users, check the advanced section and a more detailed example at this page FEM tensor.
When is finished, click on the "Ok". If you do not have the bst-duneuro toolbox, Brainstorm will ask you to install it, then click 'Yes'
Brainstorm will download the latest version of the bst-duneuro binaries for your operating system from the Github, and install it in Brainstorm user folder (~username/.brainstorm/bst-duneuro/). The calculation of the head model will start automatically. You may wait for a very long time, which depends on the mesh resolution, the number of sensors, and of course the capacity of your computer.
So, be patient, it's worth it... (for this model it's quite fast ... less than 10 min)
When it's finished, you have now a new head model for this subject in your database and can be used for the next steps/(back to tutorial 20 : Head modeling)
Anisotropy tensor from the DUNEuro options
In the case where the conductivity tensor are computed, Brainstorm detects and uses them for the FEM forward computation.
In this case, users can not change the conductivities values, since they are already computed as explained in this FEM tensor.
If at some points, for any reason, where users want to remove these FEM tensors, this can be done from the Brainstorm anatomy panel, select the FEM head model, right-click on the subject, and then "clear FEM tensor".
Advanced models and options
DUNEuro advanced options panel [to be completed]
From the previous panel, for advanced duneuro panel, click on the button "Show details", the following panel is displayed.
A set of advanced options are made available and can be easily changed. Here a short explanation is given for each option.
FEM layers & conductivities: same explanation as in the previous section. Moreover, in the case where the conductivity tensor are previously computed, Brainstorm detects these tensors and load them. In this case, the users can't change the conductivities scalar values, since they are not used. The following is displayed panel is displayed.
- FEM solver type:
- CG or Continuous Galerkin: This is the standard Lagrangian method.
- DC or the Discontinuous Galerkin:
In this version, only the Fitted FEM approaches are integrated, that require the FEM mesh of the head model. Unfitted methods are also available within DUNEuro, and will be integrated soon in Brainstorm.
- FEM source model: The list of the available source are
- Partial Integration
For more information about these methods, users can check this thesis (Vorwek thesis).
- Source space
- Shrink source space: the location of dipoles are moved inward by the specified value in this field(in mm).
- Force source space: this is required in the case where the dipoles are not within the GM matter.
- Outputs options
- Save transfer matrix:
All these parameters are stored and passed to the DUNEuro as a text file. This file is the main interface that passes the parameters from Brainstorm to DUNEuro. More details about the integration can be found in these links:
GitHub repository for the Brainstorm-DUNEuro compilation and integration
GitHub repository for the matlab-duneuro interface
- Brainstorm-DUNEuro integration discussions:
FEM head model generation from MRI data
One of the advantages of the FEM is its ability to use more complex head models with realistic geometry. In this tutorial, we have shown a basic example, as an introduction.
For the generation of a more realistic head model, users can follow this FEM mesh tutorial to learn how to generate advanced FEM head models form magnetic resonance data.
FEM conductivity tensors generation from DWI data
Among the advantages of the FEM, the use of tissue anisotropy (conductivity). The estimation of the tissue anisotropy is performed with the Brainsuite diffusion pipeline (BDP). The diffusion tensor images (DTI) are estimated with Brainsuite from the diffusion-weighted images (DWI) and then converted to conductivity tensor using the effective medieum approach. In order to use this tool, you need to install Brainsuite software, the rest of the process is distributed within bst-duneuro.
Full tutorial with complete dataset and FEM modeling
A full tutorial with the FEM computation and a full data set (T1, T2, DWI, EEG nd MEG) from the same subject is under development FEM head modeling.
List of the parameters : https://docs.google.com/spreadsheets/d/1MqURQsszn8Qj3-XRX_Z8qFFnz6Yl2-uYALkV-8pJVaM/edit#gid=0
Review of the EEG/MEG forward computation within Brainstorm
A qualitative review for the forward methods available within Brainstorm are investigated in this page
DUNEuro website: http://duneuro.org/
Brainstorm-DUNEuro integration (technical discussions)
DUNEuro binaries may crash for various reasons: we tried to list the possible causes here. If you cannot find a solution, please post the full error message on the Brainstorm user forum (you can copy-paste the error message from the Matlab command window after closing the error message box).
- " coordinate is outside of the grid, or grid is not convex"
==> Some dipoles are probably outside of the cortex, users need to correct the source space.
List of errors and possible solution : https://github.com/brainstorm-tools/bst-duneuro/issues/7