Error when running sct_label_vertebrae

NeuroDebian system. SCT v.4.0.0.

Trying to practice SCT.
Pictures obtained from SCT course_20190808-Chinese (https://osf.io/hnmr2/).
t2_seg.nii.gz was copied in mt folder.

brain@neurodebian:~/Pictures/sct_course-beijing19/single_subject/data/mt$ sct_label_vertebrae -i mt1.nii.gz -s t2_seg.nii.gz -c t2 -qc ~/qc_singleSubj


Spinal Cord Toolbox (dev)

Folder /home/brain/qc_singleSubj has been created.

Create temporary folder (/tmp/sct-20191127023100.550457-label_vertebrae-ijnzn6hi)…

Copying input data to tmp folder…

Straighten spinal cord…

Create temporary folder (/tmp/sct-20191127023100.833659-straighten_spinalcord-9bhwralm)…

Copy files to tmp folder…
Window length needs to be >= 3. Returning input signal.
Window length needs to be >= 3. Returning input signal.
Fitting centerline using B-spline approximation
Error on approximation = 0.94 mm
Error on approximation = 0.49 mm
Error on approximation = 0.46 mm
Error on approximation = 0.16 mm
Error on approximation = 0.08 mm
Error on approximation = 0.07 mm
Error on approximation = 0.04 mm
Error on approximation = 0.03 mm
Error on approximation = 0.03 mm
Create the straight space and the safe zone
Length of spinal cord: 194.37234043601467
Size of spinal cord in z direction: 190.40832635342352
Ratio length/size: 1.0208184912840073
Safe zone boundaries (curved space): [-122.37883246612023, 68.02949388730329]
Safe zone boundaries (straight space): [-124.3608395074158, 70.01150092859886]
Pad input volume to account for spinal cord length…
Time to generate centerline: 71.0 ms
100%|█████████████████████████████████████████| 244/244 [00:15<00:00, 15.98it/s]
100%|█████████████████████████████████████████| 328/328 [01:13<00:00, 4.44it/s]
Warping field generated: tmp.curve2straight.nii.gz
Warping field generated: tmp.straight2curve.nii.gz
Apply transformation to input image…
/home/brain/sct_dev/bin/isct_antsApplyTransforms -d 3 -r tmp.centerline_pad_crop.nii.gz -i data.nii -o tmp.anat_rigid_warp.nii.gz -t tmp.curve2straight.nii.gz -n ‘BSpline[3]’ # in /tmp/sct-20191127023100.833659-straighten_spinalcord-9bhwralm
Generate output files…
File created: ./warp_curve2straight.nii.gz
File created: ./warp_straight2curve.nii.gz
cp /tmp/sct-20191127023100.833659-straighten_spinalcord-9bhwralm/tmp.anat_rigid_warp.nii.gz ./straight_ref.nii.gz
sct_convert -i /tmp/sct-20191127023100.833659-straighten_spinalcord-9bhwralm/tmp.anat_rigid_warp.nii.gz -o ./data_straight.nii
File created: ./data_straight.nii
Remove temporary files…
rm -rf /tmp/sct-20191127023100.833659-straighten_spinalcord-9bhwralm

Finished! Elapsed time: 115 s

Resample to 0.5mm isotropic…
sct_resample -i data_straight.nii -mm 0.5x0.5x0.5 -x linear -o data_straightr.nii # in /tmp/sct-20191127023100.550457-label_vertebrae-ijnzn6hi

Apply straightening to segmentation…
/home/brain/sct_dev/bin/isct_antsApplyTransforms -d 3 -i segmentation.nii -r data_straightr.nii -t warp_curve2straight.nii.gz -o segmentation_straight.nii -n Linear # in /tmp/sct-20191127023100.550457-label_vertebrae-ijnzn6hi
sct_maths -i segmentation_straight.nii -thr 0.5 -o segmentation_straight.nii # in /tmp/sct-20191127023100.550457-label_vertebrae-ijnzn6hi

Create label to identify disc…
Traceback (most recent call last):
File “/home/brain/sct_dev/scripts/sct_label_vertebrae.py”, line 427, in
main()
File “/home/brain/sct_dev/scripts/sct_label_vertebrae.py”, line 330, in main
im_label_c2c3 = detect_c2c3(im_data, im_seg, contrast, verbose=verbose_detect_c2c3)
File “/home/brain/sct_dev/spinalcordtoolbox/vertebrae/detect_c2c3.py”, line 52, in detect_c2c3
nii_im = flatten_sagittal(nii_im, nii_seg,verbose=verbose)
File “/home/brain/sct_dev/scripts/sct_flatten_sagittal.py”, line 60, in flatten_sagittal
np.ones(nz-zmax) * x_centerline_fit[-1]])
File “/home/brain/sct_dev/python/envs/venv_sct/lib/python3.6/site-packages/numpy/core/numeric.py”, line 214, in ones
a = empty(shape, dtype, order)
ValueError: negative dimensions are not allowed

Hi @zmzforever,

Two things:

  1. The command you are running is using the mt1 image (flag -i), while the segmentation is using the t2 segmentation (flag -s). Both images are not in the same space, while they should be. So, either you use -i mt1 -s mt1_seg, or -i t2 -s t2_seg, but not a mix of both.
  2. This axial mt1 image is not good for labeling vertebrae because they are not well seen on this contrast and highly anisotropic resolution, as shown below: