sLORETA with Deep Brain Atlas DBA error

Hi everybody,

I am trying to do EEG deep brain source reconstruction with sLORETA. Tutorial DBA uses the Minimum Norm Imaging. When I try to replicate Tutorial DBA with sLORETA (at the compute sources step) instead of Minimum Norm Imaging, this produces an error.
Error in bst_inverse_linear_2018.m, Line 926, Index exceeds matrix dimensions

What’s going on here? Is it possible to use sLORETA for deep brain localization?

On an unrelated note, with constrained orientation of dipoles, do positive relative values indicate a dipole pointing from inside to outside the brain?

1 Like

I am trying to do EEG deep brain source reconstruction with sLORETA. Tutorial DBA uses the Minimum Norm Imaging. When I try to replicate Tutorial DBA with sLORETA (at the compute sources step) instead of Minimum Norm Imaging, this produces an error.
Error in bst_inverse_linear_2018.m, Line 926, Index exceeds matrix dimensions
What’s going on here? Is it possible to use sLORETA for deep brain localization?

This is a question for @John_Mosher.

On an unrelated note, with constrained orientation of dipoles, do positive relative values indicate a dipole pointing from inside to outside the brain?

Correct. Positive means pointing in the same direction as the normal vector estimated for the corresponding vertex of the cortex surface. And these normals should always be pointing towards the outside.

I am having the same problem. This is the error I get:

Index exceeds matrix
dimensions.

Error in
bst_inverse_linear_2018 (line
926)
sloretadiag
=
sqrt(sum(Kernel(Ndx,: )
.*
L(:,Ndx)’,
2));

Error in
process_inverse_2018>Compute
(line 638)
[Results,
OPTIONS] =
bst_inverse_linear_2018(HeadModel,
OPTIONS);

Error in process_inverse_2018
(line 24)
eval(macro_method);

Error in
panel_protocols>TreeInverse
(line 1224)
[OutputFiles,
errMessage] =
process_inverse_2018(‘Compute’,
iStudies, iDatas);

Error in panel_protocols (line
44)
eval(macro_method);

Error in
tree_callbacks>@(h,ev)panel_protocols(‘TreeInverse’,bstNodes,‘2018’)
(line 2308)
gui_component(‘MenuItem’,
jPopup, [], ‘Compute
sources [2018]’,
IconLoader.ICON_RESULTS,
[],
@(h,ev)panel_protocols(‘TreeInverse’,
bstNodes, ‘2018’));

I wonder if sLORETA is supported in DBA. Thanks!

I got the same problem and I believe I've found a solution.

The problem is in a single line of code, line 927 of bst_inverse_linear_2018. My version has the line:

Kernel = bst_bsxfun(@rdivide, Kernel(Ndx,:), sloretadiag);

The problem is that when Kernel is initialized, it spans multiple head models. This line erases all but the first headmodel the first time it is executed. If you replace it with the following line, it seems to work correctly:

Kernel(Ndx,:) = bst_bsxfun(@rdivide, Kernel(Ndx,:), sloretadiag);

@John_Mosher @Sylvain @marc.lalancette?

Hi everybody,

I have this same problem. Modification suggested by geoffmay in the line 927 of bst_inverse_linear_2018 was not working for me. I would be very grateful if someone finds a solution.

Sorry folks: it looks like there is a bug in how mixed models (cortex and deep structures) are handled by sLORETA in Brainstorm: we will look into this.
In the meantime, I can encourage sLORETA users to use only cortically constrained models: the the envelopes of deep medial structures are (partially) approximated with the cortical surfaces typically available from FreeSurfer and other brain segmentation tools. For subcortical nuclei, a full volumic source model is the next best approximation while we are working on fixing the bug.

I agree with Geoff May's correction. We are testing now to see if we encounter the error of mattiher. We have also updated the tutorial on sLORETA to clarify that it uses the theoretical data covariance, not the estimated. So we will be rolling up in one update shortly the questions of data covariance, a close review of the sLORETA "resolution" calculation, and this "mixed model" sLORETA bug. Stay tuned.

1 Like

Following previous comments, @jjeg correctly pointed out a bug. @geoffmay proposed solution works perfectly.

Bug fixed: https://github.com/brainstorm-tools/brainstorm3/pull/195
Brainstorm will be updated shortly (hopefully).

1 Like

Hi @mattiher,

Could you please describe what behavior are you experiencing? Does Matlab throw an error like the one described by @romboide2004 and @jjeg?

@juangpc Your modification is online: https://github.com/brainstorm-tools/brainstorm3/commit/76f88f98fad901dc9a0477d59d4c7b19c2da2bab

@jjeg @geoffmay Update Brainstorm to get this fix.

Hi,

So here I have three different BEM models, surface, volume and mixed. Mixed is chosen.
image
I right click above the average file marked with blue and I select the Compute Sources 2018. These are the parameters I have used:


This is what I get:

Then I correct the bst_inverse_linear_2018.m

I restart the Brainstorm (version 15-Jun-2018) and I select again the Compute Sources 2018 as above and get the error:

The sLoreta: EEG (Constr) 2018 sources can be calculated without errors.
I don't know if this has anything to do with the problem, but I have changed the structures used in the mixed model. First time I had Thalamus+Amygdala+Brainstem and now I have Thalamus+Amygdala+Hippocampus+Brainstem+Putamen. I have of course deleted and recalculated BEM model between these modifications. I also tested this with newer version of Brainstorm (01-Apr-2019) with different computer and there was the same problem.

Hi @mattiher,

Sorry for the inconvenience. I tested thoroughly the solution before requesting a pull from BST's main repository. But in any case differences between your setup and mine could cause the problem. Please consider the following:

  • Export your protocol to a safe location. It is not a bad idea to make a copy of your BSTdb folder directly.
  • Make sure again that your back up is safe and everything has been copied correctly.
  • (optional) Make a copy of the version of BST you're using.
  • Download BST today or any version later than yesterday (4.24.19) at 4:29pm.
    The modifications were merged yesterday at 4:29pm. So if you tried in a different computer with an earlier version of Brainstorm clearly the patch was not there.
  • With an updated version of BST, try to follow the DBA tutorial. https://neuroimage.usc.edu/brainstorm/Tutorials/DeepAtlas
  • Once you've followed the tutorial, try to compute sources with sLORETA.

Hope it works for you as it worked for me during the several tests I did to help you out.

Your error states that the problem is line 926, but I think the problematic line should be 927 if your are running the program you took a screenshot of. So perhaps you are not running the new fixed function. Check your Matlab path.
Either way you should add a line with just "keyboard" before line 927 or 926 ..
and then just run a "whos" to check all the dimensions of the index vector "Ndx" and the variables used to make "Ndx" in lines "921-923", especially 922, and check that the "Kernel" matrix size also makes sense. I guess "NumDipoleComponents(kk)" should be 1 for every chunk of source space with fixed orientation dipoles (i.e., a surface with dipoles fixed to normals) and should be 3 (or 2 if using spherical head model) for volumetric source space chunks. Also check that the corresponding "NumDipoles(kk)"'s make sense. Hope you get it working. Best, Rey

Hi @rey, @juangpc

First of all, thank you for helping me out with this issue.
You were right. So when I send the error log I was still using the old version. I missed the Francois update message. Sorry for that.
I'm running the software without Matlab using the MCR. I deleted the old brainstorm3 folder and downloaded and unzipped brainstorm_190425.zip on 26 of April at 8:36 (GMT+3). So I think I should now have the newest version. When I start the Brainstorm I see that the version is 10-Apr-2019, but I think this is ok.
I did what juanpc was asking me to do. I followed the DBA tutorial and everything went ok. However when I tried to compute sources using sLORETA for Subject074 for condition YO I got the error. dSPM was working fine.
image
Here is the error message:


@juangpc Could you try to compute sLORETA for this same Subject074 for condition YO? Please let me know if you can.
I get the same error message if I use my own data. Perhaps this means that the problem is not in my dataset but rather in my software setup somehow.
Unfortunately I'm out of office until 8 of May, so I'm not able to check yet what rey was suggesting. I'll return to this later.

Hi @mattiher, no problem at all, happy to help.

Just to be completely sure, I've gone through the tutorial again and I've been able to compute sources just fine, including dSPM.
image

I understand you're running the compiled version of brainstorm. That is, I think why you're not executing the last modification. I'm sorry but I don't know how long it takes for each development version to be included in a compiled roll out. I can do two things.

  • Maybe @Francois can say when the modifications will be included in the compiled version?
  • Modify bst_inverse_linear_2018 so that it is more clear which version is running. I'll pull-request asap.

Thansk

Actually, I was yesterday thinking...

Why would someone change the background of matlab's command window to black??? :sweat_smile::sweat_smile:
Now I understand. Sorry about that. Should've figured it out.

Juan

Sorry about that, I didn't realize you were working with the MCR version either.
I recompiled the version that is currently online.
Delete your existing brainstorm3 folder, download a new version of Brainstorm from the website and see if it works better (it should be the version from April 26th)

Francois

Thank you! I tested sLORETA and it is working fine.