Skip to content
AurelieBussy edited this page Aug 15, 2022 · 17 revisions

Overview

T1w/T2w ratio has been used as a myelin index (Glasser et al., 2011; Shams et al., 2019).

Be careful : T1w/T2w ratio value is not only related to myelin content but also to other molecules such as iron.

T1w and T2w images are ones of the few most standard MRI images, which makes this metric relatively easy to obtain a measure of myelin.

1. Creating the T1w/T2w image

1.1. Register T2w to T1w and save this transformation.

bestlinreg_g -nmi -lsq6 T2.mnc T1.mnc transform.xfm

1.2. Use transform.xfm file to resample T2w in T1w image space.

mincresample -like T1.mnc -sinc -short -unsigned -transform transform.xfm T2.mnc T2_lsq6.mnc

1.3. Calculate the T1w/T2w ratio at each voxel to create the T1w/T2w ratio image.

minccalc -expression "(A[0]>0.05*$(mincstats -quiet -max T1.mnc) && A[1]>0.05*$(mincstats -quiet -max T2_lsq6.mnc))?A[0]/A[1]:0" T1.mnc T2_lsq6.mnc ratio.mnc

2. Filtering the ratio values using a mask

Important: Whether the goal is to only extract the ratio values for a certain structure (i.e. globus pallidus) or to extract the ratio values for the whole brain, it will be necessary to use the appropriate mask ( in this wiki, "mask" can refers either to wholebrain maks, MAGeT labels or other binary mnc file and is sometimes used interchangeably with "label") of the desired structure for each subject.

The script used in later step requires one folder per subject. The subject folder name should be names based on the ID of the subject and each folder should initially store 2 files (or more if there are more than one mask used): the T1w/T2w ratio image and the mask file for the corresponding subject. Any outputs should also be stored in their corresponding subject specific folders seeing as the script runs on a per subject basis (1 job per subject).

(Steps developed by Rai; see /data/chamal/projects/raihaan/projects/misc/t1t2-ratio/filter_instructions for detailed instructions.

From Glasser & Van Essen, 2011: Method for correcting aberrant T1w/T2w values “Each vertex’s cortical thickness and T1w/T2w values were compared with the mean values of the neighbors within 10 steps across the surface. If the values of both the cortical thickness and the T1w/T2w exceeded 2 SDs from the mean, it was assumed that an error had occurred in surface reconstruction and thus the data were unreliable. These values were replaced by a Gaussian-weighted average of their neighbors using a geodesic distance weighting. Only vertices having cortical thickness values and T1w/T2w values <2 SDs from the mean were included in the Gaussian weighted average.”

2.1. Create a folder structure for all subjects:

2.1.1. Create a subject folder for each subject

mkdir subjectID

2.1.2. Transfer the T1w/T2w ratio images into their corresponding subject folder

cp subjectID_ratio.mnc subjectID/

2.1.3. Transfer the masks into their corresponding subject folder

cp subjectID_mask.mnc subjectID/

2.2. Normalize the mask range

Nedded to ensure that mask 1 doesn’t end up as 1.01 in future conversion.

mincreshape -normalize -unsigned -byte -image_range 0 255 -valid_range 0 255 mask.mnc mask_fix.mnc

2.3. Check the dimension of the ratio and the mask file.

mincinfo ratio.mnc

mincinfo mask_fix.mnc

2.4. If they are not the same at this stage, the dimensions need to be changed.

module load ANTs

antsApplyTransforms -d 3 -i ratio.mnc -r mask_fix.mnc -o ratio_cropped.mnc

2.5. Convert all mnc files to nii file format

mnc2nii mask_fix.mnc mask_fix.nii

mnc2nii ratio_cropped.mnc ratio_cropped.nii

2.6. Create a lookup .csv table with mask number and structure name

See example: /data/chamal/projects/raihaan/projects/misc/t1t2-ratio/label_lookup.csv. The column names must be the same as those used in this example .csv

To visualise it on the terminal:

cat /data/chamal/projects/raihaan/projects/misc/t1t2-ratio/label_lookup.csv

(example if the mask used is a label of the left and right globus pallidus)

Label_val, Label

2, left_gp_lb

5, right_gp_lb

2.7. Make a copy of Rai’s filtering script in your working directory

cp /data/chamal/projects/raihaan/projects/misc/t1t2-ratio/generic_t1t2_filter.py .

2.8. Run script generic_t1t2_filter.py on each subject

module unload minc-toolkit

module load anaconda qbatch

for subj in *HA*; do echo python generic_t1t2_filter.py --resn 0.64 --lookup labels_subcort.csv --subjdir $subj --t1t2_stem ratio.nii.gz --label_stem labels.nii.gz --left_gp_lb 2 --right_gp_lb 5; done > filterjobs

      It assumes the files in a given folder pertain to 1 subject. Required inputs:

      --resn resolution of T1w/T2w files
 
      --lookup .csv lookup table with label,structure name 

      --subjdir path to directory containing subjects files. this folder should contain 2 files: nifti t1t2 image and a nifti label for the given subject

      --t1t2_stem suffix of T1w/T2w image - so it knows which file in subjdir is the T1w/T2w image

      --label_stem suffix of label file - so it knows which file in subjdir is the label_file
      
      Optional Inputs:
      --left_gp_lb the label value for the left gp, if included in label set
      --right_gp_lb the label value for the right gp, if included in label set

As noted in the optional inputs, if your label set includes the globus pallidus you must include the appropriate option to specify the label values for the left and right gp. As the gp is a smaller structure, a slight modification to the smoothing parameters is required. If your label set does not include these structures, do not use the --left_gp_lb or --right_gp_lb options.

2.9. Submit jobs

qbatch -c 1 --ppj 2 -w 1:00:00 filterjobs

Please note: these settings that have worked when running about 100 Healthy Aging Subjects Can be very long if the label used is the wholebrain mask. In this case, run qbatch -c 1 --ppj 2 filterjobs

2.10. Get summary stats for all subjects (less meaningful if used wholebrain mask than structure-wise labels)

The generic_t1t2_filter.py script outputs two .csv files for each subject - one containing the mean t1/t2 in each structure and another containing the stdev of t1/t2 in each structure. Use bash to concatenate these for all subjects.

head -n1 subject1/subject1_meant1t2.csv > group_meant1t2.csv #Get the header for subj in allsubjectdirs; do tail -n1 $subj/"$subj"_meant1t2.csv; done >> group_meant1t2.csv

3) Extract vertex-wise T1w/T2w ratio values

It can be done at the cortex level using CIVET outputs or at the structure level using MAGeT morph outputs.

Look at https://github.com/CoBrALab/documentation/wiki/Surface-Sampling-Using-CIVET-surfaces for more details in how to do it.

4) Optional step : Create filtered ratio image

Create a new ratio images that contains only the T1w/T2w values (after filtering) for the structure(s) of interest.

3.0 Load modules

module load FSL

3.1. Invert labels

Will get label 0 only for the striatum (for example)

fslmaths labels.nii.gz -binv inverted-labels.nii.gz

3.2. Create ratio image with corrected t1w/t2w values in region of interest

fslmaths ratio.nii.gz -mul inverted-labels.nii.gz -add L_stri_filter.nii.gz ratio-filter.nii.gz

Note: L_stri_filter.nii.gz is the output of the generic_subcorticalfilter.py script (see above)

3.3 Create mnc version of filtered ratio image using the nii2mnc command

nii2mnc ratio-filter.nii.gz ratio-filter.mnc

Clone this wiki locally