18085
Comment:
|
18969
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
'''[TUTORIAL UNDER DEVELOPMENT: NOT READY FOR PUBLIC USE]''' | = FEM mesh generation = ''Authors: [[https://neuroimage.usc.edu/brainstorm/AboutUs/tmedani#preview|Takfarinas Medani]], Francois Tadel'' |
Line 3: | Line 4: |
This page will explain the different options available within brainstorm to generate the FEM mesh. | FEM forward modeling requires the construction of a 3D model of thee head tissues. The volume of the head is divided in small geometrical elements with 4 faces (tetrahedrons) or 6 faces (hexahedrons). Each element is associated with a type of biological tissue (e.g. white matter, gray matter, CSF, skull, skin) and electrical conductivity properties. |
Line 5: | Line 6: |
In order to use the finite element method to compute either the EEG/MEG forward problem or the simulate TMS od TDSC stimulation, the mesh of the head model is required. | This page lists the methods integrated with Brainstorm to generate 3D meshes of the head. For a generic introduction to FEM in Brainstorm, refer to the tutorials: [[https://neuroimage.usc.edu/brainstorm/Tutorials/Duneuro|Realistic head model: FEM with DUNEuro]] and [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMedianNerveCharm|FEM median nerve example]]. |
Line 7: | Line 8: |
In this tutorial, we present the different methods available with brainstorm to generate the FEM mesh and how to use them. | <<TableOfContents(3,2)>> |
Line 9: | Line 10: |
== Available methods == Brainstorm integrated a list of the open-source tools that are commonly used by the FEM community to generate either tetra or hexahedra mesh head model either from surface mesh or from MRI. Here is the list of the available methods in brainstorm: |
== Generate FEM mesh == FEM meshes can be computed from surfaces (as the ones generated for the [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem#BEM_surfaces|BEM models]]) or from MRI volumes (T1w and/or T2w). The methods that are available when using the popup menu '''Generate FEM mesh''' depend on the selected inputs. |
Line 12: | Line 13: |
- [[http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Doc/FunctionList|iso2mesh]] | === Surfaces === Select a list of surfaces representing the separation between different tissues (holding the CTRL or SHIFT key), then right-click on any of them. The software [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#Iso2mesh|Iso2mesh]] can create a tetrahedral mesh to represent the tissues between these different layers. |
Line 14: | Line 16: |
- [[http://mcx.space/brain2mesh/|Brain2mesh]] | {{attachment:callSurf.gif}} |
Line 16: | Line 18: |
- [[https://simnibs.github.io/simnibs/build/html/index.html|SimNibs]] | === T1 MRI === Right-click on a T1 MRI available in the database. Typically, this is the default MRI volume displayed in green in the subject folder. Methods available: [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#Brain2mesh|Brain2mesh]], [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#SimNIBS_3:_headreco|SimNIBS3]], [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#SimNIBS_4:_charm|SimNIBS4]], [[http://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#ROAST|ROAST]], [[http://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#FieldTrip|FieldTrip]]. |
Line 18: | Line 21: |
- [[http://www.fieldtriptoolbox.org/|Fieldtrip]] | {{attachment:callT1.gif}} |
Line 20: | Line 23: |
You can display the full list and a short description by right click on the MRI of the subject and then click the item "Generate FEM Mesh" | === T1+T2 MRI === Select the T1+T2 volumes, then right-click on any of them. The different files are identified based on the tags "T1" and "T2" the file names (as displayed in the Brainstorm database explorer). If these identification tags are not found in the file names, the default MRI (in green) is used as the T1, the other as the T2. If none of the is the default MRI, the first selected file is used as the T1, the second is used as the T2. Methods available: [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#Brain2mesh|Brain2mesh]], [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#SimNIBS_3:_headreco|SimNIBS3]], [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#SimNIBS_4:_charm|SimNIBS4]], [[http://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#ROAST|ROAST]]. |
Line 22: | Line 26: |
{{attachment:meshMethods.JPG||height="400",width="350"}} | {{attachment:callT1T2.gif}} |
Line 24: | Line 28: |
=== iso2mesh === iso2mesh is a matlab /octave-based mesh generation and processing toolbox. It can [[http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Doc/Workflow|create 3D tetrahedral finite element (FE) mesh from surfaces, 3D binary and gray-scale volumetric images]] such as segmented MRI/CT scans. |
=== Anatomy folder === If you right-click on the subject folder > Generate FEM mesh, then Brainstorm offers all the possible options, even the ones that are not applicable to this specific subject. |
Line 27: | Line 31: |
'''Requirement ''' | * '''Volume ''''''method''': If using a method based on MRI volumes, the T1 and T2 volumes are detected among all the volumes available based on the tags "T1" and "T2" in the file names (make sure only one file as each of these tags), otherwise use only the default MRI (in green) as the T1. * '''Surface method''': If using a method based on surfaces, the default surfaces (in green) from three categories as selected: the inner skull, the outer skull and the head surfaces. |
Line 29: | Line 34: |
it If iso2mesh is not installed in your computer, Brainstrom 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. | {{attachment:callAnat.gif}} |
Line 31: | Line 36: |
'''When and how to use it''' | == Iso2mesh == [[http://iso2mesh.sourceforge.net|Iso2mesh]] is a Matlab/Octave-based mesh generation and processing toolbox, available as a [[https://Tutorials/Plugins|Brainstorm plugin]]. |
Line 33: | Line 39: |
iso2mesh is used as the basic option by brainstorm to generate FEM mesh from surfaces mesh. | Brainstorm uses it to generate a FEM tetrahedral mesh from a set of '''nested surfaces''' representing the separation between different tissues of the head. For example, these surfaces can be the ones generated for the computation of a [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem#BEM_surfaces|BEM forward model]]. A full example is available in the tutorial [[https://neuroimage.usc.edu/brainstorm/Tutorials/Duneuro#FEM_mesh|Realistic head model: FEM with DUNEuro]]. |
Line 35: | Line 41: |
Assuming the situation where you have surfaces mesh of your subject available and you have already computed the [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem?highlight=(bem)|OpenMeeg]]forward problem. If you want to use the duneuro FEM to compute the forward model, you need to generate the FEM mesh from a similar surface used by OpenMeeg Here is the way to do it : | {{attachment:iso2meshOptions.gif}} |
Line 37: | Line 43: |
1. Richt click on the subject : In this way, brainstorm will load the inner, outer and the head from the subject data. if any of these surfaces is missing, an error will be displayed. 1. Select the 'Generate FEM mesh' item, 1. Select the iso2mesh option, 1. Set the iso2mesh parameters, |
==== Options ==== * '''MergeMesh''': Simply concatenates the input surfaces without any intersection checks. Default option (faster). * '''MergeSurf''': Concatenates and checks for intersections, split intersecting elements. Advanced option (slower). * '''Max tetrahedral volume''': Maximum volume of the tetrahedral element in the mesh. * From our tests, a DUNEuro FEM head model with a value of 0.1 achieves similar results as the OpenMeeg head model computed from the same surfaces. We have also noticed that the result with v = 0,001 is almost similar to v = 0,01. * Increasing the mesh resolution requires more time to generate the mesh, more time and memory to perform the FEM computation and more storage space in the database. * '''Percentage of elements kept''': Parameter between 0-100%, used to keep or not the original input surface nodes. |
Line 42: | Line 51: |
1. These options are used by the surf2mesh function. Select either '''MergeMesh''' or '''MergeSurf.''' 1. '''Max tetrahedral volum''' : is the maximum volume of the tetrahedral element in the mesh. '''Pourcentage of the element to keep''': parameter between 0-100%, it used to keep or not the original input surface nodes. |
==== Examples ==== * FEM mesh with different values of "Max volume": [10, 1, 0.1, 0.01] - Kept ratio=100%.<<BR>><<BR>> {{attachment:iso2meshMaxvol.gif}} * FEM meshes with only two compartments: This could be useful for investigating the influence of a specific tissue on the EEG/MEG forward solution or on the source localization, or for analyzing SEEG only within the brain volume. On the left: head and outer skull; On the right: inner and outer skull. <<BR>><<BR>> {{attachment:iso2Mesh2layer.gif}} |
Line 46: | Line 55: |
Also, a full example is explained in this [[https://neuroimage.usc.edu/brainstorm/Duneuro?highlight=(duneuro)|page]]. | ==== Troubleshooting ==== * '''Tetget failed''': If intersections are present on the surfaces mesh, the iso2mesh FEM mesh generation fails (tetgen). You may need regenerate new surfaces from the MRI. ''' ''' * Alternatively: You may try with the MergSurf option, this option can correct the intersection and create new nodes and elements. However, 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 48: | Line 59: |
. | == Brain2mesh == [[http://mcx.space/brain2mesh/|Brain2mesh]] is a MATLAB/Octave based 3D mesh generation toolbox dedicated to the creation of high-quality multi-layered brain mesh models. This software is developed by the same team developing Iso2mesh and relies heavily on it. Both are available as a [[https://Tutorials/Plugins|Brainstorm plugins]]. Warning: Requires the '''Imaging Processing Toolbox'''. |
Line 50: | Line 62: |
{{attachment:iso2meshProcess.JPG||height="380",width="720"}} | Brainstorm runs the '''SPM12 '''segmentation routine on the '''T1 '''or '''T1+T2 MRI''' volumes to obtain a 5-tissue classification (white matter, gray matter, CSF, skull and skin), which is then passed to Brain2mesh for 3D meshing. A full example is available in the tutorial [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemTensors#FEM_mesh|FEM tensors estimation]]. This option runs fast, but does not generate good quality cortex surfaces, which are needed for the full cortically-constrained source estimation pipeline in Brainstorm. |
Line 52: | Line 64: |
Here is a view of mesh obtained with different values of the Max volume = [10, 1, 0.1, 0.01] with a keep ratio = 100%. | At the moment, Brainstorm can only use the default parameters of Brain2mesh. If you need more options to be available from the interface, please contact us on the user forum. |
Line 54: | Line 66: |
{{attachment:IcbmMeshModels.jpg||height="420",width="700"}} | {{attachment:brain2meshCall.gif}} |
Line 56: | Line 68: |
From our experience, a value of 0,1 for the tetrahedral volume achieves similar results as the OpenMeeg computed from the same surfaces. And we have noticed that the result with v = 0,001 is almost similar to v = 0,01. Increasing the mesh resolution needs more time to generate the mesh, more time to perform the FEM computation and of course more memory to store the mesh in the disc. | {{attachment:brain2meshMesh.gif}} |
Line 58: | Line 70: |
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. | ==== Troubleshooting ==== * '''SPM-related errors''': If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: '''Restart Matlab''' to get a fresh workspace. |
Line 60: | Line 73: |
==== other use ==== You can also select any surface mesh, or multiple surfaces (with Shift key), on the brainstorm anatomy windows and then generate tetrahedral mesh y following the same steps above. |
== SimNIBS == [[https://simnibs.github.io/simnibs|SimNIBS]] software was developed to calculate the electric fields caused by Transcranial Electrical Stimulation (TES) and Transcranial Magnetic Stimulation (TMS). All its software dependencies (CAT12, Netgen, Gmsh, MeshFix) are embedded in the SimNIBS installation, which ensures a high stability and portability. However, it cannot be managed automatically as a plugin by Brainstorm, and needs to be installed manually. See: [[https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html|Download and install SimNIBS]]. Two versions of SimNIBS are currently supported, that include different segmentation pipelines: SimNIBS 3.x (headreco) and SimNIBS 4.x (charm). |
Line 63: | Line 76: |
Here are some examples using only some 2 tissues. This option could be useful for investigation of tissue influence on the EEG/MEG source localization or analyzing only SEEG within brain volume ... | === SimNIBS 3: headreco === SimNIBS 3.x includes the pipeline [[https://simnibs.github.io/simnibs/build/html/documentation/command_line/headreco.html|headreco]] to process '''T1''' or '''T1+T2 MRI''' volumes (T1 is required, [[https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html|T2 is recommended]]) and generate a high-quality tetrahedral FEM mesh. It calls internally [[https://neuroimage.usc.edu/brainstorm/Tutorials/SegCAT12|CAT12]] for tissue segmentation (white matter, gray matter, CSF, skull and scalp), and therefore gives us access to high-quality cortex surfaces and surface-based atlases. The tetrahedral mesh generation is done with Gmsh, Netgen and MeshFix. Depending on your computer performances, this process will take between 2 to 5 hours. |
Line 65: | Line 79: |
{{attachment:otherMesh.JPG||height="320",width="600"}} | {{attachment:simnibs.gif}} |
Line 67: | Line 81: |
=== brain2mesh === Brain2Mesh is a MATLAB/Octave based 3D mesh generation toolbox dedicated to the creation of high-quality multi-layered brain mesh models. |
{{attachment:simnibs2.gif}} |
Line 70: | Line 83: |
'''Requirement''' | {{attachment:simnibs3.png}} |
Line 72: | Line 85: |
Brain2Mesh is developed by the same team that developed the iso2mesh toolbox. Therefore iso2mesh is required. So if these toolboxes are not available on your computer, Brainstorm will download the last release and install it when it's needed. | ==== Options ==== * '''Vertex density''': Number of node per mm2 of the surface mesh. * '''Number of vertices''': This is not an input parameter of SimNIBS, but a parameter to control how much to downsample the cortex surface generated by CAT12 when importing it into the Brainstorm database. See the [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#Import_the_anatomy|introduction tutorials]]. |
Line 74: | Line 89: |
You may also need the SPM12 toolbox. Brain2mesh is used only to generate tetrahedral mesh from the segmentation output. Therefore a segmentation of the MRI will be performed by SPM when this option is called. | === SimNIBS 4: charm === SimNIBS 4.x includes the pipeline [[https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html#head-modeling-tutorial|charm]] to process '''T1''' or '''T1+T2 MRI''' volumes (T1 is required, [[https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html|T2 is recommended]]). This pipeline generates the highest-quality tetrahedral FEM mesh we can get from Brainstorm. It creates segmentations and meshes with more tissues than SimNIBS3/headreco: white matter, gray matter, CSF, compact bone, spongy bone, scalp, eyes, blood and muscle. It also creates high-resolution cortex surfaces registered with the FSAverage template, but it does not generate the full CAT12 output folder anymore. For surface and volume-based atlases, it might be necessary to execute CAT12 from Brainstorm on top of SimNIBS. |
Line 76: | Line 92: |
More parameters will be added in the next version. If you are using this method you can request our support to help you or to add these parameters asap. | Given the high quality of its outputs, SimNIBS/charm is the recommended method for FEM mesh generation in Brainstorm. A full example is available in the tutorial: [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMedianNerveCharm#FEM_mesh_with_SimNIBS|FEM median nerve example]]. |
Line 78: | Line 94: |
'''When and how to use it''' This option is used when you have the individual MRI of the subject either T1 or T1 and T2. As said before, the SPM toolbox is required. The time required for this option is around 1 hour. here is the view of the obtained mesh from a T1 MRI | {{attachment:charm1.gif}} |
Line 80: | Line 96: |
{{attachment:brain2meshModel.JPG||height="450",width="600"}} | {{attachment:charm2.png}} |
Line 82: | Line 98: |
More details will be added to this part door. | ==== Options ==== * '''Number of vertices''': This is not an input parameter of SimNIBS, but a parameter to control how much to downsample the cortex surface generated by CHARM when importing it into the Brainstorm database. See the [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#Import_the_anatomy|introduction tutorials]]. |
Line 84: | Line 101: |
=== Fieldtrip === This option call the process of segmentation and hexa mesh generation of simbio. |
==== Troubleshooting ==== * SimNIBS help: https://simnibs.github.io/simnibs/build/html/installation/throubleshooting.html * Forum: [[https://neuroimage.usc.edu/forums/t/brainstorm-not-recognising-path-or-command-to-simnibs-4-0-0/38963|SimNIBS library problems on Linux]] |
Line 87: | Line 105: |
This method calls the function ft_volumesegment then the ft_meshprepare of the field trip. | == ROAST == [[https://www.parralab.org/roast/|ROAST]] is a fully automated, Realistic, vOlumetric Approach to Simulate Transcranial electric stimulation. Open-source and Matlab-based, it is available as a [[https://Tutorials/Plugins|Brainstorm plugin]]. It calls internally SPM8 for tissue segmentation of the '''T1 '''or '''T1+T2 MRI''' volumes to obtain a 5-tissue classification (white matter, gray matter, CSF, skull and skin). Then it relies mostly on iso2mesh for generating a tetrahedral mesh. |
Line 89: | Line 108: |
The mesh generation process is faster. It converts all the voxels to hexahedral mesh. | This option runs fast, but does not generate good quality cortex surfaces, which are needed for the full cortically-constrained source estimation pipeline in Brainstorm. |
Line 91: | Line 110: |
Requirement | {{attachment:roast1.gif}} |
Line 93: | Line 112: |
The fielstrip toolbox and spm. | {{attachment:roast2.gif}} |
Line 95: | Line 114: |
Adaptative hexahedral mesh | ==== Troubleshooting ==== * '''SPM-related errors''': If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: '''Restart Matlab''' to get a fresh workspace. |
Line 97: | Line 117: |
view of the mesh | == Fieldtrip == [[http://www.fieldtriptoolbox.org/|FieldTrip]] is an open-source Matlab-based toolbox that includes a pipeline dedicated to the generation of [[http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg_fem/|hexahedral FEM mesh]]. It is available as a [[https://Tutorials/Plugins|Brainstorm plugin]]. |
Line 99: | Line 120: |
Brainstorm calls the function [[https://github.com/fieldtrip/fieldtrip/blob/release/ft_volumesegment.m|ft_volumesegment]] on the '''T1 MRI''' volume to obtain a tissue segmentation with 5 layers (white matter, gray matter, CSF, skull and skin), then [[https://github.com/fieldtrip/fieldtrip/blob/release/ft_prepare_mesh.m|ft_prepare_mesh_hexa]] to create a hexahedral mesh. | |
Line 100: | Line 122: |
{{attachment:ernieFieldtrip.JPG||height="600",width="450"}} | The mesh generation with the method is simple and fast: it downsamples the tissue classification volume, then converts all the voxels to a hexahedral mesh. The quality of the output is relatively poor: the regular meshing of the voxels makes it inefficient for providing a good representation of the tissues geometry with a limited number of elements. |
Line 102: | Line 124: |
{{attachment:fieldtrip1.gif}} | |
Line 103: | Line 126: |
'''SimNIBS Installation''' | {{attachment:fieldtrip2.gif}} |
Line 105: | Line 128: |
Please follow the instructions on this [[https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html|webapge]]''__ (new brainstorm page that explains how to generate the head model is under development)__'' | ==== Options ==== * '''Downsample volume before meshing''': When processing the tissue classification volume, reduce the number of voxels along each dimension by this factor. * '''Shift nodes to fit geometry''': The option calls the adaptative mesh generation. The process moves the nodes located on the interface either inward or outward in order to fit the geometry as explained in the [[http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg_fem/|FieldTrip tutorial]]. Below, the example from the FieldTrip website, left=original, right=shifted.<<BR>><<BR>> {{attachment:nodeShiftFigure.JPG||height="200",width="500"}} |
Line 107: | Line 132: |
in order to do the SimNibs software should be installed on your computer. | ==== Troubleshooting ==== * '''SPM-related errors''': If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: '''Restart Matlab''' to get a fresh workspace. |
Line 109: | Line 135: |
==== Iso2Mesh Installation ==== If iso2mesh is not installed on your computer, 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. |
== Zeffiro == [[https://github.com/sampsapursiainen/zeffiro_interface/wiki/Finite-Element-Mesh-generation|Zeffiro]] (ZI) is an open source code package constituting an accessible tool for multidisciplinary finite element (FE) based forward and inverse simulations in complex geometries, available as a [[https://Tutorials/Plugins|Brainstorm plugin]]. [TODO: Sampsa/Fernando: update the logo]. |
Line 112: | Line 138: |
==== Brain2Mesh Installation [TODO] ==== ==== Brainsuite Installation [TODO] ==== == FEM surfaces / Volume generation == === Volume mesh generation from Brainstorm === The most modern software that are used to generate the volume mesh head model are integrated within brainstorm with an easy graphical interface to use call these tools. |
Please note that Zeffiro require the Parallel Computing Toolbox. For further information please see [[https://github.com/sampsapursiainen/zeffiro_interface/wiki/Finite-Element-Mesh-generation|Zeffiro]] pages. |
Line 118: | Line 140: |
Right click on the subject and then "Generate FEM Mesh" | {{attachment:ZefMeshFig0.jpg||height="306",width="324"}} |
Line 120: | Line 142: |
{{attachment:menuGenerateFemMesh.PNG|height="40",width="150"}} | Brainstorm uses the Zeffiro Mesh tool to generate a FEM tetrahedral mesh from a set of '''nested surfaces''' representing the separation between different tissues of the head. For example, these surfaces can be generated to compute a [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem#BEM_surfaces|BEM forward model]]. |
Line 122: | Line 144: |
The available options are : | Zeffiro Mesh module plugin in Brainstorm follows the same structure as the iso2mesh case. Users can call the mesh generation either from the Subject node (fig1) or a set of selected surfaces (fig2). To select multiple surfaces, you can hold the "Ctrl" key and then select multiple surfaces with the mouse. |
Line 124: | Line 146: |
. {{attachment:FemMeshMethods.PNG|height="50",width="100"}} | If the user select the subject node, Brainstorm will automatiquly detect the three main surfaces [head, outer skull and inner skull]. [TODO: we can extend this for more surfaces if require] |
Line 126: | Line 148: |
"Iso2mesh" : This option merges the brainstorm surfaces available on the subject and then generarte the tetrahedral mesh. | {{attachment:ZefMeshFig1.jpg||height="750",width="750"}} |
Line 128: | Line 150: |
"Brain2Mesh" : This options uses the MRIs available on the subjects, then it calls the SPM segmentation of the volume into 5 tissus (white, gray, scf, skull and skin). After that it converts into a tetrahedral mesh. | If the user select multiple surfaces, [hold the Ctrl keyboard and select the surfaces with the mouse], Brainstorm will uses all the selected surfaces to generate the FEM mesh. |
Line 130: | Line 152: |
"SimNibs" : The recommended option, it calls the headreco {ref} and generate a FEM head model | {{attachment:ZefMeshFig2.jpg||height="630",width="630"}} |
Line 132: | Line 154: |
"FieldTrip" : (in progress) "Roast" : (in progress) | Once the Zeffiro option is selected, Brainstorm asks the user to either to use the advanced Zeffiro mesh module [click on "Yes"], or use the basic options from Brainstom (Click on "NO" Recommended). |
Line 134: | Line 156: |
"headreco" : | For the advanced options, please refer to the Zeffiro documentation [TODO: Sampsa/Fernando]. |
Line 136: | Line 158: |
https://simnibs.github.io/simnibs/build/html/documentation/command_line/headreco.html | For the basic option, brainstom will ask the users to set two option, the mesh resolution as the lenght edge of the mesh elements in (mm), the second option is asking for using the GPU computation, as shown in the following figure. |
Line 138: | Line 160: |
This function is part of the SimNibs software: | {{attachment:ZefMeshFig3.jpg||height="420",width="420"}} |
Line 140: | Line 162: |
https://simnibs.github.io/simnibs/build/html/index.html | The following figure illustrates the FEM mesh obtained using the Zef Mesh module on a defaced head surfcae, outer skull and inner skull. |
Line 142: | Line 164: |
=== 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:ZefMeshFig4.jpg||height="420",width="420"}} |
Line 145: | Line 166: |
=== 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 ....). |
== On the hard drive == Right-click on a FEM mesh > File > View file contents: |
Line 149: | Line 169: |
This process will | {{attachment:femContents.gif}} |
Line 151: | Line 171: |
- merge the surfaces, - check the self intersecting - fixe the size of the mesh - generate the volum mesh - visual checking ... - TODO : may be we can add some mesh auqlity measures ?? '''<<TAG(Advanced)>>''' === 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. ==> this depends lagely on the quality of the T1/T2 MRI image(https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html). This step is based on the "roast" toolbox (link to roast : https://github.com/andypotatohy/roast ) 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. * If 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 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. 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. - Explain here the main steps with screenshots : 1- Create new subject within the current protocole 2- Load the T1 of the subject to the brainstorm database. 3- Associate a T2 mri to the subject if it's available (this is better for csf/skull/scalp segmentation) 4- Right click on the subject, select the "Generate FEM mesh" . Select "SIMNIBS", and choose "Tetrahedral element" and keep the other options to the default value. 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. === FEM Head model template === - Load the FEM volumic mesh (template created from ICBM T1 MRI using SimNibs) - 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 ... ) https://github.com/brainstorm-tools/brainstorm3/issues/185#issuecomment-576749612 === Head model based on the level set approach === TODO and Validate == Errors == <<BR>>'''<<TAG(Advanced)>>''' <<BR>> The most modern software that are used to generate the volume mesh head model are integrated within brainstorm with an easy graphical interface to use call these tools. Right click on the subject and then "Generate FEM Mesh" The available options are : . "Iso2mesh" : This option merges the brainstorm surfaces available on the subject and then generarte the tetrahedral mesh. "Brain2Mesh" : This options uses the MRIs available on the subjects, then it calls the SPM segmentation of the volume into 5 tissus (white, gray, scf, skull and skin). After that it converts into a tetrahedral mesh. "SimNibs" : The recommended option, it calls the headreco {ref} and generate a FEM head model "FieldTrip" : (in progress) "Roast" : (in progress) "headreco" : https://simnibs.github.io/simnibs/build/html/documentation/command_line/headreco.html This function is part of the SimNibs software: https://simnibs.github.io/simnibs/build/html/index.html === 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. === 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 ....). This process will - merge the surfaces, - check the self intersecting - fixe the size of the mesh - generate the volum mesh - visual checking ... - TODO : may be we can add some mesh auqlity measures ?? '''<<TAG(Advanced)>>''' === 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. ==> this depends lagely on the quality of the T1/T2 MRI image(https://simnibs.github.io/simnibs/build/html/tutorial/head_meshing.html). This step is based on the "roast" toolbox (link to roast : https://github.com/andypotatohy/roast ) 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. * 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 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. 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. - Explain here the main steps with screenshots : 1- Create new subject within the current protocole 2- Load the T1 of the subject to the brainstorm database. 3- Associate a T2 mri to the subject if it's available (this is better for csf/skull/scalp segmentation) 4- Right click on the subject, select the "Generate FEM mesh" . Select "SIMNIBS", and choose "Tetrahedral element" and keep the other options to the default value. 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. === FEM Head model template === - Load the FEM volumic mesh (template created from ICBM T1 MRI using SimNibs) - 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 ... ) https://github.com/brainstorm-tools/brainstorm3/issues/185#issuecomment-576749612 === Head model based on the level set approach === TODO and Validate 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 computation and interface to DUNEuro == === Head model === Number of layers, conductivity value, isotropy/anisotropy/ mesh resolution/ === Electrode model === Check the position of the electrodes and align to the head model (projection if needed) === 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. However, for the FEM model, more paramters could be tuned for the source model. Choice of the source model : PI, Venant, Subtraction, Whitney Panel of the options choice that the user can select. (other wise we will set to default ) '''<<TAG(Advanced)>>''' === Advanced paramaters === - Solver parameters - Electrodes projection - maybe explain here the relevant option of the mini file ?? == Additional documentation == refer to : http://duneuro.org/ https://www.dune-project.org/ https://simnibs.github.io/simnibs/build/html/index.html == Reported Errors & alternative solution == '''<<TAG(Advanced)>>''' simnibs pblm : https://simnibs.github.io/simnibs/build/html/installation/throubleshooting.html == The MEEG forward problem with the FEM == == License == == Reference == == Additional documentation == https://github.com/brainstorm-tools/bst-duneuro/issues/1 https://github.com/brainstorm-tools/brainstorm3/issues/242 |
==== Structure of the FEM mesh files: tess_fem_*.mat ==== * '''Comment''': String displayed in the database explorer to represent the file. * '''Vertices''': [Nvertices x 3], coordinates (x,y,z) of all the nodes of the tetrahedral or hexahedral mesh, in SCS coordinates. * '''Elements''': * Tetrahedral mesh: [Nelements x 4], list of indices corresponding to the rows of the Vertices matrix, each set of 4 connected vertices identifying a tetrahedron of the mesh. * Hexahedral mesh: [Nelements x 8], list of indices corresponding to the rows of the Vertices matrix, each set of 8 connected vertices identifying a hexahedron of the mesh. * '''Tissue''': [Nelements x 1], for each Element, index of the corresponding tissue (e.g. wm=1, gm=2, csf=3, skull=4, scalp=5) * '''TissueLabels''': Labels of the tissues, e.g. {'white' 'gray' 'csf' 'skull' 'scalp'} * '''Tensors''': [Nelements x 12] if tensors are computed, otherwise empty. The 12 values are the eigenvalues and eigenvectors interpolated on each element of the mesh. * '''History''': List of operations performed on this file (menu File > View file history). |
FEM mesh generation
Authors: Takfarinas Medani, Francois Tadel
FEM forward modeling requires the construction of a 3D model of thee head tissues. The volume of the head is divided in small geometrical elements with 4 faces (tetrahedrons) or 6 faces (hexahedrons). Each element is associated with a type of biological tissue (e.g. white matter, gray matter, CSF, skull, skin) and electrical conductivity properties.
This page lists the methods integrated with Brainstorm to generate 3D meshes of the head. For a generic introduction to FEM in Brainstorm, refer to the tutorials: Realistic head model: FEM with DUNEuro and FEM median nerve example.
Contents
Generate FEM mesh
FEM meshes can be computed from surfaces (as the ones generated for the BEM models) or from MRI volumes (T1w and/or T2w). The methods that are available when using the popup menu Generate FEM mesh depend on the selected inputs.
Surfaces
Select a list of surfaces representing the separation between different tissues (holding the CTRL or SHIFT key), then right-click on any of them. The software Iso2mesh can create a tetrahedral mesh to represent the tissues between these different layers.
T1 MRI
Right-click on a T1 MRI available in the database. Typically, this is the default MRI volume displayed in green in the subject folder. Methods available: Brain2mesh, SimNIBS3, SimNIBS4, ROAST, FieldTrip.
T1+T2 MRI
Select the T1+T2 volumes, then right-click on any of them. The different files are identified based on the tags "T1" and "T2" the file names (as displayed in the Brainstorm database explorer). If these identification tags are not found in the file names, the default MRI (in green) is used as the T1, the other as the T2. If none of the is the default MRI, the first selected file is used as the T1, the second is used as the T2. Methods available: Brain2mesh, SimNIBS3, SimNIBS4, ROAST.
Anatomy folder
If you right-click on the subject folder > Generate FEM mesh, then Brainstorm offers all the possible options, even the ones that are not applicable to this specific subject.
Volume method: If using a method based on MRI volumes, the T1 and T2 volumes are detected among all the volumes available based on the tags "T1" and "T2" in the file names (make sure only one file as each of these tags), otherwise use only the default MRI (in green) as the T1.
Surface method: If using a method based on surfaces, the default surfaces (in green) from three categories as selected: the inner skull, the outer skull and the head surfaces.
Iso2mesh
Iso2mesh is a Matlab/Octave-based mesh generation and processing toolbox, available as a Brainstorm plugin.
Brainstorm uses it to generate a FEM tetrahedral mesh from a set of nested surfaces representing the separation between different tissues of the head. For example, these surfaces can be the ones generated for the computation of a BEM forward model. A full example is available in the tutorial Realistic head model: FEM with DUNEuro.
Options
MergeMesh: Simply concatenates the input surfaces without any intersection checks. Default option (faster).
MergeSurf: Concatenates and checks for intersections, split intersecting elements. Advanced option (slower).
Max tetrahedral volume: Maximum volume of the tetrahedral element in the mesh.
From our tests, a DUNEuro FEM head model with a value of 0.1 achieves similar results as the OpenMeeg head model computed from the same surfaces. We have also noticed that the result with v = 0,001 is almost similar to v = 0,01.
- Increasing the mesh resolution requires more time to generate the mesh, more time and memory to perform the FEM computation and more storage space in the database.
Percentage of elements kept: Parameter between 0-100%, used to keep or not the original input surface nodes.
Examples
FEM mesh with different values of "Max volume": [10, 1, 0.1, 0.01] - Kept ratio=100%.
FEM meshes with only two compartments: This could be useful for investigating the influence of a specific tissue on the EEG/MEG forward solution or on the source localization, or for analyzing SEEG only within the brain volume. On the left: head and outer skull; On the right: inner and outer skull.
Troubleshooting
Tetget failed: If intersections are present on the surfaces mesh, the iso2mesh FEM mesh generation fails (tetgen). You may need regenerate new surfaces from the MRI.
Alternatively: You may try with the MergSurf option, this option can correct the intersection and create new nodes and elements. However, 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.
Brain2mesh
Brain2mesh is a MATLAB/Octave based 3D mesh generation toolbox dedicated to the creation of high-quality multi-layered brain mesh models. This software is developed by the same team developing Iso2mesh and relies heavily on it. Both are available as a Brainstorm plugins. Warning: Requires the Imaging Processing Toolbox.
Brainstorm runs the SPM12 segmentation routine on the T1 or T1+T2 MRI volumes to obtain a 5-tissue classification (white matter, gray matter, CSF, skull and skin), which is then passed to Brain2mesh for 3D meshing. A full example is available in the tutorial FEM tensors estimation. This option runs fast, but does not generate good quality cortex surfaces, which are needed for the full cortically-constrained source estimation pipeline in Brainstorm.
At the moment, Brainstorm can only use the default parameters of Brain2mesh. If you need more options to be available from the interface, please contact us on the user forum.
Troubleshooting
SPM-related errors: If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: Restart Matlab to get a fresh workspace.
SimNIBS
SimNIBS software was developed to calculate the electric fields caused by Transcranial Electrical Stimulation (TES) and Transcranial Magnetic Stimulation (TMS). All its software dependencies (CAT12, Netgen, Gmsh, MeshFix) are embedded in the SimNIBS installation, which ensures a high stability and portability. However, it cannot be managed automatically as a plugin by Brainstorm, and needs to be installed manually. See: Download and install SimNIBS. Two versions of SimNIBS are currently supported, that include different segmentation pipelines: SimNIBS 3.x (headreco) and SimNIBS 4.x (charm).
SimNIBS 3: headreco
SimNIBS 3.x includes the pipeline headreco to process T1 or T1+T2 MRI volumes (T1 is required, T2 is recommended) and generate a high-quality tetrahedral FEM mesh. It calls internally CAT12 for tissue segmentation (white matter, gray matter, CSF, skull and scalp), and therefore gives us access to high-quality cortex surfaces and surface-based atlases. The tetrahedral mesh generation is done with Gmsh, Netgen and MeshFix. Depending on your computer performances, this process will take between 2 to 5 hours.
Options
Vertex density: Number of node per mm2 of the surface mesh.
Number of vertices: This is not an input parameter of SimNIBS, but a parameter to control how much to downsample the cortex surface generated by CAT12 when importing it into the Brainstorm database. See the introduction tutorials.
SimNIBS 4: charm
SimNIBS 4.x includes the pipeline charm to process T1 or T1+T2 MRI volumes (T1 is required, T2 is recommended). This pipeline generates the highest-quality tetrahedral FEM mesh we can get from Brainstorm. It creates segmentations and meshes with more tissues than SimNIBS3/headreco: white matter, gray matter, CSF, compact bone, spongy bone, scalp, eyes, blood and muscle. It also creates high-resolution cortex surfaces registered with the FSAverage template, but it does not generate the full CAT12 output folder anymore. For surface and volume-based atlases, it might be necessary to execute CAT12 from Brainstorm on top of SimNIBS.
Given the high quality of its outputs, SimNIBS/charm is the recommended method for FEM mesh generation in Brainstorm. A full example is available in the tutorial: FEM median nerve example.
Options
Number of vertices: This is not an input parameter of SimNIBS, but a parameter to control how much to downsample the cortex surface generated by CHARM when importing it into the Brainstorm database. See the introduction tutorials.
Troubleshooting
ROAST
ROAST is a fully automated, Realistic, vOlumetric Approach to Simulate Transcranial electric stimulation. Open-source and Matlab-based, it is available as a Brainstorm plugin. It calls internally SPM8 for tissue segmentation of the T1 or T1+T2 MRI volumes to obtain a 5-tissue classification (white matter, gray matter, CSF, skull and skin). Then it relies mostly on iso2mesh for generating a tetrahedral mesh.
This option runs fast, but does not generate good quality cortex surfaces, which are needed for the full cortically-constrained source estimation pipeline in Brainstorm.
Troubleshooting
SPM-related errors: If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: Restart Matlab to get a fresh workspace.
Fieldtrip
FieldTrip is an open-source Matlab-based toolbox that includes a pipeline dedicated to the generation of hexahedral FEM mesh. It is available as a Brainstorm plugin.
Brainstorm calls the function ft_volumesegment on the T1 MRI volume to obtain a tissue segmentation with 5 layers (white matter, gray matter, CSF, skull and skin), then ft_prepare_mesh_hexa to create a hexahedral mesh.
The mesh generation with the method is simple and fast: it downsamples the tissue classification volume, then converts all the voxels to a hexahedral mesh. The quality of the output is relatively poor: the regular meshing of the voxels makes it inefficient for providing a good representation of the tissues geometry with a limited number of elements.
Options
Downsample volume before meshing: When processing the tissue classification volume, reduce the number of voxels along each dimension by this factor.
Shift nodes to fit geometry: The option calls the adaptative mesh generation. The process moves the nodes located on the interface either inward or outward in order to fit the geometry as explained in the FieldTrip tutorial. Below, the example from the FieldTrip website, left=original, right=shifted.
Troubleshooting
SPM-related errors: If you've been trying multiple methods successively, errors mentioning a spm_*.m function could be due to incompatible versions of SPM12 functions in the Matlab path. Brain2mesh, FieldTrip and ROAST all run different versions of SPM12 from the same instance of Matlab. Solution: Restart Matlab to get a fresh workspace.
Zeffiro
Zeffiro (ZI) is an open source code package constituting an accessible tool for multidisciplinary finite element (FE) based forward and inverse simulations in complex geometries, available as a Brainstorm plugin. [TODO: Sampsa/Fernando: update the logo].
Please note that Zeffiro require the Parallel Computing Toolbox. For further information please see Zeffiro pages.
Brainstorm uses the Zeffiro Mesh tool to generate a FEM tetrahedral mesh from a set of nested surfaces representing the separation between different tissues of the head. For example, these surfaces can be generated to compute a BEM forward model.
Zeffiro Mesh module plugin in Brainstorm follows the same structure as the iso2mesh case. Users can call the mesh generation either from the Subject node (fig1) or a set of selected surfaces (fig2). To select multiple surfaces, you can hold the "Ctrl" key and then select multiple surfaces with the mouse.
If the user select the subject node, Brainstorm will automatiquly detect the three main surfaces [head, outer skull and inner skull]. [TODO: we can extend this for more surfaces if require]
If the user select multiple surfaces, [hold the Ctrl keyboard and select the surfaces with the mouse], Brainstorm will uses all the selected surfaces to generate the FEM mesh.
Once the Zeffiro option is selected, Brainstorm asks the user to either to use the advanced Zeffiro mesh module [click on "Yes"], or use the basic options from Brainstom (Click on "NO" Recommended).
For the advanced options, please refer to the Zeffiro documentation [TODO: Sampsa/Fernando].
For the basic option, brainstom will ask the users to set two option, the mesh resolution as the lenght edge of the mesh elements in (mm), the second option is asking for using the GPU computation, as shown in the following figure.
The following figure illustrates the FEM mesh obtained using the Zef Mesh module on a defaced head surfcae, outer skull and inner skull.
On the hard drive
Right-click on a FEM mesh > File > View file contents:
Structure of the FEM mesh files: tess_fem_*.mat
Comment: String displayed in the database explorer to represent the file.
Vertices: [Nvertices x 3], coordinates (x,y,z) of all the nodes of the tetrahedral or hexahedral mesh, in SCS coordinates.
Elements:
- Tetrahedral mesh: [Nelements x 4], list of indices corresponding to the rows of the Vertices matrix, each set of 4 connected vertices identifying a tetrahedron of the mesh.
- Hexahedral mesh: [Nelements x 8], list of indices corresponding to the rows of the Vertices matrix, each set of 8 connected vertices identifying a hexahedron of the mesh.
Tissue: [Nelements x 1], for each Element, index of the corresponding tissue (e.g. wm=1, gm=2, csf=3, skull=4, scalp=5)
TissueLabels: Labels of the tissues, e.g. {'white' 'gray' 'csf' 'skull' 'scalp'}
Tensors: [Nelements x 12] if tensors are computed, otherwise empty. The 12 values are the eigenvalues and eigenvectors interpolated on each element of the mesh.
History: List of operations performed on this file (menu File > View file history).