Bug in bst_wmne

Hi,

I am facing some issues with the latest release of Brainstorm. I was trying to run the source modelling on my data set. I found that line # 424 of bst_wmne is throwing an error which was mainly due to the fact that the L matrix (the constrained Gain Matrix) has NaNs. The L matrix is assigned in line 346. Can you please take a look at it. My programs were working perfectly until this new update.

Regards,

Balu

Hi Balu,

There was no significant update of bst_wmne.m since December 2012.
If you have NaN values in the L matrix in bst_wmne, your problem is not coming from the inverse model, but from your forward model.

This L matrix is a copy of your headmodel.Gain matrix for the required sensors.
The number of rows of the Gain matrix is always the number of channels in the data. It gets filled with NaN for all the channels for which the head model is not calculated.

Something unusual happened between the calculation of the forward and the inverse models.
Please try recalculating the headmodel.

Cheers,
Francois

You are correct. Something unusual did happen while calculating the forward model. While I constructed the forward model, there are two dipole location whose values are assigned as NaNs. I am a bit confused on why something like this happened.

If you want me to look at it, you can zip your subject (File > Export subject) and send it to me (dropbox, FTP, …)
Send me the link in a separate email.

I am zipping the files right now. I did some debugging and found that the error is because the GridOrient values for these two dipoles are NaNs. Not sure why that is happening. I will email you the folder once the data compression is completed.

I think I figured it out. I reloaded the surfaces to the new version of Brainstorm and checked the Grid Orientation. Now it is free of NaNs.

Hi,

I think I may have the same kind of problem but I don’t know how to figure it out…
Since the last update of brainstorm I’m not able to compute sources anymore.
What changed from the last update is when I import anatomy from freesurfer folder. I now have cortex_15002V (and white_15002V) instead of cortex_15000V (and white_15000V) and the aseg atlas file.

I have the following error when I compute sources:

Error: Line 64: svd
** Input to SVD must not contain NaN or Inf.
**
** Call stack:
** >bst_xyz2lf.m at 64
** >bst_wmne.m at 351
** >bst_sourceimaging.m at 278
** >panel_inverse.m>ComputeInverse at 782
** >bst_call.m at 26
** >macro_methodcall.m at 37
** >panel_inverse.m at 26
** >panel_protocols.m>TreeInverse at 1086
** >bst_call.m at 28
** >macro_methodcall.m at 39
** >panel_protocols.m at 43
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@panel_protocols,‘TreeInverse’,bstNodes) at 1939

Thanks for ypour help,
Melanie

Hi,

Can you please check this link. May be this will solve your problem

http://neuroimage.usc.edu/forums/showthread.php?1208-Zeros-in-lead-field-matrix

When did you last update?

Hi Balu,

Thanks for your help.
I tried this solution :" fix the normals by right-clicking on the cortex surface you use for the source estimation > Remove interpolations" and re-did the forward and inserve problems, but I still get the same error.

I updated brainstorm few days ago : this is the version I use:
Version: 3.1.130730 (30-Jul-2013)

Melanie

Hi Melanie,

I am not an expert. But I might want to update the Brainstorm once again. I had similar issues as yours. Francois told me that there was a bug in surface resampling function. He had fixed it in the latest release of Brainstorm (Aug 1st I think). Once I updated Brainstorm it worked fine for me. Even I updated my brainstorm on Jul 30th and had faced similar problem as yours.

Balu

Hi Melanie,

Indeed, I changed lots of things in the last few days (I’m taking advantage of the summer to make the most annoying updates, that may lead to lots of new bugs).
Please update Brainstorm to today’s version, re-import the FreeSurfer folder (if you have the subject MRI, or right-click on the default anatomy > Use template > Colin27 if you’re using the default brain), and re-calculate the forward and inverse models.

Thanks for helping me debugging the new code!
Francois

Hi Francois and Balu,

Indeed the last update fixed the bug.
It even works if I only compute the head model again and then the sources, without reloading the anatomy (because doing that I guess I will have to redo the fiducials…)
I will apply this to all my subjects unless you think it’s still better to reload the anatomy…

Thanks a lot,
Melanie

No it’s fine, you don’t have to re-import the anatomy of all your subjects. There are some unwanted triangles in the cortex surfaces you have, but it doesn’t do any harm…
You can just fix the normals by right-clicking on the cortex > Remove interpolations (before re-computing the forwards model).

Great,

Thanks again,
melanie

Hi Francois,

I also get this error but only when i set the surface model to loose instead of constrained. Is there a way to fix it? I tried the suggestions below

[QUOTE=blackholebrain;8133]Hi Francois,

I also get this error but only when i set the surface model to loose instead of constrained. Is there a way to fix it? I tried the suggestions below[/QUOTE]

I tried to pinpoint the issue. Apparently the GridOrient matrices are set to zeros which is crashing bst_xyz2lf

Can you copy-paste the full error message here?
Please add a brief description of the other options you’ve been using (EEG/MEG, type of head model, other inverse options).

Thanks,
Francois


Its a mixed head model, constructed the way you detailed in a reply to a previous question i asked. Only difference is that in the source model the 2 hemispheres are set to surf|loose and the 2 hippocampi are set to vol|unconstrained. In the inverse option the source orientation options are not available for selection.

Thanks

Indeed, the case of “loose orientations” in a “mixed head model” was not handled correctly.
I fixed it. You can update Brainstorm and try again.
(you will have to recompute your head model)

Francois

Thanks! it worked.
One last thing, why can’t the loose value be changed (you can’t change the default 0.2)