MIC-DKFZ / nnUNet

Apache License 2.0
5.9k stars 1.76k forks source link

Mismatched orientation of predicted segmentation #1956

Closed namhoangle closed 6 months ago

namhoangle commented 9 months ago

I'm inspecting the validation results of my model and spotting something strange

I overlay the predicted segmentation in the validation folder nnUNet_results/.../validation on top of the raw image in nnUNet_raw/imagesTr

For example: Here is the raw image CleanShot 2024-02-16 at 01 04 02@2x

When the predicted mask is overlayed CleanShot 2024-02-16 at 01 07 49@2x

It can be seen that the orientation of the mask does not match the orientation of the provided train images. It seems like the predicted segmentations were flipped in one dimension. Is this supposed to work that way? Will this affect the calculation of the metrics in "/nunetv2/evaluation/evaluate_predictions.py"?

mrokuss commented 8 months ago

Hey @namhoangle,

This generally seems strange and should not happen. However, I have a few ideas of what might cause the issue. Did you try opening the segmentation mask and the image with another viewer? Does this issue reappear, and how does the ground truth segmentation appear? Also, in the summary.json, is the Dice coefficient at 0 or a reasonable value? Sometimes these issues occur because the libraries "nibabel" and "SITK," often used for medical images, for some reason load the xyz axis in opposite directions. Maybe this has happened here as well.

Hope this helps, and I'm here to help out further.

Max

mrokuss commented 6 months ago

Hey @namhoangle

I hope you could fix your issue! Otherwise feel free to reopen. Cheers,

Max

namhoangle commented 5 months ago

@mrokuss

Sorry for the late reply

Did you try opening the segmentation mask and the image with another viewer?

Yes

Does this issue reappear, and how does the ground truth segmentation appear?

Yes. The image I showed in the first post is how it appear organically. In the 2nd image, the predicted mask by nnUNet is flipped.

Also, in the summary.json, is the Dice coefficient at 0 or a reasonable value?

Yes very reasonable. This leads me to conclusion that somehow the mask was correctly reoriented during the process but I have no idea how

Sometimes these issues occur because the libraries "nibabel" and "SITK"

I use simpleITK to working with nifti images. Up until the data is copied to the nnUNet_raw folder, everything looks fine and is in the correct orientation. I don't know why/how/when the masks are flipped in the nnUNet procedure.