Realistic head model: BEM with OpenMEEG
Authors: Francois Tadel, Alexandre Gramfort
This forward model uses a symmetric boundary element method (symmetric BEM) and was developed by the French public research institute INRIA (website). It uses three realistic layers (scalp, inner skull, outer skull). The goal of this forward solution is mostly for EEG users, to provide more accurate results than the spherical models. It is not necessary for MEG users, as the "overlapping spheres" method gives similar results but much faster. This method is illustrated using the tutorial EEG and epilepsy.
OpenMEEG is distributed under the French opensource license CeCILL-B. It is intended to give users the freedom to modify and redistribute the software. It is therefore compatible with popular opensource licenses such as the GPL and BSD licenses. The CeCILL-B license imposes to anybody distributing a software incorporating OpenMEEG the obligation to give credits (by citing the appropriate publications), in order for all contributions to be properly identified and acknowledged.
The references to be acknowledged are:
Gramfort A, Papadopoulo T, Olivi E, Clerc M
OpenMEEG: opensource software for quasistatic bioelectromagnetics
BioMedical Engineering OnLine 45:9, 2010
Kybic J, Clerc M, Abboud T, Faugeras O, Keriven R, Papadopoulo T
A common formalism for the integral formulations of the forward EEG problem
IEEE Transactions on Medical Imaging, 24:12-28, 2005 | pdf
On Windows 64bit systems, you need to install an extra Microsoft software package to run OpenMEEG: Microsoft Visual C++ 2010 Redistributable Package (x64).
For computing a realistic BEM forward model we need the subject's anatomy to include surfaces representing the boundaries between the tissues used in the model: scalp (head/air interface), outer skull (scalp-skull interface), and inner skull (skull/brain+CSF interface). These layers must be very smooth for OpenMEEG. Brainstorm offers two solution to create smooth approximations of the skull surfaces appropriate.
Let's consider a subject including the files needed for the computation of an analytical forward model: MRI, head surface, cortex surface (= source space). From the anatomy view of the protocol, right-click on a subject folder > MRI segmentation > Generate BEM surfaces. Two methods are available, using Brainstorm or FieldTrip.
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.
This solution only needs the T1 MRI in input, but requires FieldTrip to be installed, as a plugin or as an independent toolbox - see the Plugins tutorial. It creates a volume segmentation in at most 5 tissues, and tesselates the boundaries between these tissues.
In the example below, the inner skull surface is more realistic than with the Brainstorm approach. However, it would cause problems with OpenMEEG because it intersects the cortex surface in many places. The cortex surface needs to be edited to force all the vertices (ie. all the dipoles) inside the innermost layer.
The FieldTrip tissue segmentation can be reused for other purposes. It labels everything within the innermost layer in the same way, in the example below, all the brain is labelled as CSF. This does not cause any particular problem, it would be interpreted as "brain+CSF".
Number of vertices per layer
- The more vertices for each layer, the more accurate your head model. If there are not enough vertices, OpenMEEG may consider that the surfaces are intersecting and crash before the computation, or it may finish but at the end the model may be unstable with a few vertices with values much higher than all the others.
- On the other hand, using more vertices on each layer increases the memory usage and the computation time. If your system hangs, if it takes 24hrs to run or if you get "Out of memory" errors, you should decrease the number of vertices for each layer.
The default values are high (1922 vertices per layer), to ensure that by default the results are good. If you can afford it computationally, you should use these 1922 vertices per layer. If you have to decrease these values, you can try for instance with 1082 vertices (scalp) and 642 vertices (outer skull and inner skull).
- If you are using the default ICBM152 anatomy, you do not need to run this, you can directly use the head/outerskull/innerskull surfaces in the the default anatomy folder. The number of vertices is much lower, but we know this anatomy to be stable, you should not need to recalculate new surfaces with more vertices.
- Switch to the view "Functional data (sorted by subjects)", 2nd button above the database explore.
Right-click on the channel file > Compute head model. Select OpenMEEG BEM in the list.
- Explanations of the options:
BEM Layers & conductivities: You can select how many layers you want to use for the BEM model. The possible options in our case are Scalp (=head), Skull (=outer skull), and Brain (=inner skull). The values on the right are the relative conductivities of each layer.
- For EEG: Use all the layers
- For MEG: Use only the inner skull layer
Use adjoint formulation: Decrease significantly the amount of memory that is necessary in memory and on the hard drive, but much longer.
Use adaptive integration: This produces a more accurate solution, mostly in the cases of dipoles (vertices of the cortex surface) that are very close to the inner skull layer. Keep this option selected.
Process dipoles by blocks: If you consistently run into crashes, it could be because you don't have enough memory available. You can try to process the dipoles by smaller blocks. It would be longer but could work. Select this option only if you have memory errors.
Download OpenMEEG software? Yes.
This will download the latest version of the OpenMEEG binaries for your operating system from the INRIA website, and install it as a Brainstorm plugin.
Then the calculation of the head model will automatically start. You may wait for a long time. Be patient, it's worth it...
You have now a new head model for this subject.
Warning: Dipoles outside
OpenMEEG BEM solver may be unstable when the dipoles (= the vertices of the cortex surface) are outside or too close to the innermost layer (= the brain/inner skull surface). Brainstorm tries to detect for which dipoles OpenMEEG could return wrong values, and displays a warning if any:
This doesn't mean that these points would necessarily cause problems in the BEM forward model, but it is important to be aware that they might, and check this carefully. First, evaluate visually the intersections between the cortex and the innerskull surfaces: display both in a 3D view by double-clicking on them, then from the Surface tab, set a bright color for the cortex and 0% transparency for the innerskull. This image may reveal that some parts of the cortex are sticking out of the inner skull surface.
To fix the surfaces, two solutions:
Fix the inner skull surface by recomputing the BEM surfaces with more vertices. With more points, the envelope would have more details to wrap better the cortex surface. Always try this option first. The figures below show 12 dipoles outside the 482V inner skull, while all the dipoles fit in the 1922V inner skull.
Fix the cortex surface with the popup menu Force inside skull: pushes the vertices that are outside of the inner skull surface into it. This can be a solution to quickly get rid of the surface intersection and avoid mathematical issues in the computation of the BEM solution. However, this is only adapted to correct for minor topological issues, when the cortex surface is almost tangential to the skull and only a few cortex vertices appear outside. When selecting this option, the original surface is displayed with red dots for the edited vertices, together with the new fixed surface.
Note that this is only a WARNING: even with many suspicious points, the BEM forward model might be entirely valid. You may decide to keep the surfaces unmodified, and go back to fixing them only if you observe abnormal lead fields or source values at these locations.
To display the forward fields, right-click on the BEM head model > View lead field vectors. Abnormal displays may look like the one below: one or a few arrows are much longer than all the others. You may need to adjust the relative size of the lead field arrows in order to see something - press H for help. In this case, one of the occipital dipoles that was initially detected as a possible problem shows an abnormality that may impact your source analysis: the surfaces should be fixed and the forward model recomputed.
The example used to illustrated this section is the EEG/Epilepsy tutorial, using BEM surfaces with 642/482/482 vertices. Everything can be reproduced easily.
OpenMEEG may crash for various reasons: we tried to list the possible causes here.
OpenMEEG error #1:
./om_assemble: /usr/local/MATLAB/R2013b/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.19’ not found (required by ./om_assemble)
Cause: Your version of Matlab uses a version of library libstdc++ that is older than the one required by OpenMEEG.
Solution: If your operating system is up-to-date, you should have a newer version available on your hard drive. You need to tell Matlab to use the local version of libstdc++ instead of the one shipped with Matlab. In order to do this, open a terminal and start Matlab in the following way:
- You might need to adjust the path to the Matlab executable (get it by typing "which matlab") or the libstdc++ library (type "locate libstdc++.so.6" and pick the one in /usr/lib)
You get a system error: your computer doesn't want to execute om_assemble or any other om_* program because the developers are unknown.
Solution: Go to the OpenMEEG installation folder (most likely somewhere in $HOME/.brainstorm) and explicitly tell your system that each one of these om_* executables are OK to execute (look it up if you don't find an obvious way to do so).
- OpenMEEG error #-1073741515:
Cause: Missing package in Windows.
Solution: Install the "Microsoft Visual C++ 2010 Redistributable Package": http://www.microsoft.com/download/en/details.aspx?id=14632
- OpenMEEG crashes on a 32bit operating system:
Cause: OpenMEEG needs to address a lot of memory, which is not be possible on a 32bit OS.
Solution: Use a different computer.
- OpenMEEG cannot be downloaded:
Cause: You have a proxy that is not configured correctly with Matlab.
Solution: Download OpenMEEG manually (http://openmeeg.gforge.inria.fr/download/) and use the Brainstorm menu Update > Update OpenMEEG > Install.
- The default version of OpenMEEG is not supported on your system:
Solution: Download another OpenMEEG release manually (http://openmeeg.gforge.inria.fr/download/) and use the Brainstorm menu Update > Update OpenMEEG > Install.
- OpenMEEG crashes after a long computation time or runs forever:
Cause: Your system possibly ran out of memory. Open a resource monitor on your computer, start again the forward model computation and check the evolution of the memory usage. If it goes above 90-95%, you are reaching the maximum capacity of your system. It might start swapping (using the hard drive instead of the RAM memory, which is awfully slow) or simply crash.
Solution: Use a simplified model: BEM layers with less vertices, and/or less dipoles in your source space (downsample the cortex surface), and/or different OpenMEEG options.
- Intersecting meshes or triangles:
Cause: OpenMEEG runs only on closed, regular, very smooth surfaces and non-intersecting surfaces. A surface can be self-intersecting or two layers can be crossing each other even if you cannot see it when displaying them with Brainstorm.
Solution:Iif you were trying to use BEM surfaces from a different source, try computing them from Brainstorm using the menu "Generate BEM surfaces". If it crashes with BEM surfaces generated with Brainstorm, try increasing the number of vertices on the various layers, or try different combination of values for the various layers.
Solution not found
If you cannot find a solution, please post a bug report on the Brainstorm user forum:
- Copy-paste the full error message from the Matlab command window.
Zip the contents of the folder $HOME/.brainstorm/tmp immediately after the crash, upload it somewhere and include the download link in your bug report.
- Include a screen capture of a 3D figure showing the sensors and all the BEM surfaces.