Samseg (cross-sectional, longitudinal, MS lesions)

This functionality is available in FreeSurfer 7, with gradual improvements appearing in the development version.

Author: Koen Van Leemput

E-mail: koen [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: ThalamicNuclei, HippocampalSubfieldsAndNucleiOfAmygdala, BrainstemSubstructures


Contents

  1. General description
  2. Basic SAMSEG (cross-sectional processing)
  3. SAMSEG in multiple sclerosis (cross-sectional processing)
  4. Longitudinal processing with SAMSEG


1. General description

Sequence Adaptive Multimodal SEGmentation (SAMSEG) is a tool to robustly segment dozens of brain structures from head MRI scans without preprocessing. The characteristic property of SAMSEG is that it accepts multi-contrast MRI data without prior assumptions on the specific type of scanner or pulse sequences used. Dedicated versions to handle longitudinal data, or to segment white matter lesions in multiple sclerosis (MS) patients are also available.

The figure below illustrates a typical SAMSEG segmentation result on a T1w-FLAIR scan of a MS patient:
3D_small.png

2. Basic SAMSEG (cross-sectional processing)

In its most basic form SAMSEG takes one or more co-registered MRI volumes as input, and produces an output segmentation in around 10 min on a good desktop computer (with multi-threading enabled). Preprocessing of the scan(s) with FreeSurfer is neither required nor recommended (e.g., no reformatting to 1mm isotropic resolution, no bias field correction and no skull stripping is needed nor recommended). The command line is:

run_samseg --input <file> [<file> ...] --output <dir> [--threads <threads>] [--pallidum-separate] 

where:

The output will consist of the following set of files, which can be found under the specified <dir> directory:

Running

run_samseg --help

will display instructions for using more advanced options, including the ability to save the full probabilistic ("soft") segmentations and skipping the initial subject-to-atlas affine registration step.

Examples:

Segment a single T1w scan using a single CPU core (e.g., for running on a cluster):

run_samseg --input /home/username/data/t1.nii --output /home/username/data/samsegOutput/ 

Segment a single T1w scan with 8 CPU cores:

run_samseg --input /home/username/data/t1.nii --output /home/username/data/samsegOutput/ --threads 8

Segment a subject with both T1w and a FLAIR scan (provided both scans are co-registered and have the same image grid size and voxel resolution -- see below) using 4 threads:

run_samseg --input /home/username/data/t1.nii /home/username/data/flair.nii --pallidum-separate --output /home/username/data/samsegOutput/ --threads 4

Co-registering multi-contrast data:

When giving multi-contrast data as input, SAMSEG expects that all contrasts have already been co-registered and reformatted to the same image grid. To avoid loss of information, it is recommended to select the contrast with the highest spatial resolution (smallest voxel size) and reformat all other contrasts to that.

FreeSurfer comes with a set of tools to perform accurate inter-modality co-registration and reformatting. For instance, given a 1x1x1mm3 T1w scan "t1.nii" and a 1x1x3mm3 FLAIR "flair.nii", coregistering and reformatting the FLAIR to the T1w can be accomplished using:

mri_coreg --mov flair.nii --ref t1.nii --reg flairToT1.lta
mri_vol2vol --mov  flair.nii  --reg flairToT1.lta  --o flair_reg.nii --targ t1.nii

(See mri_coreg and mri_vol2vol for the full documentation of these tools.)

SAMSEG can then be called using e.g.,

run_samseg --input t1.nii flair_reg.nii --pallidum-separate --output samsegOutput/ 


3. SAMSEG in multiple sclerosis (cross-sectional processing)

SAMSEG comes with a dedicated extension to explicitly segment white matter lesions in multiple sclerosis patients. To use it, you need to invoke SAMSEG with the following additional flags:

When doing a study comparing MS patients with controls, you should use the same SAMSEG command to process both patient groups -- SAMSEG with the lesion flag enabled should work robustly even in subjects with no white matter lesions.

The first time you run this module, you may be prompted to install Tensorflow. Simply follow the instructions on 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 additional libraries (GPU driver, Cuda, CuDNN). These libraries are generally required for a GPU, and are not specific for this tool.

Examples:

Segment an MS subject with both a T1w and a FLAIR scan (provided both scans are co-registered and have the same image grid size and voxel resolution -- see above) using a single core:

run_samseg --input /home/username/data/t1.nii /home/username/data/flair.nii --pallidum-separate --lesion --lesion-mask-pattern 0 1 --output /home/username/data/samsegOutput/ 

Segment an MS subject with a T1w, a FLAIR and a PDw scan (provided all scans are co-registered and have the same image grid size and voxel resolution -- see above) using 8 CPU cores and a lesion threshold of 0.7:

run_samseg --input /home/username/data/t1.nii /home/username/data/flair.nii /home/username/data/pd.nii --pallidum-separate --lesion --lesion-mask-pattern 0 1 0 --threshold 0.7 --output /home/username/data/samsegOutput/ --threads 8


4. Longitudinal processing with SAMSEG

A special version of SAMSEG is available for processing longitudinal scans, i.e., repeated scans of the same subject taken at subsequent time points. In contrast to the cross-sectional setting where each image is treated independently, longitudinal SAMSEG exploits the fact that all images belong to the same subject to produce more consistent segmentations, which should make it easier to detect group differences in temporal trajectories of brain morphology.

Longitudinal SAMSEG is very generally applicable, as it does not make any prior assumptions on the scanner, the MRI protocol, or the number and timing of longitudinal follow-up scans. An example longitudinal segmentation is shown in the figure below (six time points, labeled as tp1 ... tp6):
segExamplev4_small.png

Preprocessing and invoking longitudinal SAMSEG:

As in the cross-sectional version, longitudinal SAMSEG expects all its input images to have been co-registered and reformatted to the same image grid beforehand. However, in longitudinal processing, special attention should be paid to avoid biases resulting from not treating all time points in exactly the same way (e.g., simply reformatting all follow-up time points to the baseline scan would introduce a longitudinal processing bias). Given e.g., a longitudinal T1w scan acquired at three time points, with respective file names "tp0_t1.nii", "tp1_t1.nii" and "tp2_t1.nii", the following FreeSurfer command will compute a robust representation of the average subject anatomy over time, and use that as an unbiased reference to register all time points to:

mri_robust_template --mov tp0_t1.nii tp1_t1.nii tp2_t1.nii --template mean.mgz --satit --mapmov tp0_t1_reg.mgz tp1_t1_reg.mgz tp2_t1_reg.mgz

(See mri_robust_template for the full documentation of this tool.) The resulting files "tp0_t1_reg.mgz", "tp1_t1_reg.mgz" and "tp2_t1_reg.mgz" can now be used to invoke longitudinal SAMSEG as follows:

run_samseg_long --timepoint tp0_t1_reg.mgz --timepoint tp1_t1_reg.mgz --timepoint tp2_t1_reg.mgz --output outputDir/

This will create three subdirectories in the output directory named "timepoint0", "timepoint1" and "timepoint2" with the same structure as the one obtained with cross-sectional SAMSEG.

Similar advanced options are available for the longitudinal SAMSEG as for the cross-section version; more instructions are provided by typing:

run_samseg_long --help


Longitudinal SAMSEG with multi-contrast data

Taking the same example above (longitudinal T1w scan taken at three time points) but with additional FLAIR scans named "tp0_flair.nii", "tp1_flair.nii" and "tp2_flair.nii", preprocessing would proceed as described above (i.e., generating "tp0_t1_reg.mgz", "tp1_t1_reg.mgz" and "tp2_t1_reg.mgz"), but then for each time additionally co-registering each FLAIR scan to the corresponding reformatted T1w scan. For example, for the first time point this can be accomplished by using:

mri_coreg --mov tp0_flair.nii --ref tp0_t1_reg.mgz --reg tp0_FLAIRtoT1.lta
mri_vol2vol --mov tp0_flair.nii --reg tp0_FLAIRtoT1.lta --o tp0_flair_reg.mgz --targ tp0_t1_reg.mgz

SAMSEG is then invoked by simply listing the reformatted FLAIR as an additional contrast for each time point:

run_samseg_long --timepoint tp0_t1_reg.mgz tp0_flair_reg.mgz --timepoint tp1_t1_reg.mgz tp1_flair_reg.mgz --timepoint tp2_t1_reg.mgz tp2_flair_reg.mgz --output outputDir/

In the above it is assumed that the T1w scans have a higher spatial resolution than the FLAIR. If this is not the case in your data, it is recommended to swap the role of FLAIR and T1 in the preprocessing.

If additional contrasts are available, these can simply be appended to the input lists after applying the same co-registration steps. Note that SAMSEG expects that the same combination of contrasts is provided for each time point, though.

Longitudinal SAMSEG for MS patients

In the development version of FreeSurfer, segmenting white matter lesions in MS with longitudinal SAMSEG is accomplished simply by adding the same flags as for the cross-sectional version (see section 3 above).

Warning: This functionality is only available in the development version, not in FreeSurfer 7!

Samseg (last edited 2021-01-08 06:47:54 by KoenVanLeemput)