Scripting MRI/CT coregistration pipeline

Hello, I am looking to make a pipeline of coregistering MRI and CT scans in Brainstorm. I can graphically accomplish this by importing the MRI dicom folder, then importing the CT dicom folder and selecting to register with SPM and reslice. This is successful and then I export both MRI and CT files to matlab as .mat. Moving this to scripting (we will have to do this process many times so I would like to have more of a "press-and-go" format than the graphical steps) I am able to use the spm functions to convert the dicom files to a .nii file. I then used the pipeline tool to write the script to import both MRI and CT. I have yet to find the equivalent function of Register with default MRI->SPM: Register + reslice, then export a .mat file. Any help is appreciated!

Hi @mnichols,

The function you are looking for is:

mri_coregister(MriFileSrc, MriFileRef, Method, isReslice)

where MriFileSrc is the volume to register, MriFileRef is the reference volume,
and "SPM: Register + reslice" is obtained with using method = 'spm' and isReslice = 1

There is nothing to do here, all files in Brainstorm database are saved as .mat
A function that may be useful is file_fullpath(fileName) this returns the absolute path, in case fileName is relative to the Brainstorm database directory. e.g, Subject01/subjectimage_MRI.mat

:bulb: Tip: See this section of the tutorial Scripting to know how to find interactive callback functions
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Find_interface_callback_functions

Best,
Raymundo

1 Like

Hi @Raymundo.Cassani, thank you so much this is exactly what I was looking for and couldn't find!! Thanks so much for the help and the quick response!

Is there a place where all the available scripting functions are located to reference in the future? I would like to find the equivalent of Display->Overlay of default MRI (MRI Viewer), and it would be nice if I was able to search through a list somewhere to find functions I need in the future?

Check these two sections of the Scripting tutorial:

This callback is in the tree_callbacks.m brainstorm3/toolbox/tree/tree_callbacks.m at 11a187515a3c95c8d067c085b38a12aca901c920 · brainstorm-tools/brainstorm3 · GitHub

gui_component('MenuItem', jMenuDisplay, [], 'Overlay on default MRI (MRI Viewer)', IconLoader.ICON_ANATOMY, [], @(h,ev)view_mri(MriFile, filenameRelative));

the function that is called is view_mri with the subject's default anatomy and the file to overlay as arguments.