I’m currently working on a project where I need to import an MRI file (.nii / .nii.gz), segment it with CAT12, and then import the segmented data back into Brainstorm.
I’m calling Brainstorm functions from Python using the MATLAB engine (matlab.engine), so I’m not opening the GUI.
I tried importing the MRI using import_mri(), but it didn’t work.
Now I’m attempting to download SPM12 and CAT12 from Python to perform the segmentation manually before importing it back into Brainstorm. However, I’d like to know if there is an easier or recommended way to import and segment the MRI directly within the Brainstorm pipeline.
Any guidance or example scripts would be greatly appreciated.
It is possible to use Brainstorm without the GUI, this is by generating a Matlab script, and execute it. Details to do so are described in this tutorial:
The script import_mri() only does that, to import a MRI volume into the Brainstorm DB, the process that you are looking is process_segment_cat12.m
The process process_segment_cat12.m is called in these two examples:
Thank you for your help. However, after using the process you recommended and following the examples, I’m still encountering an issue. Although the MRI appears to be imported and segmented correctly, I can’t find any of the resulting files in my folder, only the brainstormsubject.mat file. I have been unsuccessfully trying to export the results from Brainstorm to Python, in case they were saved within Brainstorm’s internal database, or at least to verify that they are stored there and save them in a variable for later use.
Here is my code. Hopefully, you can help me find a way to solve this problem. Thank you again for your assistance.
Double-check your calls to bst_get, in the shared code: SubjectByName does not exist, and the MriFile takes as argument the the relative path to the MRI file (obtained with file_short(), not the Subject file)