sct-pipeline / contrast-agnostic-softseg-spinalcord

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

Prediction clipping sets background values to 0.5 instead of 0 #71

Closed valosekj closed 9 months ago

valosekj commented 9 months ago

MONAI prediction clipping sets background values to 0.5 instead of 0!

https://github.com/sct-pipeline/contrast-agnostic-softseg-spinalcord/blob/f88d927c6709dcebb79d38ccd3bd45aa2e355474/monai/run_inference_single_image.py#L308-L309

image

Possible fix:

# clip the prediction between 0.5 and 1
pred = torch.clamp(pred, 0.5, 1)
# set background values to 0
pred[pred <= 0.5] = 0

or sct_maths command for already existing predictions:

$ sct_maths -i ${file}_seg_monai.nii.gz -thr 0.51 -o ${file}_seg_monai_thr.nii.gz
naga-karthik commented 9 months ago

Thanks for catching this bug, Jan! It has been fixed in commit 4694169352fb962f607e7684fe778677adc123dc !

valosekj commented 9 months ago

Thank you for the fix, Naga!