Inversion of background and object in label #669
-
Hello, I use code below to save predicted label into nii.gz.
"
" |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Hi @Yangtting , Could you please help provide the MONAI version you are using? Hi @dongyang0122 @ericspod , I remember we solved some similar issues before, do you remember more details? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
It might be related to the way how pre-transforms are defined. @Yangtting It would be better if you can share your full transform list. And the following issue may help here. |
Beta Was this translation helpful? Give feedback.
-
@Yangtting the pre-transforms looks good. But I notice that you have set "to_onehot" to 3 in the post-transform. You can try to set it as None to see if it works. When "to_onehot" is not None, it will create additional dimension for classes. https://docs.monai.io/en/stable/transforms.html#monai.transforms.AsDiscreted |
Beta Was this translation helpful? Give feedback.
-
For model training, loss functions require one-hot ground truth in general. But when saving the prediction, one-hot predictions are not necessary for visualization as the one-hot operation would create a 4D matrix instead of a 3D one. |
Beta Was this translation helpful? Give feedback.
@Yangtting the pre-transforms looks good. But I notice that you have set "to_onehot" to 3 in the post-transform. You can try to set it as None to see if it works. When "to_onehot" is not None, it will create additional dimension for classes.
https://docs.monai.io/en/stable/transforms.html#monai.transforms.AsDiscreted