11128
Comment:
|
19913
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= T1-MRI Segmentation with SPM12 / CAT12 = | = MRI Segmentation with CAT12 = |
Line 4: | Line 4: |
{{attachment:CAT.gif||align="right",width="195px"}} '''CAT''' is a [[http://www.neuro.uni-jena.de/cat/|SPM12 toolbox]] that is fully interfaced with Brainstorm. It can replace efficiently FreeSurfer for generating the cortical surface from any T1 MRI. It runs on '''any OS''' in '''about 1 hour''', instead of the typical 24hr FreeSurfer recon-all processing. The surfaces are registered to the templates with the FreeSurfer spheres, and include many anatomical and functional atlases. You can either run the CAT segmentation from Brainstorm, or run it separately and import its outputs as you would do with FreeSurfer. The software is not packaged with Brainstorm and does not work with the compiled version of Brainstorm, you must install SPM12 and CAT separately. |
{{attachment:CAT.gif||align="right",width="195px"}} [[http://www.neuro.uni-jena.de/cat/|CAT]] is a SPM12 toolbox that is fully interfaced with Brainstorm. It can replace efficiently FreeSurfer for generating the cortical surface from any '''T1 MRI'''. It runs on '''any OS''' in '''about 1 hour''', instead of the typical 24hr FreeSurfer recon-all processing. The surfaces are registered to the templates with the FreeSurfer spheres, and include many surface and volume parcellations. You can either install and run the CAT segmentation from Brainstorm, or run it separately and import its outputs as you would do with FreeSurfer. |
Line 10: | Line 8: |
== Install SPM12 == * Download SPM12: https://www.fil.ion.ucl.ac.uk/spm/software/download/ * Unzip it anywhere on your computer, but '''not''' in any of the Brainstorm folder. * Do not add the spm12 folder to your path if you are not a SPM user, Brainstorm will do this automatically when needed. * Start Brainstorm, set the SPM12 path in the Brainstorm preferences (File > Edit preferences). |
== Cite CAT12 == If you use CAT for MRI segmentation, please cite the following article in your publications: Gaser C, Dahnke R, Kurth F, Luders E<<BR>>CAT - A Computational Anatomy Toolbox for the Analysis of Structural MRI Data<<BR>>'''NeuroImage''', in review |
Line 17: | Line 14: |
* Download CAT: http://www.neuro.uni-jena.de/cat/index.html#DOWNLOAD * Unzip the downloaded file. * Move the cat12 folder to the '''spm12/toolbox '''directory. == Citing CAT12 == If you use CAT from Brainstorm for MRI segmentation, please cite the following article in your publications: Gaser C, Dahnke R, Kurth F, Luders E<<BR>>CAT - A Computational Anatomy Toolbox for the Analysis of Structural MRI Data<<BR>>'''NeuroImage''', in review == Running CAT from Brainstorm == |
CAT12 requires the prior installation of SPM12. Both are Matlab-based programs that be installed automatically as [[Tutorials/Plugins|Brainstorm plugins]]: * Plugins > spm12 > Install * Plugins > Anatomy > spm12 > Install<<BR>><<BR>> {{attachment:install.gif}} If you want to use your own installation of SPM12/CAT12 instead, refer to the [[https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins#Example:_FieldTrip|plugins tutorial]]. * SPM12 download: https://www.fil.ion.ucl.ac.uk/spm/software/download/ * CAT12 download: http://www.neuro.uni-jena.de/cat/index.html#DOWNLOAD '''Troubleshooting''' On Windows computers, you might run into an error: '''Error creating link'''. This is related with the creation of the symbolic link from ''plugins/spm12/spm12/toolbox/cat12'' to ''plugins/cat12/cat12''. This [[https://neuroimage.usc.edu/forums/t/cat12-error-creating-link-access-is-denied/32168|forum post]] mentions two workarounds: * Start Matlab as an administrator: * Right-click on the Matlab icon > Run as administrator * Start Brainstorm, try loading again the plugin (menu Plugins > cat12 > Load). This should restore the broken or missing symbolic link automatically. * Install SPM12/CAT12 manually (not managed as Brainstorm plugins): * Uninstall the CAT12 and SPM12 plugin from Brainstorm, * Download and install them manually on your computer (not in any of the Brainstorm folders), with CAT12 really located in the SPM12 toolbox folder, * Configure Brainstorm to use these custom installations for the two plugins, with the menu "Custom install": https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins#Example:_FieldTrip == Run CAT from Brainstorm == |
Line 28: | Line 38: |
* Create a subject, import the T1 MRI for this subject. * Set the [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#Fiducial_points|fiducial points]] manually (NAS/LPA/RPA) or [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#MNI_transformation|compute the MNI transformation]]. * Right-click on the MRI > '''CAT12 MRI registration''', <<BR>>or use the process '''Import anatomy > Segment MRI with SPM12/CAT12'''<<BR>><<BR>> {{attachment:segmentMenu.gif||width="196",height="251"}} {{attachment:segmentProcess.gif||width="325",height="180"}} * In interactive mode, you will be prompted for the number of vertices you want in the final cortex surface. This will by extension define the number of dipoles to estimate during the source estimation process. By default we set this value to 15000 for the entire brain (it means 7500 for each hemisphere). <<BR>><<BR>> {{attachment:segmentVertices.gif||width="248",height="109"}} * Brainstorm saves the MRI to process in a temporary folder, then calls CAT as an SPM batch:<<BR>>$HOME/.brainstorm/tmp/cat12/spm_cat12.nii |
* Create a new subject, set the default anatomy option to "No, use individual anatomy". * Import the T1 MRI for this subject. * Set the [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#Fiducial_points|fiducial points]] manually (NAS/LPA/RPA) or [[https://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#MNI_normalization|compute the MNI normalization]]. * Right-click on the MRI > '''MRI segmentation > CAT12'''. Two options can be selected interactively: the number of final vertices in the cortex surface, and the computation additional volume parcellations. <<BR>><<BR>> {{attachment:segmentMenu.gif}} * Alternatively, use the process: '''Import anatomy > Segment MRI with CAT12'''. <<BR>><<BR>> {{attachment:segmentProcess.gif}} * With the process version, you have access to more options: * '''TPM atlas''': Location of the template tissue probabilistic maps. If empty, it uses by default the standard TPM.nii available in SPM12 (usually downloaded automatically in the folder $HOME/.brainstorm/defaults/spm/TPM.nii). It can be interesting to replace it with a probabilistic atlas better adapted to specific population, eg. the children atlas from CAT12 (spm12/toolbox/cat12/templates_volumes/TPM_Age11.5.nii) * '''Use spherical registration''': Call CAT12 with the highest possible accuracy, which includes the [[http://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Registered_sphere|spherical registration]] to the FSAverage template. Enabling this option takes much longer, but is necessary for importing all the FreeSurfer atlases, projecting the sources maps to a common template in the case of group analysis, and computing accurate cortical thickness maps. * '''Compute volume parcellations''': Compute and import all the volume parcellations that are available in CAT12: AAL3, CoBrALab, Hammers, IBSR, JulichBrain v2, LPBA40, Mori, Schaefer2018 * '''Import cortical thickness maps''': Enable this option to import the cortical thickness computed by CAT12 as source files. See section [[https://neuroimage.usc.edu/brainstorm/Tutorials/SegCAT12#Cortical_thickness|Cortical thickness]]. * Brainstorm saves the MRI to process in a temporary folder, then calls CAT as a SPM batch:<<BR>>$HOME/.brainstorm/tmp/cat12/spm_cat12.nii |
Line 34: | Line 50: |
Line 35: | Line 52: |
== Troubleshooting == * Error about a missing function '''spm_ov_mesh.m''': you need to update SPM12, from the Brainstorm plugins menu, or run "spm_update" from the Matlab command line. See [[https://neuroimage.usc.edu/forums/t/cat12-segmentation-error-in-linux-and-windows/13409/2|forum post]]. * Error when installing CAT12: '''Error creating link: Access is denied'''. See the troubleshoothing part in the section [[https://neuroimage.usc.edu/brainstorm/Tutorials/SegCAT12#Install_CAT12|Install CAT12]] above. * Search the [[https://neuroimage.usc.edu/forums/tag/cat12|Brainstorm forum]] or create a new topic. * Search the [[https://www.jiscmail.ac.uk/cgi-bin/wa-jisc.exe?A0=SPM|SPM mailing list archive]] or send an email to this list. |
|
Line 39: | Line 62: |
* Right-click on the subject > '''Import anatomy folder'''. * Select the file format '''CAT12 folder''' or '''CAT12 folder + thickness maps'''. * Enter the number of vertices in the final cortex surface. * The files that are imported from the segmentation output folder are the following: * /'''*.nii''' (T1 MRI volume - only one .nii file allowed in the top-level folder) * /surf/'''?h.central.*.gii''' (left/right hemisphere of the central surface) * /surf/'''?h.sphere.reg.*.gii''' (left/right [[https://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Registered_sphere|FreeSurfer registered spheres]]) * /surf/'''?h.thickness''' (texture with the cortical thickness at each vertex) * Additional atlases are imported from the CAT12 program folder ('''spm12/toolbox/cat12'''): * /templates_surfaces/'''?h.central.freesurfer.gii''' (FSAverage central surfaces, high resolution) * /templates_surfaces_32k/'''?h.central.freesurfer.gii''' (FSAverage surfaces, medium resolution) * /atlases_surfaces/'''?h.*.annot''' (cortical surface-based atlases) * /atlases_surfaces_32k/'''?h.*.annot''' (cortical surface-based atlases) * All these atlases available on the FSAverage template are projected to the subject native surfaces using the [[http://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Registered_sphere|FreeSurfer registered spheres]], with functions [[https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/math/bst_project_scouts.m#L57|bst_project_scouts.m]] and [[https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/anatomy/tess_interp_tess2tess.m|tess_interp_tess2tess.m]]. * The '''central surfaces''' generated by CAT are meshes half-way between the grey-white interface and the external pial surface. * The files you can see in the database explorer at the end: * '''MRI''': The T1 MRI of the subject, imported from the .nii file at the top-level folder. * '''head mask''' (10000,0,2): Scalp surface generated by Brainstorm. The numbers indicate the parameters that were automatically used for this head: vertices=10000, erode factor=0, fill holes=2. * '''cortex_250000V''': High-resolution cortex surface that was generated by CAT. * '''cortex_15000V''': Low-resolution cortex surface, downsampled using the reducepatch function from Matlab (it keeps a meaningful subset of vertices from the original surface). It appears in green in the database explorer, ie. it is going to be used as the default by the processes that require a cortex surface. * A figure is automatically shown at the end of the process, to check visually that the cortex and head surfaces were properly generated and imported. If it doesn't look like the following picture, do not go any further in your source analysis, [[https://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Handling_errors|fix the anatomy]] first. <<BR>><<BR>> {{attachment:checkDb.gif}} {{attachment:checkResults.gif||width="197",height="234"}} |
* Right-click on the subject > '''Import anatomy folder'''.<<BR>><<BR>> {{attachment:importSelect.gif}} * '''Import anatomy folder''': Interactive import: asks for the number of vertices expected in the final cortex surfaces, for the volume atlases, and for the location of the fiducials NAS/LPA/RPA. Select this option in the case of an MEG study, when you know exactly where the fiducials were digitized during the MEG acquisition. See tutorial [[https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile#Automatic_registration|MRI registration]]. * '''Import anatomy folder (auto)''': Automatic import: Computes the [[https://neuroimage.usc.edu/brainstorm/CoordinateSystems#MNI_coordinates|linear MNI normalization]], uses default positions from the MNI atlas for the NAS/LPA/RPA fiducials, uses 15000 vertices for the cortex downsampled surfaces, and imports all the volume atlases. * Select one the CAT12 import options and select the top folder of the CAT12 segmentation: * '''CAT12''': Import the T1 MRI, cortex surfaces (central, pial and white), surface parcellations, surface spherical registration, surface and volume parcellations. Reconstruct the head surface. * '''CAT12 + ''''''Thickness''': Same as above, with the cortical thickness maps imported as source maps. * A figure is automatically shown at the end of the process, to check visually that the low-resolution cortex and head surfaces were properly generated and imported. If it doesn't look like the following picture, do not go any further in your source analysis, [[https://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Handling_errors|fix the anatomy]] first. <<BR>><<BR>> {{attachment:checkDb.gif}} * '''Difference with FreeSurfer''': The default surface selected when importing results from CAT12 is the low-resolution [[http://dbm.neuro.uni-jena.de/pdf-files/Dahnke-NI12.pdf|central surface]], while when importing FreeSurfer results the default surface is the '''pial surface''' (named "cortex"). == Files imported == The files that are imported from the segmentation output folder are the following: * /'''*.nii''' (T1 MRI volume - only one .nii file allowed in the top-level folder) * /surf/'''?h.central.*.gii''' (left/right hemisphere of the [[http://dbm.neuro.uni-jena.de/pdf-files/Dahnke-NI12.pdf|central surface]]) * /surf/'''?h.pial.*.gii''' (left/right hemisphere of the pial surface, i.e. the external cortex layer) * /surf/'''?h.white.*.gii''' (left/right hemisphere of the white surface, i.e. the inner cortex layer) * /surf/'''?h.sphere.reg.*.gii''' (left/right [[https://neuroimage.usc.edu/brainstorm/Tutorials/LabelFreeSurfer#Registered_sphere|FreeSurfer registered spheres]]) * /surf/'''?h.*.annot''' (cortical surface-based atlases) * /surf/'''?h.thickness'''.* (texture with the cortical thickness at each vertex) * /mri/'''p*.nii''' (tissue probability maps, used to create the tissue segmentation volume) * /mri_atlas/'''*.nii''' (volume parcellations) The files you can see in the database explorer at the end: * '''MRI''': The T1 MRI of the subject, imported from the .nii file at the top-level folder. * '''Volume parcellations''': /mri_atlas/*.nii, see tutorial [[https://neuroimage.usc.edu/brainstorm/Tutorials/ExploreAnatomy#Subcortical_regions:_Volume|Explore the anatomy]]. * '''Tissue_cat12''': Segmentation of the MRI volumes in 5 tissues: gray, white, CSF, skull, scalp. * '''head mask''' (10000,0,2): Scalp surface generated by Brainstorm. The numbers indicate the parameters that were automatically used for this head: vertices=10000, erode factor=0, fill holes=2. * '''central_250000V''': High-resolution cortex surface generated by CAT. The '''central surfaces''' are meshes half-way between the grey-white interface and the external pial surface ([[http://dbm.neuro.uni-jena.de/pdf-files/Dahnke-NI12.pdf|Dahnke et al. 2012]]). * '''central_15000V''': Low-resolution cortex surface, downsampled using the reducepatch function from Matlab (it keeps a meaningful subset of vertices from the original surface). It appears in green in the database explorer, ie. it is going to be used as the default by the processes that require a cortex surface. * '''pial_250000V''': High-resolution pial surface, i.e. the most external cortical layer. * '''pial_15000V''': Low-resolution pial surface, i.e. the most external cortical layer. Change the selection to this surface for a direct comparison with the FreeSurfer results. * '''white_250000V''': High-resolution white matter surface, i.e. the interface between the grey and the white matter (or innermost cortical layer). * '''white_15000V''': Low-resolution white matter surface. |
Line 62: | Line 98: |
FreeSurfer's FSAverage subject includes parcellations of the cortical surface in anatomical or functional regions. The description of this feature is available here:<<BR>>http://freesurfer.net/fswiki/CorticalParcellation Using CAT12 from Brainstorm, you have access to 15 atlases on all the individual brains: * '''Destrieux''' atlas (atlases_surfaces/?h.aparc_a2009s.freesurfer.annot): [[http://ftp.nmr.mgh.harvard.edu/fswiki/CorticalParcellation|more info]] * '''Desikan-Killiany''' atlas (atlases_surfaces/?h.aparc_DK40.freesurfer.annot): [[http://ftp.nmr.mgh.harvard.edu/fswiki/CorticalParcellation|more info]] * '''HCP MMP1''' atlas (atlases_surfaces/?h.aparc_HCP_MMP1.freesurfer.annot): [[https://cjneurolab.org/2016/11/22/hcp-mmp1-0-volumetric-nifti-masks-in-native-structural-space/|more info]] * '''Schaefer 2018''' atlases (atlases_surfaces_32k/?h.Schaefer2018_*.annot): [[https://www.biorxiv.org/content/biorxiv/early/2017/07/16/135632.full.pdf|more info]] These atlases are imported in Brainstorm as scouts (cortical regions of interest), and saved directly in the surface files. To check where they are saved: right-click on the low-resolution cortex file > File > View file contents. You can see that 17 structures "Atlas" are available, the first one that has Name='User scouts', and the second one Name='Destrieux'. {{attachment:viewMat.gif||width="430",height="404"}} To access them from the interface: Double-click on the cortex and go to the ''Scout'' tab, and click on the drop-down list to select another ''Atlas ''(ie group of scouts): {{attachment:scoutTab.gif||width="187",height="180"}} {{attachment:atlasDestrieux.gif||width="227",height="180"}} {{attachment:atlasDK.gif||width="229",height="180"}} |
Using CAT12 from Brainstorm, the following cortex parcellations are available: * '''Destrieux''' atlas (surf/?h.aparc_a2009s.*.annot): [[http://ftp.nmr.mgh.harvard.edu/fswiki/CorticalParcellation|more info]] * '''Desikan-Killiany''' atlas (surf/?h.aparc_DK40.*.annot): [[http://ftp.nmr.mgh.harvard.edu/fswiki/CorticalParcellation|more info]] * '''HCP MMP1''' atlas (surf/?h.aparc_HCP_MMP1.*.annot): [[https://cjneurolab.org/2016/11/22/hcp-mmp1-0-volumetric-nifti-masks-in-native-structural-space/|more info]] * '''Schaefer 2018''' atlases (surf/?h.Schaefer2018_*.annot): [[https://www.biorxiv.org/content/biorxiv/early/2017/07/16/135632.full.pdf|more info]] These atlases are imported in Brainstorm as scouts (cortical regions of interest), and saved directly in the [[https://neuroimage.usc.edu/brainstorm/Tutorials/Scouts#On_the_hard_drive|surface files]]. To access them from the interface: Double-click on the cortex, go to the ''Scout'' tab and click on the drop-down list to select another ''Atlas ''(ie group of scouts): {{attachment:scoutTab.gif||width="154",height="180"}} {{attachment:atlasDestrieux.gif||width="227",height="180"}} {{attachment:atlasDK.gif||width="229",height="180"}} |
Line 84: | Line 114: |
{{attachment:thicknessFile.gif}} {{attachment:thicknessMap.gif||width="300",height="203"}} | {{attachment:thicknessFile.gif}} == Registered spheres == The registered spheres are saved in each surface file in the field Reg.Sphere.Vertices. There is nothing that can be done with this information at this point, but it will become helpful when projecting the source results from the individual brains to the default anatomy of the protocol, for a group analysis of the results: [[Tutorials/CoregisterSubjects|Subject coregistration]]. Read more about the FreeSurfer registration process on the software wiki:<<BR>> https://surfer.nmr.mgh.harvard.edu/fswiki/SurfaceRegAndTemplates == Volume parcellations == Many volume parcellations are available when this option is selected when running CAT: * '''AAL3''': [[https://www.gin.cnrs.fr/en/tools/aal/|More information]] * '''Anatomy3''': [[https://www.fz-juelich.de/SharedDocs/Downloads/INM/INM-7/EN/SPM_Toolbox/Toolbox_3.html|More information]] * '''Cobra''': [[http://cobralab.ca/atlases/|More information]] * '''Hammers''': [[http://brain-development.org/brain-atlases/adult-brain-atlases/|More information]] * '''IBSR''': [[http://www.cma.mgh.harvard.edu/ibsr/|More information]] * '''JulichBrain v2.0''': [[https://kg.ebrains.eu/search/instances/Dataset/3fde2768-e845-4fc3-a425-61e2c1fb6db7|More information]] * '''LPBA40''': [[http://www.loni.usc.edu/research/atlases|More information]] * '''Mori''': [[http://wiki.slicer.org/slicerWiki/index.php/Slicer3:Mori-Atlas_labels|More information]] * '''Neuromorphometrics''': [[http://www.neuromorphometrics.com/?page_id=310|More information]] * '''Schaefer2018''': [[https://www.biorxiv.org/content/biorxiv/early/2017/07/16/135632.full.pdf|More information]] * '''Thalamus''': [[https://wp.unil.ch/mial/probabilistic-atlas-of-thalamic-nuclei/|More information]] {{attachment:volatlas.gif}} == Tissue classification == The tissue probability maps saved in /mri/p*.nii are grouped to create one volume with the labels of 5 tissues: gray matter, white matter, CSF, skull, scalp. {{attachment:voltissues.gif}} |
Line 90: | Line 147: |
% Create SPM batch matlabbatch{1}.spm.tools.cat.estwrite.data = {[NiiFile ',1']}; matlabbatch{1}.spm.tools.cat.estwrite.nproc = 0; matlabbatch{1}.spm.tools.cat.estwrite.opts.tpm = {bst_get('SpmTpmAtlas')}; matlabbatch{1}.spm.tools.cat.estwrite.opts.affreg = 'mni'; matlabbatch{1}.spm.tools.cat.estwrite.opts.biasstr = 0.5; matlabbatch{1}.spm.tools.cat.estwrite.opts.accstr = 0.5; matlabbatch{1}.spm.tools.cat.estwrite.extopts.APP = 1070; matlabbatch{1}.spm.tools.cat.estwrite.extopts.LASstr = 0.5; matlabbatch{1}.spm.tools.cat.estwrite.extopts.gcutstr = 2; matlabbatch{1}.spm.tools.cat.estwrite.extopts.registration.dartel.darteltpm = {dartelTpm}; matlabbatch{1}.spm.tools.cat.estwrite.extopts.vox = 1.5; matlabbatch{1}.spm.tools.cat.estwrite.extopts.restypes.fixed = [1 0.1]; matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.native = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.mod = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.native = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.mod = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.labelnative = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.bias.warped = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.jacobianwarped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.warps = [0 0]; % Run SPM batch spm_jobman('initcfg'); spm_jobman('run',matlabbatch); |
matlabbatch{1}.spm.tools.cat.estwrite.data = {[NiiFile ',1']}; matlabbatch{1}.spm.tools.cat.estwrite.data_wmh = {''}; matlabbatch{1}.spm.tools.cat.estwrite.useprior = ''; matlabbatch{1}.spm.tools.cat.estwrite.nproc = 0; % Blocking call to CAT12 matlabbatch{1}.spm.tools.cat.estwrite.opts.tpm = {TpmNii}; % User-defined TPM atlas matlabbatch{1}.spm.tools.cat.estwrite.output.bias.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.native = 1; % GM tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.GM.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.native = 1; % WM tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.WM.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.native = 1; % Tissue classes 4-6 matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.native = 1; % CSF tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.label.native = 1; % CSF=1,GM=2,WM=3,WMH=4 matlabbatch{1}.spm.tools.cat.estwrite.output.label.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.label.dartel = 0; % Volume atlases if isVolumeAtlases matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.aal3 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.anatomy3 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.ibsr = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.julichbrain = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.mori = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_100Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_200Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_400Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_800Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.atlas.native = 1; % Save in native space else matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.noROI = struct([]); matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 0; end % Extract additional surface parameters: Cortical thickness, Gyrification index, Sulcal depth if isExtraMaps % Separate SPM process (second element in the batch) matlabbatch{2}.spm.tools.cat.stools.surfextract.data_surf(1) = cfg_dep('CAT12: Segmentation (current release): Left Central Surface', substruct('.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}), substruct('()',{1}, '.','lhcentral', '()',{':'})); matlabbatch{2}.spm.tools.cat.stools.surfextract.GI = 1; % Gyrification index matlabbatch{2}.spm.tools.cat.stools.surfextract.SD = 1; % Sulcal depth matlabbatch{2}.spm.tools.cat.stools.surfextract.nproc = 0; % Blocking call to CAT12 end % Run SPM batch spm_jobman('initcfg'); spm_jobman('run',matlabbatch); |
Line 122: | Line 209: |
== Additional documentation == * Forum: [[https://neuroimage.usc.edu/forums/t/various-cat12-errors-with-different-versions-of-matlab-operating-systems/13435/5|Debugging CAT12 integration in Brainstorm]] * Forum: [[https://neuroimage.usc.edu/forums/t/cat12-missing-files/23121/3|CAT12 Missing Files + ICBM152 segmentation]] * Git issue: [[https://github.com/brainstorm-tools/brainstorm3/issues/352|Bugs CAT12 v1728]] |
MRI Segmentation with CAT12
Authors: Francois Tadel
CAT is a SPM12 toolbox that is fully interfaced with Brainstorm. It can replace efficiently FreeSurfer for generating the cortical surface from any T1 MRI. It runs on any OS in about 1 hour, instead of the typical 24hr FreeSurfer recon-all processing. The surfaces are registered to the templates with the FreeSurfer spheres, and include many surface and volume parcellations. You can either install and run the CAT segmentation from Brainstorm, or run it separately and import its outputs as you would do with FreeSurfer.
Contents
Cite CAT12
If you use CAT for MRI segmentation, please cite the following article in your publications:
Gaser C, Dahnke R, Kurth F, Luders E
CAT - A Computational Anatomy Toolbox for the Analysis of Structural MRI Data
NeuroImage, in review
Install CAT12
CAT12 requires the prior installation of SPM12. Both are Matlab-based programs that be installed automatically as Brainstorm plugins:
Plugins > spm12 > Install
Plugins > Anatomy > spm12 > Install
If you want to use your own installation of SPM12/CAT12 instead, refer to the plugins tutorial.
SPM12 download: https://www.fil.ion.ucl.ac.uk/spm/software/download/
CAT12 download: http://www.neuro.uni-jena.de/cat/index.html#DOWNLOAD
Troubleshooting
On Windows computers, you might run into an error: Error creating link. This is related with the creation of the symbolic link from plugins/spm12/spm12/toolbox/cat12 to plugins/cat12/cat12. This forum post mentions two workarounds:
- Start Matlab as an administrator:
Right-click on the Matlab icon > Run as administrator
Start Brainstorm, try loading again the plugin (menu Plugins > cat12 > Load). This should restore the broken or missing symbolic link automatically.
- Install SPM12/CAT12 manually (not managed as Brainstorm plugins):
- Uninstall the CAT12 and SPM12 plugin from Brainstorm,
- Download and install them manually on your computer (not in any of the Brainstorm folders), with CAT12 really located in the SPM12 toolbox folder,
Configure Brainstorm to use these custom installations for the two plugins, with the menu "Custom install": https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins#Example:_FieldTrip
Run CAT from Brainstorm
- Switch to the anatomy side of the database explorer.
- Create a new subject, set the default anatomy option to "No, use individual anatomy".
- Import the T1 MRI for this subject.
Set the fiducial points manually (NAS/LPA/RPA) or compute the MNI normalization.
Right-click on the MRI > MRI segmentation > CAT12. Two options can be selected interactively: the number of final vertices in the cortex surface, and the computation additional volume parcellations.
Alternatively, use the process: Import anatomy > Segment MRI with CAT12.
- With the process version, you have access to more options:
TPM atlas: Location of the template tissue probabilistic maps. If empty, it uses by default the standard TPM.nii available in SPM12 (usually downloaded automatically in the folder $HOME/.brainstorm/defaults/spm/TPM.nii). It can be interesting to replace it with a probabilistic atlas better adapted to specific population, eg. the children atlas from CAT12 (spm12/toolbox/cat12/templates_volumes/TPM_Age11.5.nii)
Use spherical registration: Call CAT12 with the highest possible accuracy, which includes the spherical registration to the FSAverage template. Enabling this option takes much longer, but is necessary for importing all the FreeSurfer atlases, projecting the sources maps to a common template in the case of group analysis, and computing accurate cortical thickness maps.
Compute volume parcellations: Compute and import all the volume parcellations that are available in CAT12: AAL3, CoBrALab, Hammers, IBSR, JulichBrain v2, LPBA40, Mori, Schaefer2018
Import cortical thickness maps: Enable this option to import the cortical thickness computed by CAT12 as source files. See section Cortical thickness.
Brainstorm saves the MRI to process in a temporary folder, then calls CAT as a SPM batch:
$HOME/.brainstorm/tmp/cat12/spm_cat12.nii- All the output from CAT is saved in the same temporary folder. At the end, Brainstorm imports the output folder as the anatomy for the selected subject. If the process crashes, you can inspect the contents of this folder for indices on how to solve the problem. If the segmentation and the import is successful, the temporary folder is deleted.
A report is displayed by CAT, and saved as an image and a PDF file in tmp/cat12/report.
Troubleshooting
Error about a missing function spm_ov_mesh.m: you need to update SPM12, from the Brainstorm plugins menu, or run "spm_update" from the Matlab command line. See forum post.
Error when installing CAT12: Error creating link: Access is denied. See the troubleshoothing part in the section Install CAT12 above.
Search the Brainstorm forum or create a new topic.
Search the SPM mailing list archive or send an email to this list.
Importing the results in Brainstorm
If you run the segmentation process from Brainstorm, the import will be done automatically. Otherwise, if you need to import an existing CAT segmentation, here is the following procedure.
Right-click on the subject > Import anatomy folder.
Import anatomy folder: Interactive import: asks for the number of vertices expected in the final cortex surfaces, for the volume atlases, and for the location of the fiducials NAS/LPA/RPA. Select this option in the case of an MEG study, when you know exactly where the fiducials were digitized during the MEG acquisition. See tutorial MRI registration.
Import anatomy folder (auto): Automatic import: Computes the linear MNI normalization, uses default positions from the MNI atlas for the NAS/LPA/RPA fiducials, uses 15000 vertices for the cortex downsampled surfaces, and imports all the volume atlases.
- Select one the CAT12 import options and select the top folder of the CAT12 segmentation:
CAT12: Import the T1 MRI, cortex surfaces (central, pial and white), surface parcellations, surface spherical registration, surface and volume parcellations. Reconstruct the head surface.
CAT12 + Thickness: Same as above, with the cortical thickness maps imported as source maps.
A figure is automatically shown at the end of the process, to check visually that the low-resolution cortex and head surfaces were properly generated and imported. If it doesn't look like the following picture, do not go any further in your source analysis, fix the anatomy first.
Difference with FreeSurfer: The default surface selected when importing results from CAT12 is the low-resolution central surface, while when importing FreeSurfer results the default surface is the pial surface (named "cortex").
Files imported
The files that are imported from the segmentation output folder are the following:
/*.nii (T1 MRI volume - only one .nii file allowed in the top-level folder)
/surf/?h.central.*.gii (left/right hemisphere of the central surface)
/surf/?h.pial.*.gii (left/right hemisphere of the pial surface, i.e. the external cortex layer)
/surf/?h.white.*.gii (left/right hemisphere of the white surface, i.e. the inner cortex layer)
/surf/?h.sphere.reg.*.gii (left/right FreeSurfer registered spheres)
/surf/?h.*.annot (cortical surface-based atlases)
/surf/?h.thickness.* (texture with the cortical thickness at each vertex)
/mri/p*.nii (tissue probability maps, used to create the tissue segmentation volume)
/mri_atlas/*.nii (volume parcellations)
The files you can see in the database explorer at the end:
MRI: The T1 MRI of the subject, imported from the .nii file at the top-level folder.
Volume parcellations: /mri_atlas/*.nii, see tutorial Explore the anatomy.
Tissue_cat12: Segmentation of the MRI volumes in 5 tissues: gray, white, CSF, skull, scalp.
head mask (10000,0,2): Scalp surface generated by Brainstorm. The numbers indicate the parameters that were automatically used for this head: vertices=10000, erode factor=0, fill holes=2.
central_250000V: High-resolution cortex surface generated by CAT. The central surfaces are meshes half-way between the grey-white interface and the external pial surface (Dahnke et al. 2012).
central_15000V: Low-resolution cortex surface, downsampled using the reducepatch function from Matlab (it keeps a meaningful subset of vertices from the original surface). It appears in green in the database explorer, ie. it is going to be used as the default by the processes that require a cortex surface.
pial_250000V: High-resolution pial surface, i.e. the most external cortical layer.
pial_15000V: Low-resolution pial surface, i.e. the most external cortical layer. Change the selection to this surface for a direct comparison with the FreeSurfer results.
white_250000V: High-resolution white matter surface, i.e. the interface between the grey and the white matter (or innermost cortical layer).
white_15000V: Low-resolution white matter surface.
Cortical parcellations
Using CAT12 from Brainstorm, the following cortex parcellations are available:
Destrieux atlas (surf/?h.aparc_a2009s.*.annot): more info
Desikan-Killiany atlas (surf/?h.aparc_DK40.*.annot): more info
HCP MMP1 atlas (surf/?h.aparc_HCP_MMP1.*.annot): more info
Schaefer 2018 atlases (surf/?h.Schaefer2018_*.annot): more info
These atlases are imported in Brainstorm as scouts (cortical regions of interest), and saved directly in the surface files. To access them from the interface: Double-click on the cortex, go to the Scout tab and click on the drop-down list to select another Atlas (ie group of scouts):
Cortical thickness
The cortical thickness can be saved as a cortical map in the database (a "results" file). This result is generated when using the file format "CAT12 folder + Thickness maps" in the Import anatomy folder selection.
Registered spheres
The registered spheres are saved in each surface file in the field Reg.Sphere.Vertices. There is nothing that can be done with this information at this point, but it will become helpful when projecting the source results from the individual brains to the default anatomy of the protocol, for a group analysis of the results: Subject coregistration.
Read more about the FreeSurfer registration process on the software wiki:
https://surfer.nmr.mgh.harvard.edu/fswiki/SurfaceRegAndTemplates
Volume parcellations
Many volume parcellations are available when this option is selected when running CAT:
AAL3: More information
Anatomy3: More information
Cobra: More information
Hammers: More information
IBSR: More information
JulichBrain v2.0: More information
LPBA40: More information
Mori: More information
Neuromorphometrics: More information
Schaefer2018: More information
Thalamus: More information
Tissue classification
The tissue probability maps saved in /mri/p*.nii are grouped to create one volume with the labels of 5 tissues: gray matter, white matter, CSF, skull, scalp.
SPM batch
The CAT segmentation is executed with the following SPM12 batch:
matlabbatch{1}.spm.tools.cat.estwrite.data = {[NiiFile ',1']}; matlabbatch{1}.spm.tools.cat.estwrite.data_wmh = {''}; matlabbatch{1}.spm.tools.cat.estwrite.useprior = ''; matlabbatch{1}.spm.tools.cat.estwrite.nproc = 0; % Blocking call to CAT12 matlabbatch{1}.spm.tools.cat.estwrite.opts.tpm = {TpmNii}; % User-defined TPM atlas matlabbatch{1}.spm.tools.cat.estwrite.output.bias.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.native = 1; % GM tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.GM.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.GM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.native = 1; % WM tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.WM.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.WM.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.native = 1; % Tissue classes 4-6 matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.native = 1; % CSF tissue maps matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.mod = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.dartel = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.label.native = 1; % CSF=1,GM=2,WM=3,WMH=4 matlabbatch{1}.spm.tools.cat.estwrite.output.label.warped = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.label.dartel = 0; % Volume atlases if isVolumeAtlases matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.aal3 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.anatomy3 = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.ibsr = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.julichbrain = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.mori = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_100Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_200Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_400Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_800Parcels_17Networks_order = 1; matlabbatch{1}.spm.tools.cat.estwrite.output.atlas.native = 1; % Save in native space else matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.noROI = struct([]); matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 0; matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 0; end % Extract additional surface parameters: Cortical thickness, Gyrification index, Sulcal depth if isExtraMaps % Separate SPM process (second element in the batch) matlabbatch{2}.spm.tools.cat.stools.surfextract.data_surf(1) = cfg_dep('CAT12: Segmentation (current release): Left Central Surface', substruct('.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}), substruct('()',{1}, '.','lhcentral', '()',{':'})); matlabbatch{2}.spm.tools.cat.stools.surfextract.GI = 1; % Gyrification index matlabbatch{2}.spm.tools.cat.stools.surfextract.SD = 1; % Sulcal depth matlabbatch{2}.spm.tools.cat.stools.surfextract.nproc = 0; % Blocking call to CAT12 end % Run SPM batch spm_jobman('initcfg'); spm_jobman('run',matlabbatch);
Additional documentation
Git issue: Bugs CAT12 v1728