Differences between revisions 19 and 20
Deletions are marked like this. Additions are marked like this.
Line 130: Line 130:
 * '''I ran recon-all -all -hippocampal-subfields-T1/T2 and, after running for hours, the code stopped because I had not installed the Matlab runtime. Do I need to rerun everything?'''  * '''I ran recon-all -all -brainstem-structures and, after running for hours, the code stopped because I had not installed the Matlab runtime. Do I need to rerun everything?'''
Line 132: Line 132:
No! You can just run recon-all -hippocampal-subfields-T1/T2 (that is, without the -all). Of course, that would be after installing the runtime. No! You can just run recon-all -brainstem-structures (that is, without the -all). Of course, that would be after installing the runtime.

Brainstem Substructures

This functionality is present in FreeSurfer 6.0 and later

Author: Juan Eugenio Iglesias

E-mail: iglesias [at] nmr.mgh.harvard.edu

Rather than directly contacting the author, please post your questions on this module to the FreeSurfer mailing list at freesurfer [at] nmr.mgh.harvard.edu

If you use these tools in your analysis, please cite:

See also: HippocampalSubfields

Contents

  1. Motivation and General Description
  2. Installation
  3. Usage
  4. Gathering the volumes from all analyzed subjects
  5. Frequently asked questions
  6. Test data


1. Motivation and General Description

This tool generates an automated segmentation of four different brainstem structures from the input T1 scan: medulla oblongata, pons, midbrain and superior cerebellar peduncle (SCP). We use a Bayesian segmentation algorithm that relies on a probabilistic atlas of the brainstem (and neighboring brain structures) built upon manual delineations of the structures on interest in 49 scans (10 for the brainstem structures, 39 for the surrounding structures). The delineation protocol for the brainstem was designed by Dr. Adam Boxer and his team at the UCSF Memory and Aging Center, and is described in the paper.

Here are sample segmentations produced by the algorithm.


samples.png

2. Installation

The brainstem module requires the Matlab R2012 runtime; the runtime is free, and therefore NO MATLAB LICENSES ARE REQUIRED TO USE THIS SOFTWARE. Please note that, if you have already installed the runtime for the hippocampal subfield module , you do not need to install it again. Instructions for the installation of the runtime can be found here:

https://surfer.nmr.mgh.harvard.edu/fswiki/MatlabRuntime


3. Usage

To use this software, you simply need to add the flag -brainstem-structures to your recon-all command. For example, to analyze subject "bert", you would type:

recon-all -all -s bert -brainstem-structures 

Or, if Bert has already undergone the FreeSurfer pipeline (recon-all -all), you can just run:

recon-all -s bert -brainstem-structures 

The output will be in the subjects mri directory, in this case:

$SUBJECTS_DIR/bert/mri

In this directory, you will find the following three files:

brainstemSsLabels.v10.mgz: the volume with the segmentation at 0.333 mm resolution.

brainstemSsLabels.v10.1mm.mgz: discrete segmentation in the 1 mm FreeSurfer voxel space.

brainstemSsVolumes.v10.txt: a text file with the volumes of the brainstem structures and of the whole brainstem, in cubic mm.


4. Gathering the volumes from all analyzed subjects

Once this module has been run on a number of subjects, it is possible to collect the volumes of the brainstem from all the subjects and write them to a single file - which can be easily read with a spreadsheet application. To do so, one would run:

quantifyBrainstemStructures.sh <output_file> <subject_directory>  

The first argument corresponds to the text file where the table with the volumes will be written. The fields are separated by spaces. The second argument corresponds to the FreeSurfer subjects directory that we want to analyze. This argument is not necessary if the environment variable SUBJECTS_DIR has been defined.


5. Frequently asked questions (FAQ)

  • Are you sure that this software does not require Matlab licenses? Why does it require the Matlab runtime, then?

The software uses compiled Matlab code that requires the free runtime, but no licenses. So, if you have a computer cluster, you can run hundred of segmentations in parallel without having to worry about Matlab licenses. And yes, this is all perfectly legal ;-)

  • The sum of the number of voxels of a given structure multiplied by the volume of a voxel is not equal to the volume reported in brainstemSsVolumes.v10.txt.

This is because the volumes are computed upon a soft segmentation, rather than the discrete segmentation in brainstemSsLabels.v10.mgz. This is the same that happens with the main recon-all stream: if you compute volumes by counting voxels in aseg.mgz, you don't get the values reported in aseg.stats.

  • The size of the image volume of brainstemSsLabels.v10.mgz (in voxels) is not the same as that of norm.mgz or the additional input scan.

The segmentation brainstemSsLabels.v10.mgz covers only a patch around the brainstem, at a higher resolution than the input image. The segmentation and the image are defined in the same physical coordinates, so you can visualize them simultaneously with:

cd $SUBJECTS_DIR/<subject_name>/mri/

freeview -v nu.mgz -v brainstemSsLabels.v10.mgz:colormap=lut  

The software also produces brainstemSsLabels.v10.1mm.mgz, in case you need a segmentation in the 1 mm FreeSurfer voxel space.

  • This module is CPU hungry

Indeed! The deformation of the atlas towards the input scan is parallelized, but recon-all by default limits operation to one thread (which is the polite mode of operation on a cluster). If you want to increase the number of cores that the software is allowed to use, you simply need to add this flag to the end of your recon-all command:

-itkthreads 4

where in this example usage of four threads is specified. You can set this to whatever number is optimal for your machine (two or four per core is typical). This flag sets the environment variable ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS.

  • The volume of the whole brainstem obtained with this module is not equal to the value reported by the main FreeSurfer pipeline in $SUBJECTS_DIR/<subject_name>/stats/aseg.stats.

Yes! There are two reasons for this. First, the volumes correspond to two different analyses. And second: the anatomical definitions of the brainstem are (particularly in the midbrain) are different in the original FreeSurfer protocol and the UCSF protocol used by this module.

  • I ran recon-all -all -brainstem-structures and, after running for hours, the code stopped because I had not installed the Matlab runtime. Do I need to rerun everything?

No! You can just run recon-all -brainstem-structures (that is, without the -all). Of course, that would be after installing the runtime.


6. Test data

Processed data of a single subject (also used to demo the hippocampal subfield segmentation) is available here:

wget -c ftp://surfer.nmr.mgh.harvard.edu/pub/data/hipposubfields-testdata.tgz

The data is extracted with:

tar zxvf hipposubfields-testdata.tgz

Note: within the Martinos Center, this data is found here, but should not be modified (make a copy) as it is used for testing:

/autofs/cluster/freesurfer/subjects/test/hipposubfields

The data is one subject from the ADNI dataset, is fully recon-d. The recon-all command used to produce the brainstem data was:

cd hipposubfields/ADNI_135_S_4863_20-Feb-2013
recon-all \
  -s ADNI_135_S_4863_20-Feb-2013 \
  -brainstem-structures

To view the data:

cd hipposubfields/ADNI_135_S_4863_20-Feb-2013/mri
freeview -v nu.mgz -v brainstemSsLabels.v10.mgz:colormap=lut

BrainstemSubstructures (last edited 2023-11-20 13:18:20 by JuanIglesias)