nnUNet
nnUNet copied to clipboard
Properly impose changed to data in nnUNet_raw/nnUNet_raw_data WITH SOLUTION
Hi all,
it took me about a week to fix this issue where I made changes to files in the nnUNet_raw/nnUNet_raw_data
folder to be properly incorporate into the training procedure of nnUNet. Here I want to show you the correct way to make effective changes and hopefully help anyone that might get stuck on this.
Note that my change was related to the labels that were used to a Task that was already preprocessed and trained. Meaning that the following folders were filled
nnUNet_raw/nnUNet_raw_data/TaskXXX nnUNet_raw/nnUNet_cropped_data/TaskXXX nnUNet_preprocessed/TaskXXX nnUNet_trained_models/nnUNet/2d/TaskXXX
I found an issue with my labels in the raw_data folder, so my first attempt was:
- change labels in raw-data folder
- run
nnUNet_plan_and_preprocess
for this task - run
nnUNet_train 2d nnUNetTrainerV2 TaskXXX FOLD
This did not work out. Then I tried the following
- change labels in raw-data folder [at this stage, this was of course already done]
- Delete/remove the folders
nnUNet_preprocessed/TaskXXX
andnnUNet_trained_models/nnUNet/2d/TaskXXX
- run
nnUNet_plan_and_preprocess
for this task - run
nnUNet_train 2d nnUNetTrainerV2 TaskXXX FOLD
But also this DID NOT WORK. In order for my changes to have any effect I needed to:
- change labels in raw-data folder [at this stage, this was of course already done]
- Delete/remove the folders
nnUNet_preprocessed/nnUNet_cropped_data
,nnUNet_preprocessed/TaskXXX
andnnUNet_trained_models/nnUNet/2d/TaskXXX
- run
nnUNet_plan_and_preprocess
for this task - run
nnUNet_train 2d nnUNetTrainerV2 TaskXXX FOLD
What I found was that the function nnUNet_plan_and_preprocess
does not overwrite existing .npz/.npy files in the nnUNet_cropped_data
folder. Also, this process uses the files in nnUNet_cropped_data
folder to be copied to nnUNet_preprocessed
folder.
Note that the generated .nii.gz-files DO show a change, which was very confusing for me because I used those to visually check the changes.
Hopefully I can help anyone with this... and maybe one of the creators can comment on this
Hi, indeed this is a big flaw in the old design. I am currently reworking nnU-Net and the new implementation will not have this problem. The explicit cropping will no longer happen. Best, Fabian