nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

Would like to save each label as a separate .nii.gz file during the inference phase?

Open Hollycooool opened this issue 1 year ago • 5 comments

Hi, there are four categories of labels in my dataset.json, and now the prediction is 4 labels per patient in one nii.gz file, if I want to output a specific nii.gz file for each patient's label in the inference phase, i.e. 4 different nii.gz files for each patient, which part of the nnunet should I modify? If I want to output a specific nii.gz file for each patient label in the reasoning phase, i.e. 4 different nii.gz files for each patient, which part of nnunet should I modify?

Hollycooool avatar Sep 10 '24 13:09 Hollycooool

I want to remove the softmax layer from the end of the network during the inference phase and output the probabilities of a voxel belonging to different labels.Thanks!

Hollycooool avatar Sep 12 '24 01:09 Hollycooool

Hi @Hollycooool,

to write out the softmax probabilities the network returns alongside the segmentations during the prediction use the --save_probabilties flag.

This will save .npz files in the ouptut folder in which the probabilities for each class are saved.

Best regards, Carsten

sten2lu avatar Sep 12 '24 10:09 sten2lu

What I'm wondering is whether the .npz file saved by --save_probabilties contains the un-normalized predicted values of the image before it goes through the softmax layer?

I'd like to get the model's un-normalized predicted values when the prediction is complete, which means saving the logits image (without going through Softmax), saving the logits tensor directly as .npz, and also making sure that the output is a separate channel for each label's score.

Is this achievable? Thanks!

Hollycooool avatar Sep 13 '24 01:09 Hollycooool

Hi @Hollycooool To get the logits of nnU-Net you will have to change the inference code of nnU-Net. As of yet we do not support this.

--save_probabilities saves the probabilities per class inside the.npz file.

To get a better understanding of the inference code, I refer you to the documentation.

Best regards Carsten

sten2lu avatar Sep 14 '24 16:09 sten2lu

As a noob, do I need to modify the network framework at train, and which class under the py file in the reasoning folder should I modify? Thanks!

Hollycooool avatar Sep 18 '24 01:09 Hollycooool

Hi @Hollycooool, The necessary steps are detailed in the README.md in the folder nnunetv2/inference .

Best regards, Carsten

sten2lu avatar Nov 05 '24 16:11 sten2lu