= Segmentation of hypothalamic subunits =
'''''This functionality is available in [[https://surfer.nmr.mgh.harvard.edu/fswiki/ReleaseNotes|FreeSurfer 7.2]].'''''
< >
< >
''Author: Benjamin Billot''
< >
''E-mail: benjamin.billot.18 [at] ucl.ac.uk''
< >
< >
''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:
* [[https://www.sciencedirect.com/science/article/pii/S1053811920307734|Automated segmentation of the hypothalamus and associated subunits in brain MRI]]. Billot, B., Bocchetta, M., Todd, E., Dalca, A.V., Rohrer, J.D., Iglesias, J.E. Neuroimage (in press).
< >
=== Contents ===
1. General Description
2. Installation
3. Usage
4. Frequently asked questions
< >
=== 1. General Description ===
This tool enables automated segmentation of the hypothalamus and its associated subunits in 3D T1-weighted scans of approximately 1mm isotropic resolution. It uses a convolutional neural network, which enables computing segmentations in a very short processing time (around 10 seconds with a CPU, less than a second with a GPU). More specifically, this code produces segmentation maps for five subregions (with distinct right/left labels), which comprise the following hypothalamic nuclei:
|| Subunits || Left label || Right label || Associated nuclei ||
|| '''Anterior-inferior''' || 801 || 806 || suprachiasmatic nucleus; supraoptic nucleus (SON) ||
|| '''Anterior-superior''' || 802 || 807 || preoptic area; paraventricular nucleus (PVN) ||
|| '''Posterior''' || 803 || 808 || mamillary body (including medial and lateral mamillary nuclei); lateral hypothalamus; tuberomamillary nucleus (TMN) ||
|| '''Inferior tubular''' || 804 || 809 || infundibular (or arcuate) nucleus; ventromedial nucleus; SON; lateral tubular nucleus; TMN ||
|| '''Superior tubular''' || 805 || 810 || dorsomedial nucleus; PVN; lateral hypothalamus ||
The segmentation model was trained by applying aggressive data augmentation, which makes it robust against variability in acquisition parameters (sequence, platform, bias field, head positioning), and in anatomy (e.g. atrophy patterns linked to ageing or different pathologies). The following figure illustrates two segmentation examples in coronal slices obtained by this model for a control subject, and a subject diagnosed with Alzheimer's disease:
< > {{attachment:segs.png||height="300"}} < >< >
=== 2. Installation ===
The first time you run this module, it will prompt you to install Tensorflow. Simply follow the instructions in the screen to install the CPU or GPU version.
If you have a compatible GPU, you can install the GPU version for faster processing, but this requires installing libraries (GPU driver, Cuda, CuDNN).
These libraries are generally required for a GPU, and are not specific for this tool. In fact you may have already installed them. In this case you can directly use this tool without taking any further actions, as the code will automatically run on your GPU.
< >
=== 3. Usage ===
This software can be used in two modes:
* on subjects processed with FreeSurfer
* on any T1 scan of approximately 1mm resolution.
The first mode follows the FreeSurfer subject directory structure and works on the bias field corrected images (nu.mgz). We recommend using this mode if you are running the main FreeSurfer recon-all scripts on your data.
The second mode is more flexible and has the advantage of not having to run subjects through recon-all, if you are only interested in the hypothalamus.
'''''Important:''''' the network has been trained on image at approximately 1mm isotropic resolution, so it would be underperforming if presented with images of higher/lower resolutions.
Depending on the version of FreeSurfer (but regardless of the used mode, i.e., FreesSurfer or any-T1), there are several options:
* '''in the development version''' any image with a resolution outside the [0.95, 1.15] range will be internally resampled to 1mm resolution, regardless of the selected mode (i.e. FreeSurfer subjects or any-T1).
* '''for all the FreeSurfer versions equal or lower than 7.2''', this resamping will have to be done externally, for example with the FreeSurfer command ''mri_convert'':
{{{
mri_convert --voxsize 1 1 1 -odt float
}}}
< >
We now describe what command to use in the different modes. A summary of the following information can be found simply by typing:
{{{
mri_segment_hypothalamic_subunits -h
}}}
< >
==== a. FreeSurfer subjects ====
This tool can be run on subjects that have been analyzed beforehand with the main FreeSurfer stream (i.e. “recon-all”).
Therefore, we will assume that a command similar to the following one has already been run on each subject for which we want to segment the hypothalamic subunits:
{{{
recon-all -all --s
}}}
To analyze one or several subjects, simply use:
{{{
mri_segment_hypothalamic_subunits --s --sd --write_posteriors --threads --cpu
}}}
where:
* '''': is the name of a subject in $SUBJECTS_DIR. You can also specify several subjects to run them all at the same time. If no name is given after --s, the code will be run on ALL subjects in $SUBJECTS_DIR.
* '''': (optional) is the path to a folder with which to override the current value of $SUBJECTS_DIR.
* ''--write_posteriors'': (optional) will save the posteriors (soft segmentations) obtained for each subject. This is not recommended unless needed, since it greatly increases the processing time.
* '''': (optional) number of threads to be used by Tensorflow (default uses one core). Increase it to decrease the runtime when using the CPU version.
* ''--cpu'': (optional) use this flag to enforce running with CPU rather than GPU.
When running on a subject analysed with FreeSurfer, this software automatically saves the segmentation and volumes of the hypothalamic subunits in the FreeSurfer directory structure.
* Segmentations are saved under //mri/hypothalamic_subunits_seg.v1.mgz.
* (in the dev version of FreeSurfer) If the input image had to be resampled to 1mm resolution, then the resample image is also saved under //mri/hypothalamic_subunits_nu_resampled_1mm.v1.mgz.
* Volumes are saved under //mri/hypothalamic_subunits_volumes.v1.csv.
* Volumetric stats are saved under //stats/hypothalamic_subunits_volumes.v1.stats.
* Posteriors (when enabled) are saved under //mri/hypothalamic_subunits_posteriors.v1.mgz.
'''''Important:''''' if several subjects are processed, the outputs will be saved in each subject's directory. Additionally, a CSV file regrouping the volumes of all structures for all subjects will be saved under:
* $SUBJECTS_DIR/hypothalamic_subunits_volumes_all.v1.csv.
'''''Examples:'''''
Segment all subjects in $SUBJECTS_DIR:
{{{
mri_segment_hypothalamic_subunits --s
}}}
Segment a single subject bert:
{{{
mri_segment_hypothalamic_subunits --s bert
}}}
Segment several subjects (bert and ernie):
{{{
mri_segment_hypothalamic_subunits --s bert ernie
}}}
Segment a single subject bert located in a subject directory other than $SUBJECTS_DIR:
{{{
mri_segment_hypothalamic_subunits --s bert --sd /home/user1/data/new_analysis/
}}}
Segment all subjects located in a subject directory other than $SUBJECTS_DIR:
{{{
mri_segment_hypothalamic_subunits --s --sd /home/user1/data/new_analysis/
}}}
< >
==== b. Any T1 scan ====
You can also run this on a T1 scan that has not been processed with FreeSurfer. This tool works on scans with or without preprocessing (e.g., bias field correction, skull stripping, normalization, template registration, etc.).
Depending on the version of FreeSurfer you use, there are two ways to call mri_segment_hypothalamic_subunits.
For FreeSurfer 7.2 or lower, the command line is:
{{{
mri_segment_hypothalamic_subunits --i --o