sct-pipeline / contrast-agnostic-softseg-spinalcord

Contrast-agnostic spinal cord segmentation project with softseg
MIT License
4 stars 3 forks source link

`NaN` in T2w softseg labels #24

Open uzaymacar opened 2 years ago

uzaymacar commented 2 years ago

Upon discovering that T2w training diverges to NaN loss with a multitude of training settings, I explored the preprocessed data and found that the following subjects contain NaN values in their T2w softseg labels:

This is likely the reason for problem 2 as mentioned in our progress report.

sandrinebedard commented 2 years ago

From my exploration, NaN values are due to a division of 0 by 0... From the coverage mask and the spinal cord sum of all contrast.

sct_maths -i sum_sc_seg.nii.gz -div sum_coverage.nii.gz -o division.nii.gz

--
Spinal Cord Toolbox (git-sb/3432-csa-pmj-perslice-c7db1123f5f4fae06d570293ebc135078329f94f)

sct_maths -i sum_sc_seg.nii.gz -div sum_coverage.nii.gz -o division.nii.gz
--

/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_maths.py:377: RuntimeWarning: invalid value encountered in true_divide
  data_out = np.divide(data, np.prod(data_to_div, axis=-1))

I think this is actually the case for more than just those 2 subjects. The NaN values aren't in the spinal cord segmenation, just above, they should be zeros. I'll add a fix in the preprocessing script.