Various CAT12 Errors with Different Versions of Matlab + Operating Systems

Hi all,

I had many attempts to make CAT12 work on either Windows10, Windows8 and Linux using matlab 2017/2018 and 2019 but each time I get an error and I am at a point I cannot understand what are the reasons behind anymore so I would really appreciate if I can get any help since I haven't managed to run CAT12 once. All uses the same and latest version of SPM12, CAT12 and Brainstorm.

  1. So Windows 10 - Using MATLAB 2018 and 2019 I get error saying

23-Aug-2019 10:36:20 - Running job #1

23-Aug-2019 10:36:20 - Running 'CAT12: Segmentation'
23-Aug-2019 10:36:21 - Failed 'CAT12: Segmentation'
Error using spm_vol>spm_vol_hdr (line 80)
File "C:\Users\bilgi.brainstorm\defaults\spm\TPM.nii" does not exist.
In file "C:\Users\bilgi\Desktop\Toolbox\source local\spm12\spm_vol.m" (v5958), function "spm_vol_hdr" at line 80.
In file "C:\Users\bilgi\Desktop\Toolbox\source local\spm12\spm_vol.m" (v5958), function "spm_vol" at line 61.
In file "C:\Users\bilgi\Desktop\Toolbox\source local\spm12\toolbox\cat12\cat_run.m" (v1439), function "update_job" at line 682.
In file "C:\Users\bilgi\Desktop\Toolbox\source local\spm12\toolbox\cat12\cat_run.m" (v1439), function "cat_run" at line 432.

The following modules did not run:
Failed: CAT12: Segmentation

So I cannot understand what might be the reason really.

  1. In Linux with Matlab 2017 it says

Print 'Graphics' figure to:
/home/users/tc025847/.brainstorm/tmp/cat12/report/catreport_spm_cat12.pdf
22-Aug-2019 23:27:16 - Failed 'CAT12: Segmentation'
Error using cat_io_FreeSurfer>read_curv (line 673)
Curvature file "/home/users/tc025847/.brainstorm/tmp/cat12/surf/lh.defects.spm_cat12" does not exist!

In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_io_FreeSurfer.m" (v1286), function "read_curv" at line 673.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_io_FreeSurfer.m" (v1286), function "cat_io_FreeSurfer" at line 95.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_surf_createCS.m" (v1435), function "cat_surf_createCS" at line 636.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_main.m" (v1446), function "cat_main" at line 663.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_run_job.m" (v1435), function "cat_run_job" at line 786.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_run_newcatch.m" (???), function "cat_run_newcatch" at line 15.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_run.m" (v1439), function "run_job" at line 720.
In file "/home/users/tc025847/Documents/spm12/toolbox/cat12/cat_run.m" (v1439), function "cat_run" at line 434.

The following modules did not run:
Failed: CAT12: Segmentation

Error using MATLABbatch system
Job execution failed. The full log of this run can be found in MATLAB command window, starting with the lines (look for the line showing the
exact #job as displayed in this error message)


  1. In Windows 8 with Matlab 2017a warning message at the very beginning, saying
    "Warning: A value of class "int32" was indexed with no subscripts specified. Currently, the result of this operation is the indexed value itself, but in a future release, it will be an error. "

and however whole procedure seems like running without a problem and it ends, but at the end, neither of produced files under temporary folder moves to subject-specific folder or I cannot find any surface files created eventually. I do not have a screenshot of it at the moment unfortunately but I am recreating the problem and then I will attach it in there too.
I would really appreciate if you could help me with any of those issues, so I can at least have a chance to run CAT12 once in either of these configurations...

Thank you very much in advance,

Isil

Linux_Matlab2017_error Windows10_Matlab2018_2019_Error

So I managed to get a screenshot of the error that is happening with Matlab 2017 on Windows 8 but from Matlab 2019 on Windows 8 , which is the same warning message but which still is running will end up with unfinished segmentation eventually. So I found 2 thread about this but neither of them leading to a solution at the moment, and one of the thread from Matlab forum says they will be dealing with in the future versions but apparently it is still the case.

Here are the discussions

https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=spm;14ca1013.1901

and
https://uk.mathworks.com/matlabcentral/answers/336738-warning-a-value-of-class-int32-was-indexed-with-no-subscripts-specified-in-stateflow
and I attach the warning that I got from both Matlab 2017 and Matlab 2019 in Windows 8 from unfinished segmentation (currently running but I know it will end with problem).

Sorry for bombarding with many confusing info but I do my best to provide as much as information since I need this tool desperately, and I know many people might be having the same issues eventually, so I hope those helps.

Isil

Windows8_Matlab2017%20and%202019_Error

  1. So Windows 10 - Using MATLAB 2018 and 2019 I get error saying:
    File "C:\Users\bilgi.brainstorm\defaults\spm\TPM.nii" does not exist.

I fixed the function that gets the location of the TPM.nii file. If it is not downloaded with the user folder (which is done when computing the MNI transform on any MRI in Brainstorm), it uses directly the one from the SPM12 distribution. Update Brainstorm to get this fix.
https://github.com/brainstorm-tools/brainstorm3/commit/ac668c15296965e1d5fb8f674aa451cc50aa7734

  1. In Linux with Matlab 2017 it says
    Print 'Graphics' figure to:
    /home/users/tc025847/.brainstorm/tmp/cat12/report/catreport_spm_cat12.pdf
    22-Aug-2019 23:27:16 - Failed 'CAT12: Segmentation'
    Error using cat_io_FreeSurfer>read_curv (line 673)
    Curvature file "/home/users/tc025847/.brainstorm/tmp/cat12/surf/lh.defects.spm_cat12" does not exist!

This, I don't know where it comes from...
@CGaser ?

  1. In Windows 8 with Matlab 2017a warning message at the very beginning, saying
    "Warning: A value of class "int32" was indexed with no subscripts specified. Currently, the result of this operation is the indexed value itself, but in a future release, it will be an error. "
    and however whole procedure seems like running without a problem and it ends, but at the end, neither of produced files under temporary folder moves to subject-specific folder or I cannot find any surface files created eventually.

This warning is just to tell us that Matlab's implementation will change in the future, but so far it still works without any changes. I reported this as issue on Guillaume's github repository, but it doesn't need to be fixed any time soon:
https://github.com/gllmflndn/gifti/issues/1

So the problem is coming from somewhere else.
Can you try finding other indices that would help us understand what the issue is?
Do you get any output in the temporary folder (in your home .brainstorm folder) while it runs?

Ok, I will update the brainstorm version and let you know.

The problem with that, the operation completes without a problem but the small window showing CAT12 operation gets stuck, hence Branstorm gets stuck as if the operation still continues. If you exit the small window, brainstorm still pretends like it is working, which you can tell since the cursor keeps running, however no segmentation files appear under the subject MRI data or anatomy folder in the brainstorm. And most importantly, those files that are created in temporary folder are not carried into the subject-specific folder at the end of the operation, hence if you mistakenly shutdown brainstorm, all those files are gone. This means even though the operation is completed without a problem, since the GUI doesn't pretend as if it finished, it fools you as if it gets stuck and then if you kill brainstorm without copying the files in the temporary folder manually to another location then you loose all the produced files in the temporary folder. So all the work gone for nothing just because of gui sort of misleads you.
This is at least how I am getting with Windows 8 in Matlab 2017, 2018 and 2019 versions when I get int32 error.

So it might worth to report this bit to SPM team as well, so at least they might know the consequence of having that warning message.

I will repeat the problem again, and get a screenshot and report back to this thread if that would help.

thank you

Isil Bilgin

The problem with that, the operation completes without a problem but the small window showing CAT12 operation gets stuck, hence Branstorm gets stuck as if the operation still continues. If you exit the small window, brainstorm still pretends like it is working, which you can tell since the cursor keeps running, however no segmentation files appear under the subject MRI data or anatomy folder in the brainstorm.

The window that shows the CAT logo is the wait bar of Brainstorm, sometimes it doesn't get closed correctly, either because the code crashes before, or because the code doesn't explicitly close it. It might remain open while nothing else happens.
In order to check if a task is still running in Matlab: in the Matlab command window press the ENTER key, if it shows "busy" in the bottom left corner of the Matlab window, something is still running. If it just goes to the next line and shows the prompt ">>" immediately, then nothing is being executed: you can safely close the Brainstorm wait bar, or press the "Close all figures" button (X) to also restore the mouse cursor.

I guess there is one of the following problem:

  1. CAT12 doesn't return correctly to the calling function (problem with the SPM job manager?)
  2. Brainstorm does something that keeps running for a while after CAT12 is done (importing the atlases into Brainstorm takes a while, and maybe the algorithm I wrote is not very stable and needs to fixes...)

I will repeat the problem again, and get a screenshot and report back to this thread if that would help.

Yes, please, it would help a lot to have the full text printed in the Matlab command window from the beginning of the execution of CAT12.
When you reach this moment where you think Brainstorm is stuck for no reason, instead of closing the wait bar with the CAT logo, press CTRL+C in the Matlab command window, possibly multiple times until it just prints the next prompt ">>". If you get any text after killing the current script: post it here as well

I recommend you also try with other MRI volumes. Maybe there are some a few subjects that won't work.

This is at least how I am getting with Windows 8 in Matlab 2017, 2018 and 2019 versions when I get int32 error.
So it might worth to report this bit to SPM team as well, so at least they might know the consequence of having that warning message.

This is not an error, it is a warning, and it has no impact on any computation.
The SPM developers are aware of it and already made the appropriate modifications. If it's not already part of the SPM12 you can download from their website, it will be updated soon.

Thanks for helping us debugging these new tools!

Hi Francois,

Ok, I will repeat it in my next trial and see how things work and report it back if there would be any different encounters. All I remember, there wasn't any process seems like going on at the Matlab command window, because I have seen the messages saying the segmentation has done, but I will check again.

Ok, this is how I was doing to stop the whole process and then copy the files and folders in tmp folder, I have reports from such an incident, so here you can download them if you would like and if that would help somehow but it doesn't elaborate so much info anyways.

As I mentioned the only harsh consequence of it, if you do not copy the produced files manually they are gone with the closure of the brainstorm, so even though the whole process runs without a problem, since the ending is not properly works, it makes you unconfident about the whole process hence there is a risk of losing the whole produced segmentation files. I hope I can repeat it again and get better screenshots since I didn't get it in my last run, I also started to think whether it is subject data related or not, so I will check it with the same and other participants again.

It is my pleasure, I would be happy if I can help a tiny bit :blush:

Bests,

Isil

Hi Francois,

I was also thinking would you mind adding a one or two sentence of what outputs/folder structure and files to expect at the end of a successful segmentation done with CAT12 to its tutorial page with quick descriptions about them please, so it would also give us an indication whether the whole process run successfully or not. I know it is listed to that which files will be going into BS while importing the segmentation folder, but I guess it would be another helpful info anyways, if you would have time to do so.

Thank you

Isil

I already listed all the files that are needed for importing the output to Brainstorm.
From the Brainstorm point of view, having these files available is the evidence of a successful segmentation.

Hi Francois,

I had the same error with all the logs and screenshots if you would like to have a look at.Here you can find the created output files with an error log txt file that contains the error listed in the Matlab command window and I attached the screenshots to the email as well. This is a completely new subject in Matlab 2017a, latest brainstorm and spm12 packages and in Windows8.

Also it says out of memory error but I have enough space in the both disk, where tmp folder is created and also where brainstorm runs, or database is. Is it something the capacity of the brainstorm somehow, since I remember if I keep many subject open then brainstorm was struggling to even open, so I had to close some protocols to make it work faster. (Yeah I create one protocol per participant, since I do not use other groupwise analysis in brainstorm, hence it gives me the flexibility to close the protocol hence free brainstorm, at least this is how I find it useful so far.)

So files are still in tmp even though matlab says segmentation is done.

I hope it has an easy solve. Let me know if I can provide more information.

Thank you

Isil

error_2 error_3 error_1

The "Java heap space" can be fixed by simply increasing the memory allocated to the Java heap space in the Matlab preferences:
https://neuroimage.usc.edu/brainstorm/Tutorials/KnownBugs?highlight=(heap+space)

Splitting the subjects in different protocols should not make Brainstorm work faster, unless you hundreds of subjects and/or not enough Java heap space allocated.

Thank you Francois, it helps a lot.

Isil

Hi @Francois
I can't install cat12 with Win10, MatlabR2018b and bst 12/04/2021. Error message:
image
Would you know why, please?

Bad news for my new plugin manager: I didn't expect Windows10 would have different access rights for creating files and for creating symbolic links...

Are you not an admin on your computer?
Start Matlab as an administrator (right-click on the Matlab icon > Run as administrator) and please let me know if it solves the issue.

It works with Matlab as administrator but but once installed (in the administrator directory), how can I use it as an ordinary user?

how can I use it as an ordinary user

You probably don't need to install Matlab as an administrator, just run it as an administrator.

Otherwise, google for help on creating symbolic links, and how to grant your user the rights to create links in its home folder.
The command you need to have the right to execute from a windows shell is:
mklink /D "C:\Users\username\.brainstorm\plugins\spm12\spm12\toolbox\cat12" "C:\Users\franc\.brainstorm\plugins\cat12\cat12"

Once the CAT is installed and the symbolic link is created, you can use your regular user with no extra rights to run CAT. So maybe running Matlab/Brainstorm only once as an admin to install/update SPM/CAT would be sufficient.

It worked and, now after Brains'torm update, the issue comes back :slight_smile:image

Blockquote
SPM12 template found: C:\Users\kristene.brainstorm\defaults\spm\TPM.nii
BST> Processing dependencies: cat12 requires: spm12
BST> Plugin cat12 already loaded: C:\Users\kristene.brainstorm\plugins\cat12


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


Every time you update CAT, you'll need to repeat the same procedure...