Sct_register_to_template problem with multiple disc labels (sct_4.0.1)

Dear SCT experts,

I am facing a problem while using the command sct_register_to_template.

I just call the command like this: sct_register_to_template -i T2.nii.gz -s T2_seg.nii.gz -ldisc T2_seg_labeled_discs_edited.nii.gz I created the labeled_discs by using sct_label_vertebrae command (which work quite well). I have 8 labels in this nifti file (from 2 to 9).

When I run the command I get the following error:


Straighten the spinal cord using centerline/segmentation…

Create temporary folder (/tmp/sct-20190903104329.637122-straighten_spinalcord-etincqvm)…

Copy files to tmp folder…
Create the straight space and the safe zone
Length of spinal cord: 134.47821556475964
Size of spinal cord in z direction: 127.99999999985897
Ratio length/size: 1.0506110591008422
Safe zone boundaries (curved space): [-86.1999969487103, 41.80000305114868]
Safe zone boundaries (straight space): [-89.43910473116063, 45.03911083359901]
Traceback (most recent call last):
File “/home/willi/sct_4.0.1/scripts/”, line 871, in
File “/home/willi/sct_4.0.1/scripts/”, line 437, in main
File “/home/willi/sct_4.0.1/spinalcordtoolbox/”, line 218, in straighten
centerline_straight = _get_centerline(image_centerline_straight, algo_fitting,, verbose)
NameError: name ‘algo_fitting’ is not defined "

When I just give one label instead of 8, function runs without any errors.

Before switching to 4.0.1, I was using 4.0.0- beta 5 and I did not have this problem.
Should I straighten the cord first, and then use this as an input ?

Thanks a lot!


Hi Merve,

I can reproduce this issue. We have opened a ticket here and will address this bug with top priority.

Thank you very much for reporting this issue.


Thank you very much!


Hi @Merve,

The issue has been fixed in this new SCT release 4.0.2.


Dear Dr Cohen-Adad

Thank you very much!