Error when computing any volume head model

Since updating Brainstorm to start segmenting with CAT12, I have had many head model/source issues like a lot of people here. I fixed them all, yet am I am stuck with one last error I can't figure out.

I have about 30 (MEG, most have EEG and MRI as well) participants, and 4 of them have data that throw an error when I try to compute any volume head model.

NOTE: I use a volume head model to do group analysis, so I compute with the following options:

  • MRI Volume
  • MRI volume grid: Use template grid for group analysis
  • MEG method: OpenMEEG (or Overlapping Spheres)

Unfortunately, when I go to compute head model, as it is doing the "creating grid step" I get the error:

Error using vertcat
Dimensions of arrays being concatenated are not consistent.

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

Error in tree_callbacks>@(h,ev)panel_protocols('TreeHeadModel',bstNodes) (line 2546)
gui_component('MenuItem', jPopup, , 'Compute head model', IconLoader.ICON_HEADMODEL, , @(h,ev)panel_protocols('TreeHeadModel', bstNodes));

Notes:

  • I never had a problem before using CAT12
  • It computes if I do not use a template grid for group analysis
  • It works now if I do not use CAT12 segmented MRIs

I have tried the following:

  1. Using another pt's MRI = it then works
  2. Using the default anatomy = it works
  3. Computing a cortex surface head model = it works
  4. Trying overlapping spheres instead of OpenMEEG = still does not work
  5. Increasing BEM surface vertices = still does not work (I increased before for another error)
  6. Fixing coregistration, etc. = still does not work (the coregistration looks fine for these 4 pts, not particularly worse, besides it seems to be an MRI problem)
  7. Importing as MRI as NIFTI and as DICOM = both dont work

Interestingly, if I recompute a source grid before computing the head model, it gets farther in the processing. It will get to the point to ask which Volume source grid to pick, but when I select "Use template grid for group analysis", I get the following error:

Error using vertcat
Dimensions of arrays being concatenated are not consistent.

Error in cs_convert (line 128)
P = world2mri * [double(P_world); 1];

Error in panel_sourcegrid>GetGrid (line 546)
grid = cs_convert(sMriSubject, 'mni', 'scs', gridMni);

Error in panel_sourcegrid>CreatePanel/UpdatePanel (line 341)
[gGridLoc, ctrl.sEnvelope] = GetGrid(GridOptions, ctrl.CortexFile, ctrl.sCortex, ctrl.sEnvelope, ctrl.sInner);

Error in panel_sourcegrid>@(h,ev)UpdatePanel (line 177)
jRadioGroup = gui_component('radio', jPanelOpt, 'br', 'Use template grid for group analysis', jButtonGroup, , @(h,ev)UpdatePanel, );

I am not an MRI expert (or an expert on any of this), but when I look at the contents of the MRI files in Brainstorm there seem to be a few differences between these 4 and the rest of my pts:

  • Under the -NCS section the 4 pts have extra rows of information
    For example, one pt with a head model that computes, their NCS section has:

|- NCS:
| |- AC: [124.6854, 135.0262, 79.2923]
| |- PC: [123.291, 107.1347, 76.6404]
| |- IH: [121.864, 109.6221, 134.5177]
| |- R: [0.99658, -0.052372, 0.026822; -0.03169, 0.98493, 0.21606; -0.0096685, -0.17376, 1.0785]
| |- T: [-119.3143; -143.172; -64.8459]
| |- Origin: [124.4055, 131.2902, 82.3968]

While a pt that does not compute, their NCS section is:

|- NCS:
| |- AC: [124.6131, 138.8169, 90.2311]
| |- PC: [124.88, 112.0445, 87.8455]
| |- IH: [125.6478, 120.895, 136.2044]
| |- R: [1.1066, 0.0078014, -0.0090509; -0.013847, 1.0253, 0.14174; 0.0065131, -0.15365, 1.2568]
| |- T: [-138.8823; -151.013; -92.1705]
| |- iy: [256x256x176x3 single]
| |- y: [121x145x121x3 single]
| |- y_vox2ras: [4x4 double]
| |- y_method: 'segment'
| |- Origin: [124.6849, 135.4967, 92.9811]

Additionally, I noticed that in the -Histogram section, there are some differences. The pts that successfully computed have all doubles that match in dimensions, while those that didnt compute dont.

For example, the one that computed Histogram section:

|- Histogram:
| |- fncY: [1x585 double]
| |- fncX: [1x585 double]
| |- intensityMax: 584
| |- cumulFncY: [1x585 double]
| |- smoothFncX: [1x585 double]
| |- smoothFncY: [1x585 double]
| |- max: [1x3 struct]

And the pt that head model did not compute:

|- Histogram:
| |- fncY: [1x256 double]
| |- fncX: [1x256 double]
| |- intensityMax: 1852
| |- cumulFncY: [1x256 double]
| |- smoothFncX: [1x201 double]
| |- smoothFncY: [1x201 double]
| |- max: [1x4 struct]

See how the fncY, fncX, and cumulFncY are different dimensions than smoothFncX and smoothFncY?

Lastly, I have attached data (MRI and one MEG run) for a pt that wont compute, "pt_w_error" and a pt that will compute the head model, "pt_wo_error." I am including DICOM and NIFTI files, raw MEG data, and a zipped folder of the brainstorm subject with clean MEG data and imported events:

https://drive.google.com/drive/folders/10TtV0-Of6T_mTdEBs54TPgOpHfrnO0d4?usp=sharing

I apologize for the lengthy post. I wanted to be as detailed as possible as I have been trying to fix this problem for a month now.

Thank you in advance for any and all help you can give and I thank you for making it this far!

  • Kathryn King, M.S.
    (Neurosciences Research Center, Cook Children's Medical Center, Fort Worth, TX)

Thank you for this very exhaustive bug report.

The problem was actually coming from function cs_convert, when projecting the template grid in MNI space to the subject space. When using a non-linear MNI normalization such as the one provided by CAT12, the function was crashing with more than one point in input...

I fixed this bug. Please update Brainstorm and try again.

I was so excited that I forgot to reply and say thank you!

Thank you so much!! For this and everything you do!!