CAT12 Segmentation - Unrecognized function or variable 'ST'

Dear BST community,

When using the default ICBM152 anatomy, I typically run the CAT12 segmentation on it to get the Schafer atlases. I've done this for a while now, with no issues.

However, I am running into the following error I've never come across before.

Screen Shot 2021-11-05 at 8.22.27 AM

Apologizes in advance if this is a CAT12 issue and not a BST one.

Any assistance with this would be greatly appreciated.

Thank you,

Indeed, in the latest version of CAT (r1904), the function cat_surf_map_atlas.m makes a reference to a variable ST that is not used before, at line 62.

Could you please look into this?

While this gets fixed, you can probably download and use an older version of CAT:

  • Go to:
  • Download a previous version (eg.
  • Unzip it and make sure that the function cat_surf_map_atlas.m does not include the same error
  • Replace the contents of the folder $HOME/.brainstorm/plugins/cat12/cat12 with the contents of the cat12 folder you've just downloaded
  • Do not delete the folder $HOME/.brainstorm/plugins/cat12, as a symbolic link redirects $HOME/.brainstorm/plugins/spm12/spm12/toolbox/cat12 to it. If you the folder, you'd need to recreate the link manually
  • Try again running the segmentation
1 Like

Hi Francois,

I am still running into similar errors, although I don't know if I was able to properly follow the replacement of the CAT12 contents.

I tried custom install through the plug in manager, but got that the version of CAT12 I downloaded was not able to be recognized. Could I do the install through the plug in manager?

1 Like

I did exactly as you suggested, but reported this error:

** Error: Line 60: Output argument "varargout{2}" (and maybe others) not assigned during call to "cat_system".


** Call stack:

** >cat_surf_map_atlas.m at 60

** >process_segment_cat12.m>Compute at 382

** >process_segment_cat12.m>ComputeInteractive at 445

** >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 3005


Do you have any suggestions?
Thank you very much for your help!

I also tried to install the old version of cat on my own, but in the process of running it brainstorm reported that it was not working properly and needed to be reinstalled

BST> =================================

SPM12 template found: /home/jade/.brainstorm/defaults/spm/TPM.nii
BST> Checking latest online version for cat12...
BST> Processing dependencies: cat12 requires: spm12
BST> Plugin cat12 already loaded: /home/jade/app/brainstorm3/cat12

** Error: SPM must be in the Matlab path to use this feature.

BST> Adding plugin spm12 to path: /home/jade/.brainstorm/plugins/spm12/spm12
BST> Executing callback LoadedFcn: spm('defaults','EEG');
SPM12 template found: /home/jade/.brainstorm/defaults/spm/TPM.nii
BST> Processing dependencies: cat12 requires: spm12
BST> Plugin cat12 already loaded: /home/jade/app/brainstorm3/cat12

** Error: Cannot identify CAT12 version: please re-install it.

I guess I shouldn't have sent you on the tracks of trying to install manually an older version of CAT without testing this myself first... Let me try to provide an easier fix for this issue, until it gets fixed in CAT.

  • From Brainstorm: Menu Plugins > spm12 > Uninstall (it will uninstall CAT as well)
  • Edit the Matlab path: Remove from the path all the SPM-related folders
  • Delete all your previous manual installations of SPM and CAT from your computer, in order to avoid any confusion.
  • From Brainstorm: Menu Plugins > Anatomy > cat12 > Install (it will install SPM as well)
  • The following instructions consider that Brainstorm installed CAT12 version 1904
  • In the Matab command window, type edit cat_surf_map_atlas (you need the CAT plugin to be loaded for this function to be available in the path)
  • In the editor, comment out the lines 62 and 68 by adding a % at the beginning of the line (comment only the if/end lines, and keep the entire block in between, as we want the new parcellations to be saved)

Thank you Francois! All seems to be working now.

@CGaser just pushed a fix to this problem.
You can now update to CAT12 version 1906 and it should fix the problem.