|Deletions are marked like this.||Additions are marked like this.|
|Line 107:||Line 107:|
|ANALYSIS_ID is a user defined identifier that makes it possible to run different analysis with different types of additional scans. For example, you can run the command with a DBS volume and use the identifier "DBS", and then run it again with a FGATIR volume and use the identifier "FGATIR", such that both results will coexist in the subject's mri directory (see naming convention for the generated output below). '''For a certain modality of additional scan, make sure that you use the same ID for all the subjects within a study. Also please note that it is not possible to run multiple instances of segmentThalamicNuclei.sh in parallel, using different additiona scans and ANALAYSIS_ID identifiers'''. As in the T1 case, SUBJECTS_DIR is optional, and overrides the !FreeSurfer subject directory when provided.||ANALYSIS_ID is a user defined identifier that makes it possible to run different analysis with different types of additional scans. For example, you can run the command with a DBS volume and use the identifier "DBS", and then run it again with a FGATIR volume and use the identifier "FGATIR", such that both results will coexist in the subject's mri directory (see naming convention for the generated output below). '''For a certain modality of additional scan, make sure that you use the same ID for all the subjects within a study. Also please note that it is possible to run multiple instances of segmentThalamicNuclei.sh in parallel, using different additiona scans and ANALAYSIS_ID identifiers'''. As in the T1 case, SUBJECTS_DIR is optional, and overrides the !FreeSurfer subject directory when provided.|
Segmentation of thalamic nuclei
This functionality is not available in FreeSurfer yet, but will be part of the development version soon
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:
- A probabilistic atlas of the human thalamic nuclei combining ex vivo MRI and histology. Iglesias, J.E., Insausti, R., Lerma-Usabiaga, G., Bocchetta, M., Van Leemput, K., Greve, D., van der Kouwe, A., Caballero-Gaudes, C., Paz-Alonso, P.
- Motivation and General Description
- Gathering the volumes from all analyzed subjects
- Frequently asked questions
- Test data
1. Motivation and General Description
This tool produces a parcellation of the thalamus into 25 different nuclei, using a probabilistic atlas built with histological data. The parcellation is based on structural MRI, either the main T1 scan processed through recon-all, or an additional scan of a different modality, which potentially shows better contrast between the nuclei. For example, we have observed good contrast with FGATIR sequences, or those used in deep brain stimulation (DBS). The main feature exploited by the atlas is the boundary between the mediodorsal and pulvinar nuclei, and the rest of the nuclei:
Another example, using a DBS scan:
We note that, at this point, the code cannot exploit information in diffusion MR data - this feature will be developed in future versions.
This module requires the Matlab R2014b runtime, which 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 / amygdala module, you do not need to install it again. Instructions for the installation of the runtime can be found here:
This software requires that a whole brain T1 scan of the subject has been analyzed with the main FreeSurfer stream ("recon-all"), i.e., we will assume that the command similar to this has already been run:
recon-all -all -s bert
where bert is the name of the subject. Bear in mind that, if this T1 scan has a voxel size smaller than 1 mm, it is possible to exploit this higher resolution by using the flag -cm in recon-all. Otherwise, both recon-all and this tool will work with a resampled version of the T1 volume at 1mm isotropic resolution.
This thalamic segmentation tool has two modes of operation: 1. Using only the main T1 volume processed with recon-all (norm.mgz); 2. Using an additional MRI volume (any MRI contrast supported; this scan ideally shows superior contrast between the thalamic nuclei).
Usin the T1 scan from recon-all
To analyze your subject "bert", you would simply type:
segmentThalamicNuclei.sh bert [SUBJECTS_DIR]
where the second argument is optional, and can be used to override the FreeSurfer subject directory.
The output will consist of the following three files, which can be found under the subject's mri directory (in this example, $SUBJECTS_DIR/bert/mri/):
ThalamicNuclei.v10.T1.volumes.txt: this text file stores the estimated volumes of the thalamic nuclei.
ThalamicNuclei.v10.T1.mgz: stores the discrete segmentation volumes at subvoxel resolution (0.5 mm).
ThalamicNuclei.v10.T1.FSvoxelSpace.mgz: stores the discrete segmentation volume in the FreeSurfer voxel space (normally 1mm isotropic, unless higher resolution data was used in recon-all with the flag -cm).
Discrete segmentation means a segmentation where there is one label for each voxel. Note that ThalamicNuclei.v10.T1.mgz only covers a patch around the thalamus, 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 (run from the subject's mri directory):
freeview -v nu.mgz -v ThalamicNuclei.v10.T1.mgz:colormap=lut
On the other hand ThalamicNuclei.v10.T1.FSvoxelSpace.mgz lives in the same voxel space as the other FreeSurfer volumes (e.g., orig.mgz, nu.mgz, aseg.mgz), so you can use it directly to produce masks for further analyses, but its resolution is lower (1 mm vs 0.5 mm).
Using an additional scan
If an additional MRI volume (e.g., a FGATIR scan, or a DBS scan) is available, we can use it to obtain a more reliable segmentation - particularly in the case in which its contrast is higher than that of the main T1 scan around the thalamus. In this case, the only requirement is that the additional scan is coarsely aligned to the main T1 scan.
To analyze subject bert, the command would be:
segmentThalamicNuclei.sh bert FILE_ADDITIONAL_SCAN ANALYSIS_ID BBREGISTER_MODE [SUBJECTS_DIR]
FILE_ADDITIONAL_SCAN is the additional scan to use in the segmentation, in Nifty (.nii/.nii.gz) or FreeSurfer format (.mgh/.mgz).
ANALYSIS_ID is a user defined identifier that makes it possible to run different analysis with different types of additional scans. For example, you can run the command with a DBS volume and use the identifier "DBS", and then run it again with a FGATIR volume and use the identifier "FGATIR", such that both results will coexist in the subject's mri directory (see naming convention for the generated output below). For a certain modality of additional scan, make sure that you use the same ID for all the subjects within a study. Also please note that it is possible to run multiple instances of segmentThalamicNuclei.sh in parallel, using different additiona scans and ANALAYSIS_ID identifiers. As in the T1 case, SUBJECTS_DIR is optional, and overrides the FreeSurfer subject directory when provided.
BBREGISTER_MODE: this module relies on BBregister for the registration of the additional scan to the main T1 volume. This argument specifies the contrast of the additional scan, and can be equal to 't1', 't2', or 'none'. Modes 't1' and 't2' map directly to the corresponding BBregister contrast flags, which specifies whether white matter is brighter than gray matter (t1 mode) or the other way around (t2 mode). Note that the additional volume does not have to be a T1 or T2 scan; for example, a FGATIR scan like the one in the figure above would be processed with the 't2' flag, since the gray matter is brighter than the white matter. Finally, the third mode (none) skips the registration (i.e., assumes that the additional scan has already been registered to the main FreeSurfer T1), and is therefore compatible with any MRI contrast.
This command generates the same three volumes as the T1 version, but also two additional volumes corresponding to the registered/resampled additional scan:
ThalamicNuclei.v10.<analysisID>.volumes.txt: text file with estimated volumes.
ThalamicNuclei.v10.<analysisID>.mgz: discrete segmentation at 0.5 mm.
ThalamicNuclei.v10.<analysisID>.FSvoxelSpace.mgz: discrete segmentation volume in FreeSurfer voxel space.
<analysisID>.thalamus.<bbRegisterMode>.mgz: registered additional volume, resampled to the FreeSurfer voxel space./
<analysisID>.thalamus.<bbRegisterMode>.stripped.bfcorr.mgz: skull stripped and bias field corrected version of the volume above.
In order to visualize the outputs: let's say that you have run an analysis with id FGATIR, and bbregister mode t2. Then, you can for example run the following command from the subject's mri directory:
freeview -v nu.mgz -v FGATIR.thalamus.t2.mgz -v FGATIR.thalamus.t2.stripped.bfcorr.mgz -v ThalamicNuclei.v10.FGATIR.mgz:colormap=lut
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 thalamic nuclei of all subjects and write them to a single file - which can be easily read with a spreadsheet application. To do so, one would run:
quantifyThalamicNuclei.sh <output_file> <analysisID> <OPTIONAL_SUBJECTS_DIR>
The first argument (<output_file>) corresponds to the text file where the table with the volumes will be written. The second argument is the name of the analysis, i.e., ANALYSIS_ID (if using only the T1 from Freesurfer, it is simply 'T1'). Finally, the third argument is optional and overrides the FreeSurfer subjects directory.
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 runtime (which is free), 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 ThalamicNuclei.v10.T1.volumes.txt.
This is because the volumes are computed upon a soft segmentation, rather than the discrete labels in [lr]h.hippoAmygLabels*.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 ThalamicNuclei.v10.<analysisID>.mgz (in voxels) is not the same as that of norm.mgz or the additional input scan.
The segmentations cover only a patch around the thalamus, at a higher resolution than the input image. The segmentation and the image are defined in the same physical coordinates, so that is why you can still visualize them simultaneously with FreeView using the commands listed above. The software also gives ThalamicNuclei.v10.<analysisID>.FSvoxelSpace.mgz, which is in the same voxel space as the other FreeSurfer volumes, in case you need it to produce masks for other processing.
I am interested in the soft segmentations (i.e., posterior probabilities), can I have access to them?
Yes. All you need to do is to define an environment variable WRITE_POSTERIORS and set it to 1. For example, in tcsh or csh:
setenv WRITE_POSTERIORS 1
Or, in bash:
Then, the software will write a (big!) bunch of files under the subject's mri directory, with the format: posterior_*.mgz
This module is CPU hungry
Indeed! The deformation of the atlas towards the input scan(s) is parallelized, and uses by default as many threads as available cores. If you want to limit the number of cores / threads that are used, you can do that through the environment variable ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS. For example, to use two cores (tcsh/csh):
setenv ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS 2
Or, in bash:
What are the computational requirements to run this module?
If the input is just a standard resolution (1mm) T1 from the main FreeSurfer pipeline (i.e., no additional scans), then the software requires approximately 8GB of RAM memory to run. If a higher resolution T1 is processed with the flag -cm, or additional scans are used, then the exact amount of required RAM memory depends on the size and resolution of the scans.
The volume of the whole thalamus 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! The reason for this is that the volumes correspond to two different analyses. We have found the estimates from this module to be slightly more accurate than FreeSurfer's in an Alzheimer's disease discrimination task (see paper).
What image formats are supported for the additional scan?
For now this software supports Nifti (.nii/.nii.gz) and FreeSurfer format (.mgh/.mgz).
Do you store the transform between the original additional volume and the FreeSurfer coordinate space?
Yes. It is in the subject's mri/transforms directory, with the name: <analysisID>.<bbRegisterMode>.lta.
The registration between the T1 and the additional scan failed, i.e., the T1 and <analysisID>.FSspace.mgz do not overlap when I open them in Freeview
This means that bbregister failed; it is very unusual, but it can happen, particularly if the input additional scan and the T1 are not approximately registered in first place. In that case, you have two options: 1. pre-registering the images yourself with your favorite registration tool, and re-running the thalamic segmentation with BBREGISTER_MODE set to none; and 2. manually (and coarsely) aligning the additional scan to the T1 (without resampling, please!) and re-running the analysis - if you use Freeview (recommended), you can use Tools -> Transform Volume to manually register the images, then hit the "save as" button and check the option "Do not resample voxel data when saving"
How can I quickly check whether the registration has failed?
In the subject's mri/transforms directory, the software writes an animated gif (T1-<analysisID>.<bbRegisterMode>.QC.gif) that can be used as quality control. It flips back and forth between a central coronal slice in the T1 scan and its corresponding slice in the T2 scan. If the two images are not aligned, the problem can be fixed by prealigning the additional scan to the T1 scan, as explained above.
How reliable are the the volumes estimated from standard resolution (1 mm) T1 data?
The main image feature when subdiving the thalamus is the boundary between the mediodorsal and pulvinar nuclei, and all other nuclei. This boundary is faint, but visible in most T1 scans. Other than this internal boundary and the external edge of the thalamus, the segmentation needs to rely on prior knowledge encoded in the atlas. We have found the segmentations to be quite consistent, except for the lateral and medial geniculate nucle (LGN/MGN), which are surrounded by cerebral white matter and exhibit little contrast.
Do the volume of thalamic nuclei need to be corrected for ICV (either by including ICV as a covariate or taking the ratio of each nucleus to the ICV)? If so, might it make more sense to correct them (perhaps take the ratio of each subfield to the whole thalamus) for the volume of the thalamus (after the thalamus itself has been corrected for the ICV)?
Yes, volumes of thalamic nuclei need to be corrected for ICV. If you’re correcting the nuclei by whole thalamic volume: a) the question is a different one (“which fraction of the thalamic volume is attributed to each nucleus”); and b) I would not correct by ICV, because the values are already fractions / normalized (see point a).
Does this module have a multispectral mode, i.e., processing the T1 and additional scans simultaneously?
No. We conducted some experiments and using both images simultaneously did not seem to help much, compared with using the additional volume alone.
Can this module exploit structural connectivity information derived from diffusion MRI to parcellate the thalamus?
Most of our efforts so far have been targeted at building the atlas from histological data, so for now we are basing the segmentation on our previously developed methods for the hippocampus, amygdala and brainstem. However, using diffusion is a great idea, and we will definitely explore this direction in the future.
6. Test data
Coming soon ...