How to merge MNI and PAM50 template?

Now that the PAM50 and MNI templates are in the same physical space, it is possible to merge them in order to obtain a single image encompassing both templates, like this:

I was asked several times how to do it, so I though it would be useful to describe the recipe in this forum:

# Pad the MNI template
sct_image -i /usr/local/fsl/data/standard/MNI152_T1_0.5mm.nii.gz -pad-asym 0,0,100,0,300,0 -o MNI152_T1_0.5mm_pad.nii.gz
# Bring the PAM50_t1 template into the padded MNI space
sct_register_multimodal -i ${SCT_DIR}/data/PAM50/template/PAM50_t1.nii.gz -d MNI152_T1_0.5mm_pad.nii.gz -identity 1
# Scale the intensity of the PAM50 template to match that of the MNI template (signal value estimated at 160 in the white matter of the ICBM152_0.5 template)
sct_maths -i PAM50_t1_reg.nii.gz -div 6.25 -o PAM50_t1_reg_norm.nii.gz
# Mask the PAM50 above a given slice
sct_crop_image -i PAM50_t1_reg_norm.nii.gz -zmin 0 -zmax 310 -b 0 -o PAM50_t1_reg_norm_crop.nii.gz
# Mask the MNI template below the same slice
sct_crop_image -i MNI152_T1_0.5mm_pad.nii.gz -zmin 311 -zmax 644 -b 0 -o MNI152_T1_0.5mm_pad_crop.nii.gz
# Add the PAM50 to the padded MNI template image
sct_maths -i MNI152_T1_0.5mm_pad_crop.nii.gz -add PAM50_t1_reg_norm_crop.nii.gz -o MNI152-PAM50_T1_0.5mm.nii.gz
# And the magic happens!
fsleyes MNI152-PAM50_T1_0.5mm.nii.gz &

Of course you can also play with other field of view (i.e. extend the PAM50 further down), contrasts (T2, T2s) and resolution (1mm, 2mm) offered by the ICBM152 MNI template.

Cheers,
Julien

3 Likes

Update

SCT release 4.1.0 updated sct_crop_image. Indeed, -dim, -start and -end are now replaced by the min and max of each direction (xmin/xmax, ymin/ymax, zmin/zmax). Thus, the commands after release 4.1.0 are now (tested on release 5.5):

# Pad the MNI template
sct_image -i /usr/local/fsl/data/standard/MNI152_T1_0.5mm.nii.gz -pad-asym 0,0,100,0,300,0 -o MNI152_T1_0.5mm_pad.nii.gz

# Bring the PAM50_t1 template into the padded MNI space
sct_register_multimodal -i ${SCT_DIR}/data/PAM50/template/PAM50_t1.nii.gz -d MNI152_T1_0.5mm_pad.nii.gz -identity 1

# Scale the intensity of the PAM50 template to match that of the MNI template (signal value estimated at 160 in the white matter of the ICBM152_0.5 template)
sct_maths -i PAM50_t1_reg.nii.gz -div 6.25 -o PAM50_t1_reg_norm.nii.gz

# Mask the PAM50 above a given slice
sct_crop_image -i PAM50_t1_reg_norm.nii.gz -zmin 0 -zmax 310 -b 0 -o PAM50_t1_reg_norm_crop.nii.gz

# Mask the MNI template below the same slice
sct_crop_image -i MNI152_T1_0.5mm_pad.nii.gz -zmin 311 -zmax 644 -b 0 -o MNI152_T1_0.5mm_pad_crop.nii.gz

# Add the PAM50 to the padded MNI template image
sct_maths -i MNI152_T1_0.5mm_pad_crop.nii.gz -add PAM50_t1_reg_norm_crop.nii.gz -o MNI152-PAM50_T1_0.5mm.nii.gz

# And the magic happens!
fsleyes MNI152-PAM50_T1_0.5mm.nii.gz &

Of note, step 2 (sct_register_multimodal) is quite demanding (memory > 12Gb?!)

2 Likes

thank you for the community spirit, @mgaubert! this is appreciated. I have now edited the original post with your corrections.