Zeros in DUNEuro Gain matrix

Hey there!

First, let's be thankful that we finally have the FEM model inside the Brainstorm!

However, I wonder why I always get the first row of the Gain matrix of FEM DUNEuro as zero, no matter how many channels I use or where the location of the reference channel is.
I use the MNI152 template of the Brainstorm and have computed the mesh by iso2mesh, and have selected the MRI volume DUNEuro method with its default parameters to build the head model. I also use the default registered channel's location files from the Brainstorm directory.

Plus, what comes a bit surprising to me is that the computation of the FEM model with this package is way too faster than the SimBio in Fieldtrip, which makes me think maybe the model is over-simplified somewhere, or that I'm missing some point. In my computer (average performance), with 60 channels and the default parameters, it takes only 3 mins to compute the leadfield, whereas in Fieldtrip for such setting I never get it for less than 6 hours!

Any help would be appreciated.
Maryam

1 Like

I wonder why I always get the first row of the Gain matrix of FEM DUNEuro as zero, no matter how many channels I use or where the location of the reference channel is.

I could observe the same problem on the DUNEuro gain matrices I have in my database: the first row contains only zeros.
@tmedani Is there some 0-1 indexing issue somewhere in the bst-duneuro code?

Plus, what comes a bit surprising to me is that the computation of the FEM model with this package is way too faster than the SimBio in Fieldtrip

DUNEuro is the successor of SimBio, and is expected to be faster.
However, running the comparison would require using the same parameters with both libraries, which I don't think is possible at the moment. FieldTrip-simbio works with dense hexahedral meshes, while Brainstorm-DUNEuro works with much lighter tetrahedral meshes.

Try running DUNEuro from FieldTrip, it seems to be supported:
https://www.fieldtriptoolbox.org/reference/ft_prepare_headmodel/

2 Likes

Github issue:

Hello all,

DUNEuro uses the first electrode as the reference for the forward computation, therefore it sets all the values to zeros for this electrode.
As far as I know, the same process is done with ft-simbio.

Then for the inverse computation, the average reference is applied by Brainstorm for this matrix.

If you want to use the Gain matrix outside of Brainstorm, you can either use the average re-referencing or re-reference the Gain matrix to your reference electrode, just be subtracting the value of your reference from all the electrodes (moving the zeros line to the new reference).

Yes, Duneuro is much faster since it uses a faster solver than the one implemented within ft_SimBio,
adding to @Francois comments, if you want to compare you need to have the same parameters and the same head model. ft_simbio has only the Venant source model and the parameters are fixed, the difference is in the source code, Duneuro is Cpp based and SimBio is a mixture of C and Fortran, and there are some differences in the solvers. Therefore you can find slight numerical differences.

I'm not sure that the ft-code version of this workshop is available at this time.
But I recommend reading the tutorials.

Best,
Takfarinas

Hello Takfarinas,

Thank you very much for your answer, it made me realize why I sometimes would get the same issue with FT, which is no longer actually an issue. In FT it was not clear enough why by only changing a few options (e.g. deleting some seemingly unused variables inside the main struct variable) the zero row would disappear, but fortunately, now we know what causes this.

So just to make sure if I have understood your answer clearly:

Do you mean I can simply get the mean of each column of the Gain matrix to make a new Gain matrix suitable for average-reference data? I am asking since the method of computations is not linear and is dependent on the channels' settings. So is applying the average function on this level (final Gain matrix) safe in terms of keeping the real contributions of every source to every channel? Theoretically I couldn't verify, so if you have any experience with it, it would be valuable to have it here.

@Francois Trying DUNEuro from FT sounds a good idea. I will let you know once I test it for computation time. And thanks for the follow-up.

1 Like

I'm not sure if I understand what you mean by "nonlinear", the gain matrix map the contribution of each source to each channel and it's linear. The average referencing is also a linear operation,
Here are some links where a similar topic is discussed

https://neuroimage.usc.edu/brainstorm/Tutorials/MontageEditor#Custom_montage

A+
Takfarinas

1 Like

Thanks for the informative links. I read the discussion fully, but I doubt if my problem was addressed there.
Dr. Mosher mentioned that primarily the Gain matrix is computed using an infinity (non-physical) reference, but what I concern here is that in computing FEM head model (either by Simbio or DUNEuro) we first consider the first channel as reference and set its share in all sources as zero no matter where it is located and how is connected to all sources in the brain anatomy, then after completing the computation of Gain matrix we apply the average-reference operator to give a bit of a value to the first channel thanks to the non-zero average value of every column (other channels' share in sources). In contrary, when computing a head model like 3 layers spheres we do not need to trivially consider a channel as reference and as a result no such problem will arise. So that's where I say computing the shares is nonlinear and I am skeptical if we can ignore one channel first and then try to rebuild it at last.
I know my question sounds complicated and I myself have no clue how to either mathematically or spatially explain what happens in details while computing FEM head model like this, but only thought maybe someone had any resources for this.

Thanks again.

@John_Mosher ?