8563
Comment:
|
16517
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Realistic head model: FEM with Duneuro = '''[TUTORIAL UNDER DEVELOPMENT: NOT READY FOR PUBLIC USE]''' |
= Realistic head model: FEM with DUNEuro = '''[TUTORIAL UNDER REVISION/CORRECTION: NOT READY FOR PUBLIC USE]''' |
Line 4: | Line 4: |
''Authors: Takfarinas, Juan, ..., Sophie, Maria, Christian, Carsten, John, Richard ? '' | ''Authors: [[https://neuroimage.usc.edu/brainstorm/AboutUs/tmedani|Takfarinas Medani]], Juan Garcia-Prieto, Francois Tadel, Sophie Schrader, Anand Joshi, Christian Engwer, Carsten Wolters, John Mosher and Richard Leahy '' |
Line 6: | Line 6: |
This tutorial explains how to use brainstorm-dueneuro to compute the head model using the finite element method, implemented in the Duneuro software. | {{attachment:logo_duneuro.png||align="right",height="82",width="187"}} |
Line 8: | Line 8: |
This forward model uses a finite element element method (FEM) implemented within the [[http://duneuro.org/|Duneuro]] software. '''...(l''''''ink)'''. It uses the volume mesh of the realistic head model. The goal of this forward solution is mostly for '''EEG users''', to provide more accurate results than the spherical models and more complex geometry than the BEM. It could be not necessary for MEG users, as the "overlapping spheres" method gives similar results (we need to check) but much faster. This method is illustrated using the tutorial [[http://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy|EEG and epilepsy]] or similar data ('''todo'''). | This tutorial explains how to use [[http://duneuro.org/|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 provides more accurate results than the spherical forward models, and more realistic geometry and tissue propriety than the [[Tutorials/TutBem|BEM]] methods. |
Line 10: | Line 10: |
refe to these point : http://duneuro.org/ | 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 [[Tutorials/FemMesh|FEM mesh generation]]. We assume that you have already followed the [[Tutorials|introduction tutorials]] (or at least the [[Tutorials/HeadModel|head modeling tutorial]]), we will not discuss the general principles of forward modeling here. |
Line 12: | Line 12: |
and to the documentation from here : | <<TableOfContents(2,2)>> |
Line 14: | Line 14: |
https://gitlab.dune-project.org/duneuro/duneuro/wikis/home | == DUNEuro == '''[[http://duneuro.org/|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''' [[https://www.dune-project.org/|DUNE library]] '''and its main features include solving the EEG and MEG forward problem and providing simulations for brain stimulation. |
Line 16: | Line 17: |
Here we will describe the FEM and run some examples | As distributed on the [[http://gitlab.dune-project.org/duneuro/duneuro|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 ([[http://www.sci.utah.edu/~wolters/ChengduSummerschool/DUNEuroPresentation/|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 [[https://github.com/brainstorm-tools/bst-duneuro|GitHub repository bst-duneuro]]. |
Line 18: | Line 19: |
== Duneuro == DUNEuro is an open-source C++ software library for solving partial differential equations in neurosciences using mesh bases methods. It is based on the DUNE library and its main features include solving the electroencephalography (EEG) and magnetoencephalography (MEG) forward problem and providing simulations for brain stimulation. |
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. |
Line 21: | Line 21: |
http://duneuro.org/ | ''' {{attachment:duneuroFromDune.JPG||height="187",width="546"}} ''' |
Line 23: | Line 23: |
== Requirements == DUNEuro is build on top of DUNE Library, at this time (September 2019) the source code works only on Linux operating systems. However we are able to generate the binaries for the main platforms (windows 64, Linux and Mac), therefor it can be easily used from Matlab for all platforms without the need to install and compile the tidiuos CPP library of DUNE and DUNEURO. |
Please '''cite the following papers''' if you use this software in your work: ''' ''' |
Line 26: | Line 25: |
However if you want to use the source code of Duneuro you can visite: http://duneuro.org/ | * Please cite the corresponding papers from the [[http://duneuro.org/|duneuro website]]. * ''Takfarinas Medani'', Juan Garcia-Prieto, Francois Tadel, Sophie Schrader, Anand Joshi, Christian Engwer, Carsten H. Wolters, John C. Mosher, and Richard M. Leahy : '''''"Realistic head modeling of electromagnetic brain activity: An integrated Brainstorm pipeline from the MRI data to the FEM solution"''''' ''under writing'' |
Line 28: | Line 28: |
For the advanced user users, he main steps you need in order to compile for windows are listed here : https://github.com/svdecomposer/brainstorm-duneuro | ''' ''' |
Line 30: | Line 30: |
https://github.com/brainstorm-tools/bst-duneuro | == Download and installation == * '''Requirements''' * You have already followed all the introduction tutorials * You have a working copy of Brainstorm installed on your computer. |
Line 32: | Line 35: |
We distribute the binary files for Windows/Ubunto 64bit systems, you don't need to installan extra Microsoft software package to run '''Duneuro.''' | * '''Download the dataset''' * Get the open access reference data set from''' '''here''' : '''[[https://urldefense.com/v3/__https://zenodo.org/record/3888381__;!!LIr3w8kk_Xxm!6KhbFOL7K9swpYSnYrC6ZOtj6uGhoULw9qgkmW75irYricc0ITrt_Do95QkqIQ$|https://zenodo.org/record/3888381]] |
Line 34: | Line 38: |
'''<<TAG(Advanced)>>''' | == 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). ''' ''' |
Line 36: | Line 41: |
However, to use this pipline from Brainstorm you need to download the bst-duneuro toolbox (ref) that interface brainstorm to duneuro. | The minimal requirement for FEM mesh generation is the [[http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Download|iso2mesh]] toolbox, which is automatically added when it's required (needs internet connexion). For advanced mesh, the list of the available methods are listed and explained in [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh|this tutorial]]'''. ''' ''' ''' |
Line 38: | Line 43: |
The FEM mesh visualisation and some mesh processing requires the installation of the iso2mesh toolbox (link). If you want to work on offline, you can download it and add it to your matlab path. If it's not installed, Brainstrom will download and istall this toolbox when it needed. | The FEM mesh visualization and mesh processing options are integrated with Brainstorm. The use of these options requires also the installation of the [[http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Download|iso2mesh]]'''.''' |
Line 40: | Line 45: |
== FEM surfaces / Volume generation == === SIMNIBS === https://simnibs.github.io/simnibs/build/html/index.html |
Brainstorm will download the last release from this [[https://neuroimage.usc.edu/brainstorm/http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Download|webpage]]''' '''and install it when it is needed. However, you can also download the iso2mesh from the''' '''[[https://github.com/fangq/iso2mesh|github]]''' '''and add it to your Matlab path. |
Line 44: | Line 47: |
=== SimNIBS Installation === Please follow the instructions on this webapge: |
=== 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). ''' ''' |
Line 47: | Line 50: |
https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html | 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. ''' ''' |
Line 49: | Line 52: |
=== Volume mesh generation from Brainstorm === To generate the volume mesh head model we use the "headreco" : |
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 [[http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Doc/FunctionList|webpage]]). ''' ''' |
Line 52: | Line 54: |
https://simnibs.github.io/simnibs/build/html/documentation/command_line/headreco.html | ''' {{attachment:fem_mesh_generation.JPG||height="300",width="230"}} {{attachment:meshMethods.JPG||height="300",width="230"}} {{attachment:iso2meshMergeMethodOptions.JPG||height="200",width="200"}} ''' ''' ''' |
Line 54: | Line 56: |
This function is part of the SimNibs software: | The other mesh generation's methods are explained on this''' [[https://neuroimage.usc.edu/brainstorm/meshGeneration#preview|tutorial]]. ''' ''' ''' |
Line 56: | Line 58: |
https://simnibs.github.io/simnibs/build/html/index.html | === Volume mesh visualisation === In this tutorial, we use the ICBM head model template distributed with brainstorm. When the FEM mesh generation is correctly completed, a new node will appear on the anatomy window. |
Line 58: | Line 61: |
=== headreco === The headreco function is fully integrated to brainstorm. With this option, brainstorm can reconstructs a tetrahedral head mesh from T1- and T2-weighted structural MR images. It runs also with only a T1w image, but it will achieve more reliable skull segmentations when a T2w image is supplied. |
''' {{attachment:view_default_subject.JPG||height="180",width="250"}} ''' ''' ''' |
Line 61: | Line 63: |
=== Surface mesh generation from volume mesh === === Volume generation from surface files === In this part you can generate your FEM mesh from surfaces that you can get fron the segmentation software (brainSuite, FreeSurfer ....). |
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. ''' ''' |
Line 65: | Line 65: |
This process will | ''' {{attachment:dispIcbmMesh.JPG||height="300",width="580"}} ''' |
Line 67: | Line 67: |
- merge the surfaces, | 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. ''' ''' |
Line 69: | Line 69: |
- check the self intersecting | If you still want to use the intersecting surfaces, you can try with the "MergSurf" option. This option will 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. ''' ''' |
Line 71: | Line 71: |
- fixe the size of the mesh | == FEM Forward model == To compute the forward model (Gain Matrix) with the FEM method, we assume that you have followed the [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem?highlight=(bem)|introduction tutorials]] and all the relative [[https://neuroimage.usc.edu/brainstorm/Tutorials/HeadModel|data are available]](channels files, ...). ''' ''' |
Line 73: | Line 74: |
- generate the volum mesh | 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. ''' ''' |
Line 75: | Line 76: |
- visual checking ... | ''' {{attachment:femNode.JPG||height="200",width="250"}} {{attachment:modelAndCortex.JPG||height="350",width="300"}} ''' ''' ''' |
Line 77: | Line 78: |
- TODO : may be we can add some mesh auqlity measures ?? | 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. ''' ''' |
Line 79: | Line 80: |
'''<<TAG(Advanced)>>''' | ''' {{attachment:ComputeHeadModelDuneuro.JPG||height="350",width="330"}} ''' ''' ''' |
Line 81: | Line 82: |
=== Volume generation from T1/T2 MRI data === You can also generate your own FEM head model and then load it to brainstorm. However the automatic head model generation from from imaging techniques are not accurate and most of the time visual checking are needed and manual correction are required. |
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. ''' ''' |
Line 84: | Line 84: |
==> this depends lagely on the quality of the T1/T2 MRI image(https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html). | When you press OK, the panel related to DUNEuro options is displayed where you have the possibilities to change the options. |
Line 86: | Line 86: |
This step is based on the "roast" toolbox (link to roast : https://github.com/andypotatohy/roast | {{attachment:duneuroBasicOptions.JPG||height="300",width="300"}} |
Line 88: | Line 88: |
) that we adapted for the MEEG forward computation. If you want to generate your own FEM head model from an MRI, you will need to download these file (link), then run the bst process as explained here. | At this level, the basic options are the list head's tissues and their conductivities. Brainstorm reads these parameters from the selected head model. |
Line 90: | Line 90: |
* f there is a MRI file with the string "T2" in the subject anatomy folder, it will use it * Otherwise, if you select explicitly two MRI files with CTRL+Click, it will use the first one as the T1 and the second one as the T2 (this needs to be documented in the tutorial) |
* '''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 In this case, there is Scalp (=head), Skull (=outer skull), and Brain (=inner skull). |
Line 93: | Line 98: |
=== FEM Head model generation with SimNibs === This method used the SimNibs software. So to call this process, you need to download and install the SimNibs software, the process of the installation is explained in the SimNibs webpage : https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html. |
* '''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. |
Line 96: | Line 100: |
When you have installed SimNibs, Brainstorm can call the main function used for the mesh generation frm the main graphical interface. Depemding on your computer performances, this process will take between 2 to 5 hours. We highly recommend to close all other running process and application on our computer in order to speed this process. | For advanced users, check the advanced section and more detailed example at this page [[https://neuroimage.usc.edu/brainstorm/FemTensors|FEM tensor]]''.'' |
Line 98: | Line 102: |
- Explain here the main steps with screenshots : | When is finished, click on the "Ok", the calculation of the head model will start. You may wait for a very long time, which depends on the mesh resolution. |
Line 100: | Line 104: |
1- Create new subject within the current protocole | So, be patient, it's worth it...''' '''''(for this model it's quite fast ... less than 10 min)'' <<TAG(Advanced)>> |
Line 102: | Line 106: |
2- Load the T1 of the subject to the brainstorm database. | === Anisotropy tensors from the DUNEuro options === In the case where the conductivity tensors are computed, Brainstorm detects and uses and loads them for the FEM forward computation. |
Line 104: | Line 109: |
3- Associate a T2 mri to the subject if it's available (this is better for csf/skull/scalp segmentation) | {{attachment:duneuroBasicOptionsTensor.JPG||height="300",width="300"}} |
Line 106: | Line 111: |
4- Right click on the subject, select the "Generate FEM mesh" | In this case, users can not change the conductivities values, since they are already computed as explained in this [[https://neuroimage.usc.edu/brainstorm/FemTensors|FEM tensor]]. |
Line 108: | Line 113: |
. Select "SIMNIBS", and choose "Tetrahedral element" and keep the other options to the default value. | If at some points, for any reason, where users want to remove these FEM tensors, this can be done from the Brainstom anatomy panel, select the FEM head model, right-click on the subject and then "clear FEM tensor". |
Line 110: | Line 115: |
5- When this process is finished, a new node will appear in the data base, which hase he name "FEM xxxV, (simNibs, yLayers)". This is the FEM mesh model generated from the T1. | {{attachment:clearFemTensors.JPG||height="300",width="220"}} |
Line 112: | Line 117: |
=== FEM Head model template === - Load the FEM volumic mesh (template created from ICBM T1 MRI using SimNibs) |
<<TAG(Advanced)>> |
Line 115: | Line 119: |
- Load the surface mesh (template created also from ICBM using ICBM ) and then generates the volume mesh (either tetra or hexa) by calling the tetgen process cia iso2mesh toolbox (if hexa are desired, the tetra mesh will be converted to hexa ... ) | == 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. |
Line 117: | Line 123: |
https://github.com/brainstorm-tools/brainstorm3/issues/185#issuecomment-576749612 | {{attachment:duneuroAdvancedOptions.JPG||height="550",width="700"}} |
Line 119: | Line 125: |
=== Head model based on the level set approach === TODO and Validate |
A set of advanced options are made available and can be easily changed. Here a short explanation is given for each option. |
Line 122: | Line 127: |
if users want to use freesurfer and simnibs, the priority is given to freesurfer, then load the fs files, then call simnibs headmodel generation from t1/t2. | * FEM layers & conductivities: same explanation as in the previous section. Moreover, in the case where the conductivity tensors 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. |
Line 124: | Line 129: |
== FEM computation and unterface to DUNEuro == === Head model === Number of layers, conductivity value, isotropy/anisotropy/ mesh resolution/ |
* FEM solver type: * CG or Continious Galerkin: This is the standard Lagrangien methods. |
Line 128: | Line 132: |
=== Electrode model === Check the position of the electrodes and align to the head model (projection if needed) |
* DC or the Discontinious Galerkin: |
Line 131: | Line 134: |
=== Source model === Similarly to the spherical nad BEM head model, the source position are defined on the cortex surface vertices. We can either define a contraned or not constrained orientation. |
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. |
Line 134: | Line 136: |
However, for the FEM model, more paramters could be tuned for the source model. | * FEM source model: The list of the available source are * Venant * Subtraction * Partial Integration |
Line 136: | Line 141: |
Choice of the source model : PI, Venant, Subtraction, Whitney | For more information about these methods, users can check this thesis (Vorwek thesis). |
Line 138: | Line 143: |
Panel of the options choice that the user can select. (other wise we will set to default ) | * 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: |
Line 140: | Line 149: |
'''<<TAG(Advanced)>>''' | 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: |
Line 142: | Line 151: |
=== Advanced paramaters === - Solver parameters |
* GitHub repository for the [[https://github.com/brainstorm-tools/bst-duneuro|Brainstorm-DUNEuro]] compilation and integration * GitHub repository for the [[https://github.com/tmedani/duneuro_interface|matlab-duneuro interface]] * Brainstorm-DUNEuro integration discussions: * [[https://github.com/brainstorm-tools/brainstorm3/issues/185|Brainstorm-simbio/DUNEuro implementation]]/head model generation * [[https://github.com/brainstorm-tools/brainstorm3/issues/242|Integrate the DUNEuro FEM computation]] * [[https://github.com/brainstorm-tools/brainstorm3/pull/282|Genration of the FEM tensor]] * [[https://github.com/brainstorm-tools/brainstorm3/issues/302|Generation of the FEM source space]] |
Line 145: | Line 159: |
- Electrodes projection | === 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. |
Line 147: | Line 162: |
- maybe explain here the relevant option of the mini file ?? | For the generation of a more realistic head model, users can follow this [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh|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 ([[http://brainsuite.org/processing/diffusion/|BDP]]). The diffusion tensor images (DTI) are estimated with Brainsuite from the diffusion-weighted images (DWI) and then converted to conductivity tensor using the [[https://www.pnas.org/content/98/20/11697|effective medieum approach]]. In order to use this tool, you need to install [[http://forums.brainsuite.org/download/|Brainsuite]] software, the rest of the process is distributed within bst-duneuro. For more information, users can follow this [[https://neuroimage.usc.edu/brainstorm/FemTensors|FEM tensor]] [[https://neuroimage.usc.edu/brainstorm/FemTensors|tutorial]]. |
Line 150: | Line 170: |
refer to : | === 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 investigation. |
Line 152: | Line 173: |
http://duneuro.org/ | === Review of the EEG/MEG forward computation within Brainstorm === A qualitative review for the forward methods available within Brainstorm are investigated in this [[https://neuroimage.usc.edu/brainstorm/https://neuroimage.usc.edu/brainstorm/Tutorials/ReviewForward|page]] |
Line 154: | Line 176: |
https://www.dune-project.org/ | === DUNEuro references === * DUNEuro wiki: https://gitlab.dune-project.org/duneuro/duneuro/wikis/home * DUNEuro website: http://duneuro.org/ |
Line 156: | Line 180: |
https://simnibs.github.io/simnibs/build/html/index.html | === Brainstorm-DUNEuro integration (technical discussions)<<BR>> === * https://github.com/brainstorm-tools/bst-duneuro/issues/1 * https://github.com/brainstorm-tools/brainstorm3/issues/242 * https://github.com/brainstorm-tools/brainstorm3/issues/185 * |
Line 158: | Line 186: |
== Reported Errors & alternative solution == '''<<TAG(Advanced)>>''' |
== Errors == 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). |
Line 161: | Line 189: |
simnibs pblm : | * " coordinate is outside of the grid, or grid is not convex" |
Line 163: | Line 191: |
https://simnibs.github.io/simnibs/build/html/installation/throubleshooting.html | |
Line 165: | Line 192: |
== The MEEG forward problem with the FEM == == License == == Reference == |
==> 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 |
Realistic head model: FEM with DUNEuro
[TUTORIAL UNDER REVISION/CORRECTION: NOT READY FOR PUBLIC USE]
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 provides 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.
Contents
DUNEuro
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:
Please cite the corresponding papers from the duneuro website.
Takfarinas Medani, Juan Garcia-Prieto, Francois Tadel, Sophie Schrader, Anand Joshi, Christian Engwer, Carsten H. Wolters, John C. Mosher, and Richard M. Leahy : "Realistic head modeling of electromagnetic brain activity: An integrated Brainstorm pipeline from the MRI data to the FEM solution" under writing
Download and installation
Requirements
- You have already followed all the introduction tutorials
- You have a working copy of Brainstorm installed on your computer.
Download the dataset
Get the open access reference data set from here : https://zenodo.org/record/3888381
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).
The minimal requirement for FEM mesh generation is the iso2mesh toolbox, which is automatically added when it's required (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.
Brainstorm will download the last release from this webpage and install it when it is needed. However, you can also download the iso2mesh from the github and add it to your Matlab path.
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. When the FEM mesh generation is correctly completed, a new node will appear on the anatomy window.
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. This option will 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
To compute the forward model (Gain Matrix) with the FEM method, we assume that you have followed the introduction tutorials and all the relative data are available(channels files, ...).
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 more detailed example at this page FEM tensor.
When is finished, click on the "Ok", the calculation of the head model will start. You may wait for a very long time, which depends on the mesh resolution.
So, be patient, it's worth it... (for this model it's quite fast ... less than 10 min)
Anisotropy tensors from the DUNEuro options
In the case where the conductivity tensors are computed, Brainstorm detects and uses and loads 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 Brainstom 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 tensors 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 Continious Galerkin: This is the standard Lagrangien methods.
- DC or the Discontinious 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
- Venant
- Subtraction
- 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.
For more information, users can follow this FEM tensor tutorial.
Additional documentation
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 investigation.
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 references
DUNEuro wiki: https://gitlab.dune-project.org/duneuro/duneuro/wikis/home
DUNEuro website: http://duneuro.org/
Brainstorm-DUNEuro integration (technical discussions)<<BR>>
Errors
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