ivadomed / model_seg_sci

Deep-learning based segmentation of the spinal cord and intramedually lesions in traumatic and non-traumatic SCI
MIT License
12 stars 2 forks source link

`sci-colorado/sub-5740_T2w.nii.gz` - weird intensity range #59

Open valosekj opened 1 year ago

valosekj commented 1 year ago

The sci-colorado/sub-5740/anat/sub-5740_T2w.nii.gz image has a weird intensity range:

$ fslstats sub-5740_T2w.nii.gz -R
-32767.000000 32516.000000

This results in a "gray nothing" when opening the image in FSLeyes:

image

When manually adjusting the min and max to 0-1000 interval, the image looks good:

image

The weird intensity range results in the failure of sct_deepseg_sc:

$ sct_deepseg_sc -i sub-5740_T2w.nii.gz -c t2 -kernel 2d 

--
Spinal Cord Toolbox (git-jv/sct_analyze_lesion_improvements-16742e4eada8e9853993e61fe4ce559767d4f42a*)

sct_deepseg_sc -i sub-5740_T2w.nii.gz -c t2 -kernel 2d
--

Config deepseg_sc:
  Centerline algorithm: svm
  Brain in image: True
  Kernel dimension: 2d
  Contrast: t2
  Threshold: 0.7
Creating temporary folder (/var/folders/w6/bnzr2qls11l69w0_8q95ghtr0000gn/T/sct_2023-09-11_10-43-36_deepseg-sc_sk1d9x5y)
Reorient the image to RPI, if necessary...
Finding the spinal cord centerline...
Creating temporary folder (/var/folders/w6/bnzr2qls11l69w0_8q95ghtr0000gn/T/sct_2023-09-11_10-43-37_optic-detect-centerline_8wgfjh8r)
/Users/valosek/code/sct_latest/spinalcordtoolbox/centerline/optic.py:102: RuntimeWarning: overflow encountered in short_scalars
  data_rescaled = img_data.astype('float') * (max_out - min_out) / (max_in - min_in)
To avoid intensity overflow due to convertion to +uint16+, intensity will be rescaled to the maximum quantization scale
Remove temporary files...
rm -rf /var/folders/w6/bnzr2qls11l69w0_8q95ghtr0000gn/T/sct_2023-09-11_10-43-37_optic-detect-centerline_8wgfjh8r
Cropping the image around the spinal cord...
Normalizing the intensity...
Segmenting the spinal cord using deep learning on 2D patches...
Reassembling the image...
Resampling the segmentation to the native image resolution using linear interpolation...
Spinal cord could not be detected for /Users/valosek/data/data.neuro.polymtl.ca/sci-colorado/sub-5740/anat/sub-5740_T2w.nii.gz
    EmptyArrayError: 'Spinal cord not detected. Please make sure that there is sufficient contrast between the spinal cord and CSF to ensure good results.'
jcohenadad commented 1 year ago

Very interesting bug! Thank you for reporting this, Jan. Maybe we could consider also reporting in SCT.

valosekj commented 1 year ago

Note that this intensity issue results in the failure of the baselines/comparison_with_other_methods_sc.sh script for seed710 and seed123 train-test splits. --> we have no SC predictions for this subject for these two seeds.

mguaypaq commented 1 year ago

I had a quick look at the data for this image (sub-5740_T2w.nii.gz), and all the values which are outside the range [0, 10000] are concentrated in a small region of the image:

So maybe it would make sense to zero out this part of the image.

Edit: outside of this part of the image, the range of values is [0, 1839].