DTI PAM50 template registration

Hi Julien,

I am working on spinal cord DTI images acquired as sagittal images. I find the registration to PAM50 template is not as good as expected (attached are the outputs)
Can you let me know how I can improve the registration?
How can I send you the data- I can’t seem to be able to upload the DTI scan?

Thanks,
Aditya

SCRIPT:

sct_propseg -i t2.nii.gz -c t2 -qc ~/qc_DTI_Cordotomy

sct_deepseg_sc -i t2.nii.gz -c t1 -ofolder deepseg -qc ~/qc_DTI_Cordotomy

———————

sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -qc ~/qc_DTI_Cordotomy

# If automatic labeling did not work, you can initialize with manual identification of C2-C3 disc:

sct_label_utils -i t2.nii.gz -create-viewer 3 -o label_c2c3.nii.gz -msg "Click at the posterior tip of C2/C3 inter-vertebral disc"

sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -initlabel label_c2c3.nii.gz -qc ~/qc_DTI_Cordotomy

—————————————

sct_label_utils -i t2_seg_labeled.nii.gz -vert-body 3,9 -o t2_labels_vert.nii.gz

sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l t2_labels_vert.nii.gz -c t2 -qc ~/qc_DTI_Cordotomy

sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -qc ~/qc_DTI_Cordotomy

——————————————

# Compute mean dMRI from dMRI data

sct_maths -i dmri.nii.gz -mean t -o dmri_mean.nii.gz

# Segment SC on mean dMRI data

# Note: This segmentation does not need to be accurate-- it is only used to create a mask around the cord

sct_propseg -i dmri_mean.nii.gz -c dwi -qc ~/qc_DTI_Cordotomy

# Create mask (for subsequent cropping)

sct_create_mask -i dmri_mean.nii.gz -p centerline,dmri_mean_seg.nii.gz -size 35mm

# Crop data for faster processing

sct_crop_image -i dmri.nii.gz -m mask_dmri_mean.nii.gz -o dmri_crop.nii.gz

# Motion correction (moco)

sct_dmri_moco -i dmri_crop.nii.gz -bvec bvecs.txt

# Segment SC on motion-corrected mean dwi data (check results in the QC report)

sct_propseg -i dmri_crop_moco_dwi_mean.nii.gz -c dwi -qc ~/qc_DTI_Cordotomy

# Register template->dwi via t2s to account for GM segmentation

sct_register_multimodal -i dmri_crop_moco_b0_mean.nii.gz -iseg dmri_crop_moco_dwi_mean_seg.nii.gz -d t2.nii.gz -dseg t2_seg.nii.gz -param step=1,type=seg,algo=slicereg,smooth=5:step=2,type=im,algo=syn,metric=CC,smooth=0,slicewise=0,iter=3 -qc ~/qc_DTI_Cordotomy

# Rename warping fields for clarity

mv warp_PAM50_t12dmri_crop_moco_dwi_mean.nii.gz warp_template2dmri.nii.gz

mv warp_dmri_crop_moco_dwi_mean2PAM50_t1.nii.gz warp_dmri2template.nii.gz

# Warp template

sct_warp_template -d dmri_crop_moco_dwi_mean.nii.gz -w warp_template2dmri.nii.gz -qc ~/qc_DTI_Cordotomy

# Check results in the QC report

Hi @AdiVeeMiami,

Thank you for reaching out.

The spinal cord segmentation likely has some issues. Could you please show the QC of the segmentation in this forum thread?

If you need to send me data, you can do so via an upload to dropbox/googledrive and send me the link. You can use my email if these are private data.

Cheers,
Julien

I sent you a link to the data via google drive.

Here is the segmentation data- I used deepseg instead of propseg for this screnshot.

Hi @AdiVeeMiami,

Thank you for sending me your data. First of all, there are a few issues with the data themselves:

  • The t2.nii.gz is oriented axially. While it is of a reasonable quality, you use it to identify vertebral levels. I would suggest to use a sagittal (or isotropic resolution) image for that task.
  • The DWI data are acquired in the sagittal plane, and the slice thickness is 3.5mm. Given that the spinal cord is about 1cm large in the R-L direction, it gives only 1-2 slices in the cord without strong partial volume effect, inducing bias in DTI metrics and tractography performance.
  • The DWI data are very noisy below ~C7, making any DTI metric unreliable.
  • The DWI data are hampered by susceptibility artifacts (distortions). It is fairly unusual to prescribe phase-encoding in the head-foot direction.
  • The “bvecs.docx” file you sent should be in text file, not a microsoft docx file. So I had to manually copy/paste the content into a new txt file, and transpose the bvec table. Here is the file: bvec_t.txt (1.8 KB)

And a few comments on your commands:

  • you used sct_deepseg_sc -i t2.nii.gz -c t1, but for a T2w contrast, you should use flag -c t2
  • Your pipeline includes a registration of the T2w to the PAM50, and then a registration of the T2w to the DWI, however you forgot to use the intermediate warping field (template → T2) as an initial transformation for sct_register_multimodal. So what you effectively did was: register the template to the T2, then the T2 to the DWI, and then you applied the template2T2 warping field to the DWI data. Then, you renamed warping fields which were never created in the first place.
  • Related to the previous point: why are you registering the PAM50 to the T2w image in the first place? If you are only interested in the DWI data, then you can simply run sct_register_to_template on the DWI data. See my commands below.
  • sct_maths -i dmri.nii.gz -mean t -o dmri_mean.nii.gz: you used that syntax to perform a first segmentation. But given the very noisy data, i strongly suggest to instead separate the b=0 and DWI data, average the DWI data and then segment the cord. See my script below.
  • vertebral labeling: you specified 3,9. As mentioned above, below C6 the DWI data are too noisy, so i would recommend to focus on C3-C6.

When copy/pasting commands from example scripts (here I assume you borrowed code from the example batch_processing.sh script), it is very important to understand every step. I strongly recommend to spend some time on the latest SCT course.

Now, here the script I used on your data:

# Segment the cord on the T2w image
sct_deepseg_sc -i t2.nii.gz -c t2 -qc ~/qc_DTI_Cordotomy
# Label vertebral levels on the T2w image
sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -qc ~/qc_DTI_Cordotomy/
# Perform motion correction. Note: here we use "group=1" because these are sagittal images (ie: it does not make sense to group slices across time).
sct_dmri_moco -i dmri.nii.gz -bvec bvec_t.txt -g 1
# Segment the cord on the averaged DWI data
sct_deepseg_sc -i dmri_moco_dwi_mean.nii.gz -c dwi -qc ~/qc_DTI_Cordotomy
# Resample the vertebral levels in the DWI space (no optimization, simple resampling with nearest neighbor interpolation)
sct_register_multimodal -i t2_seg_labeled.nii.gz -d dmri_moco_dwi_mean.nii.gz -x nn -identity 1 -qc ~/qc_DTI_Cordotomy
# Extract labels corresponding to C3 and C6
sct_label_utils -i t2_seg_labeled_reg.nii.gz -vert-body 3,6 -o dmri_labels.nii.gz
# Register PAM50 template to DWI image. Note: here we use the "t1" contrast as it is similar to the mean DWI image.
sct_register_to_template -i dmri_moco_DWI_mean.nii.gz -s dmri_moco_dwi_mean_seg.nii.gz -l dmri_labels.nii.gz -c t1 -qc ~/qc_DTI_Cordotomy/ 
# Warp template
sct_warp_template -w warp_template2anat.nii.gz -d dmri_moco_dwi_mean.nii.gz -qc ~/qc_DTI_Cordotomy/

Here is the QC report: qc_DTI_Cordotomy.zip (1.9 MB)

And here is the warped WM atlas:

Note that I am not showing the slices below ~C6, because as mentioned above, the combination of thick slices and high noise amplitude made the automatic segmentation difficult, and therefore the realignment unreliable. However, if you still want to use data below C6, I suggest you manually correct the segmentation and you will be able to obtain good registration results afterwards.

Also note that in the picture above, the blueish overlay represent the spinal white matter (not the spinal cord), so it is expected to see some “holes” in the middle.

:warning: While working with your data, I noticed a bug in SCT. Fortunately I was able to fix it quickly. In order to benefit from this fix, you will need to install the master version of SCT (using git). Installation instructions here. If you prefer, you can also wait for the next stable release which will include the fix.

Cheers,
Julien

1 Like

Julien, Thank you for the detailed response.
I have been working with SCT for a few months and will go through the SCT course presentation once more.

1 Like