Sct_register_to_template problem v 4.0.2

Dear SCT team,

I am trying to register my T2 images to the template and I am using the following command (I would like to skip step 2 and run the registration with default parameters of steps 0 and 1- this is why I manually define all the parameters).

sct_register_to_template -i T2.nii.gz -s DeepSeg_Smoothed/T2_smooth_seg.nii.gz -ldisc LabelVertebSmooth/T2_smooth_seg_labeled_discs_edited2.nii.gz  -param step=0,type=label,dof=Tx_Ty_Tz_Sz:step=1, type=seg, algo=centermass, metric=MeanSquares, iter=10, smooth=2, gradStep=0.5, slicewise=0,smoothWarpXY=2,pca_eigenratio_th=1.6 -ofolder RegsTmpSmooth_woStep2 -c t2 

It starts running but then I get the following error:

e[0m
Register straight spinal cord to template...e[0m
e[0m
Estimate transformation for step #1...e[0m
e[91mERROR: Wrong image type.e[0m
Traceback (most recent call last):
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_to_template.py", line 871, in <module>
    main()
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_to_template.py", line 598, in main
    warp_forward_out, warp_inverse_out = register(src, dest, paramreg, param, str(i_step))
UnboundLocalError: local variable 'src' referenced before assignment

Could you please help me with that?

Thanks a lot!

Best
Merve

Hi Merve,

type=label does not refer to disc labels, but to points which are used as a coarse pre-registration (e.g., to bring source image into destination image). This could be useful in case the two physical coordinate system are different your image to the template space, e.g., in case of subject repositioning between source and destination. When using this option, you need to provide your labels with the flags -ilabel and -dlabel.

In the case of registration to template, step=0 is dealt with internally using the provided discs, so you should not interfere with step=0.

if you want to remove step=2 (or add more steps), you can simply omit step=0 in the syntax, and by default it will use the disc labels for step=0. So, the syntax would look like:

sct_register_to_template -i T2.nii.gz -s DeepSeg_Smoothed/T2_smooth_seg.nii.gz -ldisc LabelVertebSmooth/T2_smooth_seg_labeled_discs_edited2.nii.gz  -param step=1, type=seg, algo=centermass, metric=MeanSquares, iter=10, smooth=2, gradStep=0.5, slicewise=0,smoothWarpXY=2,pca_eigenratio_th=1.6 -ofolder RegsTmpSmooth_woStep2 -c t2 

With this syntax, step=2 will not be run.

Note that with algo=centermass, the fields metric, iter, smooth, gradStep and slicewise which you have specified are not used.

Best,
Julien

Dear Dr Cohen-Adad,

Thank you very much for your reply and for the explanation.
Unfortunately, I encounter another problem right now. So I just copied the line you have sent and tried to run it.
Then I got the following error:

Folder RegsTmpSmooth_woStep2 has been created.
Please check parameter -param (usage changed from previous version)
Traceback (most recent call last):
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_to_template.py", line 871, in <module>
    main()
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_to_template.py", line 233, in main
    paramreg.addStep(paramStep)
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_multimodal.py", line 279, in addStep
    param_reg.update(stepParam)
  File "/home/raid2/mkaptan/sct_4.0.2/scripts/sct_register_multimodal.py", line 259, in update
    setattr(self, obj[0], obj[1])
IndexError: list index out of range

What could be the reason for this?

Thanks a lot!

Best
Merve

I suspect the segmentation and/or labels have a problem. Could you upload them here?

Sure! T2_smooth_seg_labeled_discs_edited2.nii.gz (223.7 KB)

Shall I send the T2 as well?
I got the error in 2 participants- not only this one.

Thank you,

Best
Merve

T2_smooth_seg.nii.gz (36.4 KB)

And here is the segmentation.

Hi Merve,

Sorry I didn’t notice there was a typo in the syntax: There should be no space separating each item of the -param flag. Instead of this:

sct_register_to_template -i T2.nii.gz -s DeepSeg_Smoothed/T2_smooth_seg.nii.gz -ldisc LabelVertebSmooth/T2_smooth_seg_labeled_discs_edited2.nii.gz  -param step=1, type=seg, algo=centermass, metric=MeanSquares, iter=10, smooth=2, gradStep=0.5, slicewise=0,smoothWarpXY=2,pca_eigenratio_th=1.6 -ofolder RegsTmpSmooth_woStep2 -c t2  

It should be this:

sct_register_to_template -i T2.nii.gz -s DeepSeg_Smoothed/T2_smooth_seg.nii.gz -ldisc LabelVertebSmooth/T2_smooth_seg_labeled_discs_edited2.nii.gz  -param step=1,type=seg,algo=centermass,metric=MeanSquares,iter=10,smooth=2,gradStep=0.5,slicewise=0,smoothWarpXY=2,pca_eigenratio_th=1.6 -ofolder RegsTmpSmooth_woStep2 -c t2 

Dr Dr Cohen-Adad,

I see, it works now. Thank you very much for your help, I did not notice the mistake I made!

Best
Merve