Spinal cord lesion segmentation

Hi,

I am running sct_deepseg_lesion on T2 3D FLAIR images from people with multiple sclerosis. These are brain MRI scans, but include a sufficient amount of the cervical spine to allow for SCT processing. I’ve succesfully ran spinal cord segmentation on the T1s for the same subjects. The lesion segmentation, however, produces empty masks, despite it not giving any errors.

I’ve used the following command:
sct_deepseg_lesion -i $SUBDIR/$SUB/$SES/anat/$LESIONSEARCH -c t2 -centerline cnn -brain 1 -ofolder $SUBDIR/$SUB/$SES/$SEGFOLDER >> $SUBDIR/$SUB/$SES/$SEGFOLDER/sct_logfile.log 2>&1

I’ve also tried:
sct_deepseg_lesion -i $SUBDIR/$SUB/$SES/anat/$LESIONSEARCH -c t2 -ofolder $SUBDIR/$SUB/$SES/$SEGFOLDER >> $SUBDIR/$SUB/$SES/$SEGFOLDER/sct_logfile.log 2>&1

Output:
Spinal Cord Toolbox (6.0)

sct_deepseg_lesion -i /PROJ/FutureMS_Res/Pipeline/TestingFolder/Rozanna/Spinalcord/FMS_0112/ses_w2/anat/FMS_0112_ED2_w2_3dFLAIR.nii.gz -c t2_ax -centerline cnn -brain 1 -ofolder /PROJ/FutureMS_Res/Pipeline/TestingFolder/Rozanna/Spinalcord/FMS_0112/ses_w2/segmentations/tissue/spinalcord

Method:
Centerline algorithm: cnn
Assumes brain section included in the image: True

Creating temporary folder (/tmp/sct_2024-09-11_15-29-56_deepseg-lesion_rpox8w0_)
Reorient the image to RPI, if necessary…

Finding the spinal cord centerline…
e[33mTo avoid intensity overflow due to convertion to +uint8+, intensity will be rescaled to the maximum quantization scalee[0m
Brain section detected.
Creating temporary folder (/tmp/sct_2024-09-11_15-31-32_optic-detect-centerline_6_mt2s32)
e[33mImage header specifies datatype ‘uint8’, but array is of type ‘float64’. Header metadata will be overwritten to use ‘float64’.e[0m
Remove temporary files…
rm -rf /tmp/sct_2024-09-11_15-31-32_optic-detect-centerline_6_mt2s32
Cropping brain section.

Cropping the image around the spinal cord…
Normalizing the intensity…
e[33mImage header specifies datatype ‘int16’, but array is of type ‘float64’. Header metadata will be overwritten to use ‘float64’.e[0m
/home/rmeijboo/sct_6.0/spinalcordtoolbox/deepseg_/lesion.py:55: RuntimeWarning: divide by zero encountered in double_scalars
m = (y2 - y1) / (x2 - x1)
/home/rmeijboo/sct_6.0/spinalcordtoolbox/deepseg_/lesion.py:56: RuntimeWarning: invalid value encountered in double_scalars
b = y1 - (m * x1)
/home/rmeijboo/sct_6.0/spinalcordtoolbox/deepseg_/lesion.py:62: RuntimeWarning: invalid value encountered in double_scalars
omega = m * mu90 - s2 + b
/home/rmeijboo/sct_6.0/spinalcordtoolbox/deepseg_/lesion.py:63: RuntimeWarning: invalid value encountered in double_scalars
beta = omega * np.exp(-m * mu90 * 1.0 / omega)
e[33mImage header specifies datatype ‘float64’, but array is of type ‘float32’. Header metadata will be overwritten to use ‘float32’.e[0m
load data…

Segmenting the MS lesions using deep learning on 3D patches…
e[33mImage header specifies datatype ‘uint8’, but array is of type ‘float64’. Header metadata will be overwritten to use ‘float64’.e[0m
load data…

Reassembling the image…
e[33mFile /PROJ/FutureMS_Res/Pipeline/TestingFolder/Rozanna/Spinalcord/FMS_0112/ses_w2/anat/FMS_0112_ED2_w2_3dFLAIR_res_RPI_seg.nii.gz already exists. Will overwrite it.e[0m
Resampling the segmentation to the original image resolution…
load data…

Binarizing the segmentation to avoid interpolation effects…

Reorienting the segmentation to the original image orientation…

Remove temporary files…
rm -rf /tmp/sct_2024-09-11_15-29-56_deepseg-lesion_rpox8w0_
e[33mFile /PROJ/FutureMS_Res/Pipeline/TestingFolder/Rozanna/Spinalcord/FMS_0112/ses_w2/segmentations/tissue/spinalcord/FMS_0112_ED2_w2_3dFLAIR_lesionseg.nii.gz already exists. Will overwrite it.e[0m

Done! To view results, run one of the following commands (depending on your preferred viewer):
fsleyes FMS_0112/ses_w2/anat/FMS_0112_ED2_w2_3dFLAIR.nii.gz -cm greyscale FMS_0112/ses_w2/segmentations/tissue/spinalcord/FMS_0112_ED2_w2_23dFLAIR_lesionseg.nii.gz -cm red -a 70.0 &

fslview_deprecated FMS_0112/ses_w2/anat/FMS_0112_ED2_w2_3dFLAIR.nii.gz -l Greyscale FMS_0112/ses_w2/segmentations/tissue/spinalcord/FMS_0112_ED2_w2_3dFLAIR_lesionseg.nii.gz -l Red -t 0.7 &

fslview FMS_0112/ses_w2/anat/FMS_0112_ED2_w2_3dFLAIR.nii.gz -l Greyscale FMS_0112/ses_w2/segmentations/tissue/spinalcord/FMS_0112_ED2_w2_3dFLAIR_lesionseg.nii.gz -l Red -t 0.7 &

Dependencies check:
SYSTEM INFORMATION

SCT info:

version: 6.0
path: /home/rmeijboo/sct_6.0
OS: linux (Linux-3.10.0-1160.45.1.el7.x86_64-x86_64-with-glibc2.17)
CPU cores: Available: 56, Used by ITK functions: 56
RAM: Total: 193181MB, Used: 41912MB, Available: 150485MB

OPTIONAL DEPENDENCIES

Check FSLeyes version…[OK] (0.27.3+build0)

MANDATORY DEPENDENCIES

Check Python executable…[OK]

Using bundled python 3.9.19 (main, May 6 2024, 19:43:03)
[GCC 11.2.0] at /home/rmeijboo/sct_6.0/python/envs/venv_sct/bin/python
Check if data are installed…[OK]
Check if dipy is installed…[OK] (1.7.0)
Check if ivadomed is installed…[OK] (2.9.8)
Check if matplotlib is installed…[OK] (3.7.2)
Check if nibabel is installed…[OK] (3.2.2)
Check if nilearn is installed…[OK] (0.10.1)
Check if numpy is installed…[OK] (1.23.5)
Check if onnxruntime is installed…[OK] (1.15.1)
Check if pandas is installed…[OK] (1.4.4)
Check if portalocker is installed…[OK] (2.7.0)
Check if psutil is installed…[OK] (5.9.5)
Check if pyqt5 (5.12.3) is installed…[OK] (5.12.3)
Check if pytest is installed…[OK] (7.4.0)
Check if pytest-cov is installed…[OK] (4.1.0)
Check if requests is installed…[OK] (2.31.0)
Check if requirements-parser is installed…[OK]
Check if scipy is installed…[OK] (1.11.1)
Check if scikit-image is installed…[OK] (0.21.0)
Check if scikit-learn is installed…[OK] (1.3.0)
Check if xlwt is installed…[OK] (1.3.0)
Check if tqdm is installed…[OK] (4.65.0)
Check if transforms3d is installed…[OK] (0.4.1)
Check if urllib3 is installed…[OK] (1.26.16)
Check if pytest_console_scripts is installed…[OK]
Check if pyyaml is installed…[OK] (6.0)
Check if voxelmorph is installed…[OK] (0.2)
Check if wquantiles is installed…[OK] (0.4)
Check if xlsxwriter is installed…[OK] (3.1.2)
Check if spinalcordtoolbox is installed…[OK]
Check ANTs compatibility with OS …[OK]
Check PropSeg compatibility with OS …[OK]
Check if figure can be opened with PyQt…[OK]
Check if figure can be opened with matplotlib…[OK] (Using GUI backend: ‘QtAgg’)

Would you be able to help? Many thanks in advance!

Rozanna

Hi @RMeijboom,

If you send me 1-2 representative images we can have a look.

Cheers,
Julien

Many thanks, Julien! Could I have your email address please? I can’t upload them here for data privacy reasons. Thanks!

Rozanna

jcohen@polymtl.ca