CAT Segmentation issue (Unrecognized function or variable 'sMri')

Hello Francois

I have cat12-spm12 installed with all updated versions (2000 and 7771 respectively). However, when I run CAT12 for MRI segmentation I get (for the first time) the following error:

Can anyone help?

Merci !

Rodrigo
macOS Monterey 12.4
Matlab R20221b Update 3 (February 3,2022)
BST version 29-jun-2022


** Error: Line 267: Unrecognized function or variable 'sMri'.
**
** Call stack:
** >import_anatomy_cat_2020.m at 267
** >import_anatomy_cat.m at 28
** >process_segment_cat12.m>Compute at 382
** >process_segment_cat12.m>ComputeInteractive at 442
** >process_segment_cat12.m at 28
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_segment_cat12,'ComputeInteractive',iSubject,iAnatomy) at 3023


Hu,
it seems that there is not an MRI in the subject that you want to segment.
Could you share the steps that you did to get this error?

Hello Rodrigo, Takfarinas, and Francois;
I just bumped into the same error”


** Error: Line 267: Unrecognized function or variable 'sMri'.
**
** Call stack:
** >import_anatomy_cat_2020.m at 267
** >import_anatomy_cat.m at 28
** >process_segment_cat12.m>Compute at 382
** >process_segment_cat12.m>ComputeInteractive at 442
** >process_segment_cat12.m at 28
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_segment_cat12,'ComputeInteractive',iSubject,iAnatomy) at 3027
**


On the brainstorm GUI I do see under my “subject” the MRI image (I can right-click —> display —> MRI viewer properly and it overlays; also the ASEG, Desikan, and Destrieux surfaces display well.

My “subject” is configured as “using individual anatomy”.

I’M copying below all the processes that succesfully ran, as - like Rodrigo mentioned - Cat ran for about 25 mins undisturbed..

Disclaimer: this is my first time I am using CAT and I am

  • import anatomy folder (auto)
  • loading a folder with the same structure as the one from freesurfer… (issue here?)
  • I am then prompted to accept the deletion of current surfaces / files in the structure (issue solved?)

30-Jun-2022 18:06:20 - Running job #1
------------------------------------------------------------------------
30-Jun-2022 18:06:20 - Running 'CAT12: Segmentation'

------------------------------------------------------------------------
CAT12.8.1 r2000: 1/1:   ./alfredospagna/.brainstorm/tmp/cat12/test_cat.n
------------------------------------------------------------------------
SANLM denoising (medium):                                         Your version of CAT12 is up-to-date.
   18s
APP: Rough bias correction:                                       
  Initialize                                                          4s
  Estimate background                                                 3s
  Initial correction                                                  5s
  Refine background                                                   3s
  Final correction                                                    4s
  Final scaling                                                       5s
                                                                     29s
Correct center-of-mass                                                8s
Affine registration                                               
    ------------------------------------------------------------------------
     WARNING 01:  cat_run_job1639:noSPMTPM-noBGmasking
                  Different TPM detected - deactivated background masking!
    ------------------------------------------------------------------------
                                                                      8s
SPM preprocessing 1 (estimate 1 - TPM registration):                 43s
SPM preprocessing 1 (estimate 2):                                   153s
SPM preprocessing 2 (write):                                      
  Write Segmentation                                                 15s
  Update Segmentation                                                10s
  Update Skull-Stripping                                             22s
  Update probability maps                                             5s
                                                                     52s
Global intensity correction:                                         11s
SANLM denoising after intensity normalization (medium):               7s
Fast Optimized Shooting registration                                 28s
Local adaptive segmentation (LASstr=0.50):                        
  Prepare maps                                                        2s
  Prepare partitions                                                  2s
  Prepare segments (LASmod = 1.05)                                    6s
  Estimate local tissue thresholds (WM)                              13s
  Estimate local tissue thresholds (GM)                              18s
  Intensity transformation                                            0s
  SANLM denoising after LAS (medium)                                 27s
                                                                     70s
ROI segmentation (partitioning):                                  
  Atlas -> subject space                                              5s
  Major structures                                                    2s
  Ventricle detection                                                 7s
  Blood vessel detection                                              5s
  WMH detection (WMHCstr=0.50 > WMHCstr'=0.00)                       10s
  Manual stroke lesion detection                                      0s
  Closing of deep structures                                          1s
  Side alignment                                                      2s
  Final corrections                                                   2s
                                                                     33s
Blood vessel correction (BVCstr=0.50):                                1s
Amap using initial SPM12 segmentations (MRF filter strength 0.06):   16s
    AMAP peaks: [CSF,GM,WM] = [0.36±0.05,0.68±0.08,0.99±0.04]
Final cleanup (gcutstr=0.25):                                     
  Level 1 cleanup (ROI estimation)                                    2s
  Level 1 cleanup (brain masking)                                     1s
  Level 2 cleanup (CSF correction)                                    1s
  Level 3 cleanup (CSF/WM PVE)                                        1s
                                                                      5s
Optimized Shooting registration with 2.50:-0.25:1.50 mm (regstr=0.50):
  Template: "/Users/alfredospagna/.brainstorm/plugins/spm12/spm12/toolbox/cat12/templates_MNI152NLin2009cAsym/Template_0_GS.nii"
    1 | 2.50 | 0.0834  0.0000  0.0834 |  32.0000 
    2 | 2.50 | 0.0806  0.0012  0.0818 |  29.4886 
    3 | 2.50 | 0.0798  0.0018  0.0817 |  26.9772 
    4 | 2.50 | 0.0794  0.0021  0.0815 |  24.6107 
    5 | 2.50 | 0.0791  0.0022  0.0813 |  22.6548 
    6 | 2.50 | 0.0788  0.0023  0.0811 |  20.6989 
    7 | 2.50 | 0.0785  0.0024  0.0809 |  18.9688 
    8 | 2.50 | 0.0782  0.0025  0.0807 |  17.4455 
    9 | 2.50 | 0.0779  0.0025  0.0805 |  15.9223 
   10 | 2.50 | 0.0776  0.0026  0.0803 |  14.6627 
   11 | 2.50 | 0.0773  0.0027  0.0800 |  13.4764 
   12 | 2.50 | 0.0770  0.0028  0.0797 |  12.3015 
   13 | 2.50 | 0.0766  0.0029  0.0795 |  11.3776 
   14 | 2.50 | 0.0763  0.0029  0.0792 |  10.4537 
   15 | 2.25 | 0.0755  0.0030  0.0785 |   9.5920 
   16 | 2.25 | 0.0724  0.0045  0.0769 |   8.8725 
   29 | 2.00 | 0.0736  0.0020  0.0757 |   3.3283 
   30 | 2.00 | 0.0676  0.0045  0.0721 |   3.1221 
   31 | 2.00 | 0.0656  0.0055  0.0710 |   2.9160 
   43 | 1.75 | 0.0647  0.0031  0.0679 |   1.5785 
   44 | 1.75 | 0.0604  0.0054  0.0658 |   1.5194 
   45 | 1.75 | 0.0591  0.0062  0.0652 |   1.4626 
   57 | 1.50 | 0.0577  0.0045  0.0622 |   1.0900 
   58 | 1.50 | 0.0546  0.0065  0.0611 |   1.0730 
   59 | 1.50 | 0.0536  0.0071  0.0607 |   1.0579 
Shooting registration with 2.50:-0.25:1.50 mm takes:                106s
  Prepare output                                                      8s
                                                                    113s
  Jacobian determinant (RMS): 0.012 0.041 0.062 0.089 0.115 |  0.122110 
           Template Matching: 0.083 0.217 0.197 0.177 0.161 |  0.160838 
Write result maps:                                                   20s
Surface and thickness estimation:                                 
lh:
  Thickness estimation (0.50 mmÂł):                                
    WM distance:                                                     22s
    CSF distance:                                                    12s
    PBT2x thickness:                                                 30s
                                                                     68s
  Create initial surface                                             48s
  Topology correction:                                               69s
  Surface refinement:                                                66s
  Reduction of surface collisions with optimization:                 52s
  Spherical mapping with areal smoothing                             60s
  Spherical registration                                            194s
rh:
  Thickness estimation (0.50 mmÂł):                                
    WM distance:                                                     26s
    CSF distance:                                                    11s
    PBT2x thickness:                                                 30s
                                                                     71s
  Create initial surface                                             48s
  Topology correction:                                               70s
  Surface refinement:                                                90s
  Reduction of surface collisions with optimization:                 54s
  Spherical mapping with areal smoothing                             62s
  Spherical registration                                            192s
Final surface processing results: 
  Average thickness (FS):                     2.7369 ± 0.6036 mm
  Surface intensity / position RMSE:          0.0686 / 0.0643
  Euler number / defect number / defect size: 6.0 / 5.0 / 0.08% 
  Display thickness:          /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.thickness.test_cat
  Display thickness:          /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.thickness.test_cat
  Show surfaces in orthview:  /Users/alfredospagna/.brainstorm/tmp/cat12/test_cat.nii
  Surface ROI estimation:                                             8s
Surface and thickness estimation takes:                            1230s
ROI estimation in native space:                                   
  ROI estimation of 'cobra' atlas                                     5s
  ROI estimation of 'neuromorphometrics' atlas                       18s
  ROI estimation of 'lpba40' atlas                                    6s
  ROI estimation of 'hammers' atlas                                  13s
  ROI estimation of 'thalamus' atlas                                  1s
  ROI estimation of 'ibsr' atlas                                      5s
  ROI estimation of 'aal3' atlas                                      8s
  ROI estimation of 'mori' atlas                                     10s
  ROI estimation of 'anatomy3' atlas                                 15s
  ROI estimation of 'julichbrain' atlas                              19s
  ROI estimation of 'Schaefer2018_100Parcels_17Networks_order' atlas    8s
  ROI estimation of 'Schaefer2018_200Parcels_17Networks_order' atlas   15s
  ROI estimation of 'Schaefer2018_400Parcels_17Networks_order' atlas   37s
  ROI estimation of 'Schaefer2018_600Parcels_17Networks_order' atlas   46s
  Write results                                                      50s
                                                                    212s
Quality check:                                                        9s
Print 'Graphics' figure to: 
  /Users/alfredospagna/.brainstorm/tmp/cat12/report/catreport_test_cat.pdf

------------------------------------------------------------------------
CAT preprocessing takes 35 minute(s) and 16 second(s).
Image Quality Rating (IQR):  86.62% (B)
GM volume (GMV):             52.48% (790.62 / 1506.54 ml)
GM thickness (GMT):           2.74 ± 0.60 mm
Segmentations are saved in /Users/alfredospagna/.brainstorm/tmp/cat12/mri
Reports are saved in /Users/alfredospagna/.brainstorm/tmp/cat12/report
Labels are saved in /Users/alfredospagna/.brainstorm/tmp/cat12/label
------------------------------------------------------------------------

30-Jun-2022 18:41:39 - Done    'CAT12: Segmentation'
30-Jun-2022 18:41:39 - Running 'Extract additional surface parameters'

     1/1) Extract parameters for /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.central.test_cat.gii
             1s - Display /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.gyrification.test_cat
             4s - Display /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.depth.test_cat
             1s - Display /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.gyrification.test_cat
             4s - Display /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.depth.test_cat
30-Jun-2022 18:41:50 - Done    'Extract additional surface parameters'
30-Jun-2022 18:41:50 - Done

Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.Schaefer2018_100Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.Schaefer2018_100Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.Schaefer2018_200Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.Schaefer2018_200Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.Schaefer2018_400Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.Schaefer2018_400Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.Schaefer2018_600Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.Schaefer2018_600Parcels_17Networks_order.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.aparc_DK40.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.aparc_DK40.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.aparc_HCP_MMP1.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.aparc_HCP_MMP1.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/lh.aparc_a2009s.test_cat.annot
Save /Users/alfredospagna/.brainstorm/tmp/cat12/surf/rh.aparc_a2009s.test_cat.annot

***************************************************************************
** Error: Line 267: Unrecognized function or variable 'sMri'.
** 
** Call stack:
** >import_anatomy_cat_2020.m at 267
** >import_anatomy_cat.m at 28
** >process_segment_cat12.m>Compute at 382
** >process_segment_cat12.m>ComputeInteractive at 442
** >process_segment_cat12.m at 28
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_segment_cat12,'ComputeInteractive',iSubject,iAnatomy) at 3027
** 
***************************************************************************

I have the previous version of Brainstorm and it was working.

I will update my bst and check with the latest version.

@Francois @Raymundo.Cassani any recent changes on this side?

1 Like

That would be lovely; I really don’t get what might be going wrong.. I’m feeding a T1.mgz image and using the import MRI function.. that’s literally the only file being processed and I get the same error also with other T1s from other subjects..

it seems to be related to the recent update (Import BIDS: Add support for AnatomicalLandmarks and Fiducials · brainstorm-tools/brainstorm3@e7a2882 · GitHub) and especially the removal of l316: sMri = in_mri_bst(BstT1File);

In the condition here (brainstorm3/toolbox/io/import_anatomy_cat_2020.m at master · brainstorm-tools/brainstorm3 · GitHub); sMRI might not be defined before being used here: brainstorm3/toolbox/io/import_anatomy_cat_2020.m at master · brainstorm-tools/brainstorm3 · GitHub

I guess replacing

if isKeepMri && ~isempty(sSubject.Anatomy)
BstT1File = file_fullpath(sSubject.Anatomy(sSubject.iAnatomy).FileName);
else
...

by

if isKeepMri && ~isempty(sSubject.Anatomy)
BstT1File = file_fullpath(sSubject.Anatomy(sSubject.iAnatomy).FileName);
sMri = in_mri_bst(BstT1File);
else
should correct the bug :slight_smile:

Regards,
Edouard

2 Likes

Thanks, Edouard;

I went on my local copy of
brainstorm3/import_anatomy_cat_2020.m at master

and added
sMri = in_mri_bst(BstT1File);

It worked well and ran smoothly the full hour.
I can see the atlases loading in the scouts now;

Alfredo

1 Like

Oooops.... I apologize for this new bug... I didn't test everything after this massive update of the fiducials management for automated BIDS import.

Thank you all for debugging the code that fast!
I added a few more fixes here: Bugfix: Computation of CAT12 segmentation after fiducial management u… · brainstorm-tools/brainstorm3@d1970f9 · GitHub

I'll keep testing the anatomy segmentation and import for detecting other possible bugs due to the same changes.

2 Likes

Spotted! :slight_smile:

Thanks to all of you !!! :wink: :mechanical_arm:

2 Likes