Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessing messes up the shape #2673

Closed
adelka-m opened this issue Jan 22, 2025 · 4 comments
Closed

Preprocessing messes up the shape #2673

adelka-m opened this issue Jan 22, 2025 · 4 comments
Assignees

Comments

@adelka-m
Copy link

Hi all,

first of all thanks for your awesome work. I have a bit non standard use of the nnUnet (and it does not work, but I was expecting it a bit).

However, I have an issue with the shapes of the input data. My nii.gz files are always (112,128,128) and spacing (1.0,1.0,1.0). But the npz files created by

export nnUNet_raw="/path/nnUnet/nnUNet_raw" 
export nnUNet_preprocessed="/path/nnUnet/nnUNet_preprocessed"
export nnUNet_results="/path/nnUnet/nnUNet_results"
nnUNetv2_plan_and_preprocess -d 301 --verify_dataset_integrity

creates very random resolution of the data:
001: data: (1, 112, 128, 100), seg: (1, 112, 128, 100)
002: data: (1, 112, 102, 128), seg: (1, 112, 102, 128)
003: data: (1, 112, 128, 120), seg: (1, 112, 128, 120)
004: data: (1, 112, 128, 125), seg: (1, 112, 128, 125)
005: data: (1, 112, 128, 128), seg: (1, 112, 128, 128)

Could anyone point me to where is the problem? Or is it normal?

Thanks a lot in the advance!

@sten2lu
Copy link
Contributor

sten2lu commented Jan 24, 2025

Hi @adelka-m,

This is something that can happen because when the data has large regions that only contain background in the label and "0"s in the image, they can be cropped away.

To be sure that this is the case:

Could you please rerun the preprocessing with the "--verbose" option and paste an example of the output for samples where the shape changes or upload the entire output to a file and upload it?

Best regards,

Carsten

@adelka-m
Copy link
Author

Oh, ok. I also thought that this could be the reason. (It is very unbalanced problem, little foreground.)
Could I disable the cropping with some flag? I think that cropping could actually worsen the performance of the problem. Probably not a lot but if that disabling it is easy, it is worth a try. Thanks!

@sten2lu
Copy link
Contributor

sten2lu commented Jan 28, 2025

Hi @adelka-m,
the cropping is performed automatically and should not influence the performance.

However, if you wish to disable it, you need to write a Custom Preprocessor where to crop_to_nonzero function is not called during the preprocessing.
See the DefaultPreprocessor here: https://github.com/MIC-DKFZ/nnUNet/blob/master/nnunetv2/preprocessing/preprocessors/default_preprocessor.py

Best regards,
Carsten

@adelka-m
Copy link
Author

Ok. Thanks a lot for your help. I will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants