I am trying to segment and label T1-w scans containing a small portion of the upper cervical cord.
The segmentation is working fine, but the vertebral labeling sometime is failing, as in this case here:
Additionally, in some cases, both the segmentation and the vertebral labelling are producing an output, but the labeling is not always delivering the expected results.On the left a correct labeling, on the right something went wrong.
Do I have to segment first and then run labeling by running the two command sequentially ?
sct_deepseg -task seg_sc_contrast_agnostic -i $image_file
sct_deepseg -task TotalSpineSeg -i $image_file
Important Note: While TotalSpineSeg provides spinal cord segmentation, it is not intended to replace validated methods for cross-sectional area (CSA) analysis. The spinal cord segmentation from TotalSpineSeg has not been validated for CSA measurements, nor has it been tested on cases involving spinal cord compressions, MS lesions, or other spinal cord abnormalities. For accurate CSA analysis, we strongly recommend using the validated algorithms available in the Spinal Cord Toolbox.
The segmentation is working fine. The contrast agnostic approach (which I also tried) is much faster compared to the standard deepseg.
The problem is the sct_label_vertebrae is not working well for images with such small coverage of the cord.
Coming back to your suggestion. Using the output from the totalspineseg model you implanted, would it be possible to have the possibility to split c1 and c2?
I run the code as you suggested.
The segmentation is generated, the totalseg output generated, but when i combine the step1_level with the segmentation I get this error and cannot extract the segmented portions of the cord:
Apply straightening to segmentation...
File /tmp/sct_2025-02-10_08-06-06_label-vertebrae_eczyqo9h/segmentation_straight.nii already exists. Will overwrite it.
Apply straightening to disc labels...
Creating temporary folder (/tmp/sct_2025-02-10_08-06-36_apply-transfo-3d-label_qjogmjkl)
File labeldisc_straight.nii.gz already exists. Will overwrite it.
During disc labeling, center of mass calculation failed due to discontinuities in segmented spinal cord; please check the quality of your segmentation. Using interpolated centerline as a fallback.
Traceback (most recent call last):
File "/usr/prog/software/SCT-toolbox/6.5/spinalcordtoolbox/scripts/sct_label_vertebrae.py", line 507, in <module>
main(sys.argv[1:])
File "/usr/prog/software/SCT-toolbox/6.5/spinalcordtoolbox/scripts/sct_label_vertebrae.py", line 365, in main
label_vert('segmentation_straight.nii', 'labeldisc_straight.nii.gz')
File "/usr/prog/software/SCT-toolbox/6.5/spinalcordtoolbox/vertebrae/core.py", line 42, in label_vert
label_discs(fname_seg, discs)
File "/usr/prog/software/SCT-toolbox/6.5/spinalcordtoolbox/vertebrae/core.py", line 514, in label_discs
cx, cy = [int(x) for x in np.round(center_of_mass(slices)).tolist()]
File "/usr/prog/software/SCT-toolbox/6.5/spinalcordtoolbox/vertebrae/core.py", line 261, in center_of_mass
raise EmptyArrayError("Center of mass can't be calculated on empty arrays.")
spinalcordtoolbox.types.EmptyArrayError: Center of mass can't be calculated on empty arrays.