FEM headmodel grid question

Dear @Francois @tmedani

As I had issues with FEM headmodel and discussed with you under the thread, I am still attempting with different options, the issue I had before occurred when computing the headmodel with MRI volume -> head grid, the reason of doing it is that I'd like to extract time series from the deep structure after the inverse solution. Now I found the error is not shown if I change my option to MRI volume -> brain grid, however, the default setting from the anatomy is cortex 15000V which has only cortical regions. If I change it to cortex (FEM) that included deep structure(brainstem and cerebellum, etc) the preview looks good to me as shown in the attached figure.
Screen Shot 2021-06-10 at 9.04.20 AM

My questions:

Is switching from cortex 15000V to cortex(FEM) an acceptable way of making headmodel?

If I selected with only the brain grid, does that mean the headmodel computation only uses the mesh of the inner layer without considering the conductivity of the rest four layers?

Would it be a good idea to force the source space to gray layer in this case(compute with brain grid) or it is no longer needed?

As introduced in the tutorial, it is recommended to remesh from simNibs FEM output, since there is no error reported, is it still a compulsory step to do before making headmodel?

Thank you very much for your time and looing forward your reply.

1 Like

If you select the entire head, many source points would be located in the skull and skin: FEM modelling is expected to fail for these points.
We need to capture this error and add clear error messages when trying to run FEM computation on source points outside of the inner skull surface.

@kenzo0619 Could you please copy-paste here the error you get when trying to use the full head volume?

@tmedani How do you detect and handle such points in the code?

Is switching from cortex 15000V to cortex(FEM) an acceptable way of making headmodel?

I don't see any problem with this solution. It is a different way to create a grid points, but all of them should be located within the brain.

If I selected with only the brain grid, does that mean the headmodel computation only uses the mesh of the inner layer without considering the conductivity of the rest four layers?

This grid of green points (as on the screen captures you posted) are the brain locations for which you want to estimate the electric activity. You should not have "brain sources" in the other layers.
If the difference between the "head model" (model explaining how the currents flow from the brain sources to the sensors on the skin) and the "source space" is not clear to you, get back to introduction tutorials on these topics:
https://neuroimage.usc.edu/brainstorm/Tutorials/HeadModel
https://neuroimage.usc.edu/brainstorm/Tutorials/SourceEstimation

As introduced in the tutorial, it is recommended to remesh from simNibs FEM output, since there is no error reported, is it still a compulsory step to do before making headmodel?

@tmedani?

1 Like

Thank you very much @Francois, your feedback is very useful to me.

I have one more question regarding the batch process of head model computation. It seems that Duneuro is not parallelly optimized, so I wanted to get most of my CPUs used when computing the head model. Do you think I can achieve it by setting the temporary directory of the brainstem for each subject? so that each process can read&write into different folders so that they won't overwritten each other and save to the database in the end. I attached the idea as follows:

#!/bin/bash

for subject in subjectList
do
    # running compiled version of brainstorm.
    # each iteration runs a matlab script with custmised temporary directory.
    brainstorm3.command <MATLABROOT> <script.m> <parameters> & 
done

Hello all,
sorry for the delay on this post,

Yes, this is doable, this will create a grid bounded by the selected cortex surfaces, you may have some points outside of the brain, you need to uncheck the option "restrict" on the duneuro panel, this will avoid the crash but the solution on these dipoles will not be accurate since they are outside of the brain.
The FEM crashes when the dipoles are outside the FEM grid.

We don't have a dedicated solution now from the GUI, but a possible solution is to export the cortex surface to Matlab and then deflate it by few millimeters, and then import it back to brainstorm to use it as the surface to create the grid.
Also, If you are familiar with brainstorm and the management of the files, you can do it from the gui by playing with this process: "right click on the XX surface=>alligne manually on ==> YY" where you XX surface is the FEM cortex surface that you want to modify and the YY surface is the original FEM cortex surface. You can use the different options available there to change the chape, size ...

another possible solution is to force the grid dipole in the brain from matlab, and then use the forced dipole as an input from the gui.

image

what do you mean by selecting only the brain grid?
at which level of the process?

There is an option that allows you to select specific tissues on the duneuro panel, but it makes sense only for MEG and sEEG and not for EEG, EEG requires all the tissues.

this is an observed issue from users and it can happen in some cases, at this time the solution that we recommend is to re-mesh the model as explained before. This will be solved in the next version of the duneuro and simnibs.

The "force inside the grey" option works only for the surface model and not for the whole volume. This is not implemented yet in bst

.

Indeed, if you are using windows it's not, initially, Duneuro is built only for Linux OS, and the distributed version within brainstorm is a cross-compilation able to work on windows, however without the parallelization at this time.
But if you are in Linux it should work,
@juangpc could you confirm this lat statement?

I think this is doable, as far the temporary i/o files are independent
check this https://github.com/brainstorm-tools/brainstorm3/issues/345#issuecomment-714275083

But @Francois is the best guy who can answer this question.

Hello @tmedani

Thank you for your suggestion and detailed explanation.

Yes, this is doable, this will create a grid bounded by the selected cortex surfaces, you may have some points outside of the brain, you need to uncheck the option "restrict" on the duneuro panel, this will avoid the crash but the solution on these dipoles will not be accurate since they are outside of the brain.
The FEM crashes when the dipoles are outside the FEM grid.
We don't have a dedicated solution now from the GUI, but a possible solution is to export the cortex surface to Matlab and then deflate it by few millimeters, and then import it back to brainstorm to use it as the surface to create the grid.
Also, If you are familiar with brainstorm and the management of the files, you can do it from the gui by playing with this process: "right click on the XX surface=>alligne manually on ==> YY" where you XX surface is the FEM cortex surface that you want to modify and the YY surface is the original FEM cortex surface. You can use the different options available there to change the chape, size ...
another possible solution is to force the grid dipole in the brain from matlab, and then use the forced dipole as an input from the gui.

After activated the cortex(FEM) from the anatomy panel, I did not see any grid point outside brain as you can see from the screenshot above, so I guess I can just start to compute the head model if there are no green dots outside of the cortex and deep structure regions. May I know what does "restrict" option mean in the Venant option of Duneuro panel, I did not find information from Brainstorm tutorials. In addition, the default grid size is 5mm, how small would you suggest for high-density EEG(256 channels)?

what do you mean by selecting only the brain grid?
at which level of the process?

My question may be silly, I was wondering the step of Volume source grid as shown on your screenshot. I thought if I selected only the Brain option in the Regular grid(isotropic), the modeling process would just consider the layer of the selected cortex instead of all the layers.

Indeed, if you are using windows it's not, initially, Duneuro is built only for Linux OS, and the distributed version within brainstorm is a cross-compilation able to work on windows, however without the parallelization at this time.
But if you are in Linux it should work,
@juangpc could you confirm this lat statement?

I usually run my test on Win10 or Mac, I will deploy the head model computation on my cluster that built on Linux. I have tried previously, it indeed is faster than Mac/Win10 but from the CPU load, it did not seem to use all the cores. Is there any command need to specify before running or it is fully automated, I'm looking forward to the reply from @juangpc. Many thanks.

you can give it a try and see if it works.

This is an option specific to the StVenant source model, when checked it takes only the equivalent monopoles which are within the GM tissue, This is performed within the core computation of the Duneuro.

you can check this paper for more details: https://hal.sorbonne-universite.fr/hal-01222242/document as well as the new paper for the DUNEuro software : https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0252431

No, this will just load the surface file from the database from which the grid of dipoles will be placed. So you can select either the brain surface or the head surface.
btw, I'm not sure why we have the option of "Head" in this panel, it may be useful for TES, or maybe a request from users?
@Francois is there a specific reason for this option?

I'm not about the last version of the binaries that we have distributed, but there is chance that the // will work on Linux system, we will check this with @juangpc

The "head" option in the definition of the source grid is useful for investigating the sources outside of the brain, e.g. eyes or neck muscles. Examples in the resting state tutorial:
https://neuroimage.usc.edu/brainstorm/Tutorials/RestingOmega#Power_maps

My question may be silly, I was wondering the step of Volume source grid as shown on your screenshot. I thought if I selected only the Brain option in the Regular grid(isotropic) , the modeling process would just consider the layer of the selected cortex instead of all the layers.

As suggested in my first reply, there might be some confusion between the source space and the head model here...

Thanks for the explanation.

@Francois I'm following this tutorial now. After the inverse solution and importing scouts, is there a way to save the time series as a matlab variable ?

is there a way to save the time series as a matlab variable ?

Process "Extract > Scouts time series".

1 Like

Hi there,
I'm afraid the version we distributed implements serial computation. Cross-compilation for windows with enabled parallelization never got to work properly, so we decided to first go with a serial version.

In linux, parallelization could be achieved by linking against MPI and we managed to have it working at some point, Takfa had to remind me this :slight_smile:. For it to work, you could try recompiling the code, depending on how comfortable you are with linux c/c++ development, it might be very easy or quite time consuming. There was a flag that needed to be activated in duneuro's settings script file. Duneuro has specific compiling tool that takes care of the packages. As I said, depending of how comfortable you are, it might be worth just to try to parallelize at the subject/paradigm/stimulus level through different calls to the serial application we distributed. If you want to dive deeper let me know. Take care,

2 Likes