Some dipoles outside BEM layer - error while computing headmodel with default anatomy

,

Hi,

I'm trying to compute an MRI volume BEM headmodel for source analysis, using the default ICBM152 anatomy and Biosemi 64 channel 10-10 default EEG cap.
No matter how what settings I change, I always get the same error when computing the volume:

WARNING: Some dipoles are outside the BEM layers (89 dipoles).
The leadfield for these dipoles is probably incorrect.

Following advice on the forum post linked below,
I have adjusted a number of factors, such as grid resolution, adaptive vs standard grid etc. It seems I can only adjust the number of dipoles outside the BEM layers but never make sure no dipole is outside the layers.

[The other post]

best wishes,
Rick

Hi!
I had the same problem, but I fixed it using FEM mesh and Duneuro, it is faster than conventional methods, there is a BS tutorial:

https://neuroimage.usc.edu/brainstorm/Tutorials/Duneuro?highlight=(fem)

Hope it works!

Regards!

ps: I'm not sure but I think it is not necessary to compute BEM when using default anatomy, maybe that could lead to the outside dipole problem

1 Like

Hi,

Thanks, @tourette95 for your answer.

Indeed, bst-duneuro seems to be faster in some cases and it can handle the unstable sources.
However, we highly recommend having all the dipoles within the inner layer (case of the three-layer model).
A good way to check if the forward model is stable enough is to display the leadfield vector, by right click on the forward model and then 'view leadfield vectors'.

A+

Thanks! :slight_smile:

So I have tried to display the leadfield vectors .. and it then seems like some of the red dots (dipoles?) are outside the inner skull. However, this does not help me actually prevent it from happening in the first place.

Any ideas?

@rsomervail
Are you working with a database that was created more than a few months ago?
Or a version of the Brainstorm software that was downloaded before may 2020?
The ICBM152 template was fixed in this commit: https://github.com/brainstorm-tools/brainstorm3/commit/fcff5e998b2719c6ee691692f1ae7e9b839cae1f

  1. Update Brainstorm
  2. In your protocol, update the ICBM152 template: right-click on "Default anatomy" > Use template > ICBM152.
  3. you need to repeat everywhere you've been using the ICBM152 template.

If you do not modify the template, computing a BEM solution should not trigger this warning about dipoles being outside of the BEM layers.

@rsomervail @tourette95
Please be aware that FEM computation is not ready yet.
As the tutorial mentions at the top of the page: this is not ready for production.
To use at your own risks...

Ahh this explains it, I was using the April 2020 version of Brainstorm.

After updating to 08 May 2020 (both by updating from within Brainstorm, and by reinstalling from the neuroimage website, I am still receiving the same error. (I did also update the template as in your "step 2")

I then tried to reinstall again, but this time with the latest GITHUB version and the head model error is gone now.

Something very strange though.. this version is labelled "25 May 2019", so I think when updating Brainstorm from within the toolbox, it updates to "08 May 2020" instead. This was also the version that the main website gave me.
Could there be a labelling issue with the github version?

Thank you!

  • Rick

Ahh this explains it, I was using the April 2020 version of Brainstorm.

No, this is not the problem, the cortex surface from the ICBM152 anatomy was already fixed in April 2020.
The problem was the anatomy template not being updated correctly, either in the Brainstorm installation folder, or in your $HOME/.brainstorm folder, or in your protocol folder.

Something very strange though.. this version is labelled "25 May 20 19 ",

Which label are your referring to?
It is possible that there is a file that we forgot to update, but the version on our github repository is the one that is re-packaged everyday and made available from download on the Brainstorm website...

Is it possible that you have some confusion in your Matlab path?
Or that there you have some file rights issues that prevents Brainstorm from being to update itself completely?

  1. In Brainstorm, menu File > Edit preferences > Reset.
  2. When Brainstorm restarts, you will need to select again the brainstorm_db folder
  3. Close Brainstorm
  4. Edit the Matlab path and remove everything that is not related with the MATLAB installation.
  5. Close Matlab, restart Matlab
  6. Do NOT add any Brainstorm folder to the Matlab path, just go to the brainstorm3 folder and execute brainstorm.m

I should add that a colleague independently downloaded the latest version (8th May 2020) and also had the cortex surface issue.

This is the label I was referring to with the date for the cortex surface bugfix, I assumed that this was a mistake as your previous message implied the bugfix was recent ("more than a few months ago"):
image

Is it possible that you have some confusion in your Matlab path?
Each time I did this, I restored the default path for matlab and checked that there was nothing referring to brainstorm left.

Or that there you have some file rights issues that prevents Brainstorm from being to update itself completely?
This is possible, as I had another issue that the FEM toolboxes failed to install properly via brainstorm (although they did seem to download into the .brainstorm folder ok). However, I mad sure that these folders had full permission and started matlab in administrator mode.

[List of instructions]
I followed these instructions, and then tried to update through brainstorm.
Afterwards, my version of brainstorm (8th of May 2020) has the dipole error again, as if it has reverted back to the pre-fix cortex model.. Note that this was not the case immediately before following these instructions (when I had the 25th May 2019 version).

What do you mean?
How did you get this version?

As I mentioned before: this is not a Brainstorm version issue, but a problem related with the database. The cortex surface in the anatomy folder is outdated and needs to be updated.

With the latest Brainstorm version: Reset the preferences, create a new protocol, import a piece of EEG recordings and compute a forward model. Just to make sure that this works correctly.

How did you get this version?
I got this version (May 2019) from the github link you sent,. Fresh installs of this version allowed me to create protocols with a working cortical surface model.

With the latest Brainstorm version: Reset the preferences , create a new protocol , import a piece of EEG recordings and compute a forward model. Just to make sure that this works correctly.
I did this again, and still received the same error.
Note that I already attempted several fresh installations with this latest version, each time creating totally new protocols, which is what led me to try the may 2019 version.

I got this version (May 2019) from the github link you sent,. Fresh installs of this version allowed me to create protocols with a working cortical surface model.

If you get an older Brainstorm version, you wouldn't get this warning simply because we were not testing if all the dipoles were within the BEM layers. It was not working better: the error was simply not detected.

Note that I already attempted several fresh installations with this latest version, each time creating totally new protocols, which is what led me to try the may 2019 version.

I could not reproduce what you describe with the Brainstorm EEG tutorial datasets.
Can you please share one of these example protocols you created?

  • Delete all the files that are not needed to reproduce the behavior:
    • in the anatomy, delete the ASEG atlas and all the surfaces but the low-resolution cortex,
    • in the functional data, keep only one channel file and one short block of imported data (1s long or less) - delete forward and inverse models
    • Make sure that if you right-click on the channel file > Compute head model > OpenMEEG with all the default options, you still get the warning.
  • Right-click on the subject > File > Export subject
  • Upload the zip file somewhere (dropbox, google drive...) and share the download link here

Thanks

*** Delete all the files that are not needed to reproduce the behavior:**
** * in the anatomy, delete the ASEG atlas and all the surfaces but the low-resolution cortex,**
** * in the functional data, keep only one channel file and one short block of imported data (1s long or less) - delete forward and inverse models**
** * Make sure that if you right-click on the channel file > Compute head model > OpenMEEG with all the default options, you still get the warning.**
*** Right-click on the subject > File > Export subject**
*** Upload the zip file somewhere (dropbox, google drive...) and share the download link here**

Following these instructions, I deleted every file except the low-resolution cortex & the MRI, but this then prevented me from computing a head model.. In the link below you can download the exported subject, but I had to include the surface files because brainstorm said they were necessary to compute the head model.

https://we.tl/t-C8vTslKECz

I did the following:

Therefore even with your example data, I can't reproduce the behavior you describe.
Can you confirm that if you do exactly the same, you do get the warning you posted earlier printed in the Matlab command window:

WARNING: Some dipoles are outside the BEM layers (89 dipoles).
The leadfield for these dipoles is probably incorrect.

Maybe the problem comes from the differences in Matlab versions or operating systems.

Can you please copy-paste here the output of the following commands:

ver
path
which inpolyhd

Hang on, are you computing a cortical surface headmodel? (i.e. not an MRI volume?).
As I said in my first post, the error is only occurring for the "MRI volume" headmodel, not the default "cortical surface" headmodel.

Repeating your exact steps, I get the same original error if I compute a volume model, and no error if i compute the cortical surface model.

The link below contains the output in my command window from the commands you asked for:
https://pastebin.com/8bQWWsFV

Oops, indeed, I forgot about this detail...
Sorry for making this unnecessarily complicated.

I added some code to exclude the sources outside of the inner skull:
https://github.com/brainstorm-tools/brainstorm3/commit/cbfec658d6d70aa03f51fb5c77652945b16929ad
Please update Brainstorm and try again.

No problem, I think that detail got a bit lost after the first post.
I have updated and now it's working - thanks for all your help!