Anatomical registration between sessions

Hello,

I am currently working on a reproducibility study, and I scan the same subject 1-2 weeks apart. For my study, I need to create a cervical spinal cord ROI that is the same for both scans. To do this, I am trying to register the t2 image from the first scan to the t2 image from the second scan and then segment the registered images.

I have been playing around with different parameter arguments and have gotten okay registration results using labels but it’s still not perfect. The command that I am currently using is as follows:

sct_register_multimodal -i 2_t2.nii.gz -d t2.nii.gz -iseg 2_t2_seg.nii.gz -dseg t2_seg.nii.gz -ilabel 2_t2_seg_labeled.nii.gz -dlabel t2_seg_labeled.nii.gz -m mask_t2.nii.gz -param step=0,type=label,dof=Tx_Ty_Tz_Rx_Ry_Rz:step=1,type=seg,algo=affine

ezgif.com-gif-maker

I was just wondering if anyone had any suggestions on parameter arguments that would make this registration better.

Here is the necessary data.

Thank you!

Hi @acronin96,

Thank you for your question!

Before giving a full answer, I just wanted to mention that the data archive above seems to be missing the file “mask_t2.nii.gz” (as referenced in the command above). Could you please share this file as well?

Thank you kindly,
Joshua

@joshuacwnewton

Oh no, sorry about that! Here is the data folder that also includes the “mask_t2.nii.gz ” file.

Alicia

1 Like

Sorry for the late reply. While working on a solution, we discovered this bug, which is now fixed. So, to be able to use the proposed solution below, you will need to install the development version of SCT (“master” branch). If you are already working with the development version, you just need to go in SCT’s repository and run:

git pull

So, here is the proposed solution. The idea to register two scans that are acquired at two different sessions is to use the disc labels as a first ‘approximate’ registration, and then use the spinal cord segmentations for the refined registration. Here is the command:

sct_register_multimodal -i scan1/t2.nii.gz -iseg scan1/t2_seg.nii.gz -ilabel scan1/t2_seg_labeled_discs.nii.gz -d scan2/2_t2.nii.gz -dseg scan2/2_t2_seg.nii.gz -dlabel scan2/2_t2_seg_labeled_discs.nii.gz -param step=0,type=label,doi=Tx_Ty_Tz_Rx_Ry_Rz:step=1,type=seg,algo=centermassrot

When running with flag -v 2, it outputs intermediate registration results. An interesting one is the label-based registration, showing the source (red), destination (green cross) and registered (blue) disc labels:

Here is the result of the registration for the data you shared:
anim

And here are some QC reports, showing some of the commands I tried (the first one is the “winner”).

Great, thank you so much for taking the time to look at this!

Alicia

Hi Julien,

I am also trying to register anatomical T2 images from 2 different sessions. For I’d say half of the participants, your suggested parameters work very well. But for a lot of images, the output spinal cord appears ‘twisted’ in the XY plane. This is the command I’ve been using to register my POST to my PRE session :

sct_register_multimodal -i /sub-CTS05/ses-SPpost/anat_5960/sub-CTS05_ses-SPpost_T2w_crop_08iso.nii.gz -iseg /sub-CTS05/ses-SPpost/anat_5960/sub-CTS05_ses-SPpost_T2w_deepseg_08iso.nii.gz -ilabel /sub-CTS05/ses-SPpost/anat_5960/reg2refanat/sub-CTS05_ses-SPpost_T2w_deepseg_labeled_commonverts_prepost.nii.gz -d /sub-CTS05/ses-SPpre/anat_5960/sub-CTS05_ses-SPpre_T2w_crop_08iso.nii.gz -dseg /sub-CTS05/ses-SPpre/anat_5960/sub-CTS05_ses-SPpre_T2w_deepseg_08iso.nii.gz -dlabel /sub-CTS05/ses-SPpre/anat_5960/reg2refanat/sub-CTS05_ses-SPpre_T2w_deepseg_labeled_commonverts_prepost.nii.gz -param step=0,type=label,doi=Tx_Ty_Tz_Rx_Ry_Rz:step=1,type=imseg,algo=centermassrot,rot_method=pcahog -o /sub-CTS05/ses-SPpost/anat_5960/reg2refanat/sub-CTS05_ses-SPpost_T2w_crop_inrefanat_pcahog.nii.gz -owarp /sub-CTS05/ses-SPpost/anat_5960/reg2refanat/warp_anat2refanat_pcahog.nii.gz -x spline

I’ve tried different rotation methods, of which pcahog is the best, but still not quite satisfactory towards the cauda equina. Here is a gif showing 3 ouputs when trying :
1/ centermassrot (imseg type) algorithm with pcahog
2/ centermassrot (imseg type) algorithm with hog (equivalent to default pca in terms of twisted output),
3/ centermass (seg type)
Capture vidéo du 2024-06-06 17-21-46

I have also tested the other algorithms without any luck. Do you have an idea on how to handle this registration ? Here are the files to test it if you’d like.

Thanks !

@raphaschl, I’ve tried a couple of combinations, but unfortunately I was not able to obtain a satisfactory co-registration between the two scans. Here is a QC of my investigations. I’ve notably tried to re-segment the spinal cord using the latest deepseg model, but it didn’t completely solve the issue.

I have some ideas to improve the co-registration, notably by revisiting the HOG algorithm, using mask around the cord, but it would require me spending a significant amount of time to implement these new features, and unfortunately I do not have that time right now.

Thank you for taking the time to give it a try. I’ll look into what you’re suggesting :relieved:

Hey, I also realized that when implementing a first step based on vertebral labels with the parameters you mentioned : step=0,type=label,dof=Tx_Ty_Tz_Rx_Ry_Rz, the code outputs :

Parameter ‘algo=syn’ has no effect for ‘type=label’ registration.

It seems this message appears for all algorithms, and the labels are still taken into account, is this normal ?

It seems this message appears for all algorithms, and the labels are still taken into account, is this normal ?

Yes, normal. You can ignore

1 Like

Hi ! I think we’ve found a solution : @jsein suggested trying the niftyreg package, and initializing the non-linear registration with an affine transform beforehand. It works like a charm ! I will try and see if it works for all the participants I’ve had trouble coregistering.

# linear registration post 2 pre
reg_aladin -ref sub-CTS05_ses-SPpre_T2w_crop_08iso.nii.gz -flo sub-CTS05_ses-SPpost_T2w_crop_08iso.nii.gz -res sub-CTS05_ses-SPpost_T2w_crop_inrefanat_niftyreg.nii.gz -aff affinetrans_sub-CTS05_ses-SPpost_T2w_crop_inrefanat_niftyreg.txt
# non-linear registration post 2 pre, initialized with the linear affine transform
reg_f3d -ref sub-CTS05_ses-SPpre_T2w_crop_08iso.nii.gz -flo sub-CTS05_ses-SPpost_T2w_crop_08iso.nii.gz -res sub-CTS05_ses-SPpost_T2w_crop_inrefanat_niftyreg.nii.gz -aff affinetrans_sub-CTS05_ses-SPpost_T2w_crop_inrefanat_niftyreg.txt -cpp cpp_sub-CTS05_ses-SPpost_T2w_crop_inrefanat_niftyreg.nii
1 Like

I agree. I’ve just tried these commands and the registration quality is excellent. Thank you for sharing @raphaschl !

I would just be careful with the non-linear registration, which seems to be highly sensitive to bias field, and generates spurious deformation. See below (SPpre, SPpost_aladin, SPpost_aladin-f3d)

ezgif-7-847fb8e656

Yes noted ! The above commands worked on all subjects but one. For it to work on that tricky subject, we added -nac -ln 12 -lp 10 to the reg_aladin command, as follows :

reg_aladin -ref sub-CTS06_ses-SPpre_T2w_crop_08iso.nii.gz  -flo sub-CTS06_ses-SPpost_T2w_crop_08iso.nii.gz -res test.nii.gz -nac -ln 12 -lp 10
reg_f3d -ref sub-CTS06_ses-SPpre_T2w_crop_08iso.nii.gz -flo sub-CTS06_ses-SPpost_T2w_crop_08iso.nii.gz -res test.nii.gz -aff outputAffine.txt

Also, the version of niftyreg used seems quite important : with a 1.3.x version, these parameters still didn’t help. But after updating to 1.5.7 on Unix, the output was really satisfactory ! And interestingly, slightly different (I would say not as good) as with @jsein’s 1.5.30 version on Mac.

1 Like

Hi,

On a complementary note, when using niftyreg v1.5.69, as it is available on NeuroDesk, identical results are obtained as with niftyreg v1.5.30 on a mac.

1 Like