DIAGNijmegen / AbdomenMRUS-prostate-segmentation

Grand Challenge wrapper for whole-gland prostate segmentation with nnUNet
Apache License 2.0
14 stars 5 forks source link

Issue with .mha reading #7

Open iladakis opened 11 months ago

iladakis commented 11 months ago

Hello @joeranbosma, firstly I want to congratulate you for your work! I have two questions:

1) I am trying to follow the guidelines found here: https://github.com/DIAGNijmegen/AbdomenMRUS-prostate-segmentation/blob/main/inference/README.md. While I can create the docker image, I have the following error thrown during reading the .mha file found in the test folder of your project (Unable to determine ImageIO reader): εικόνα

I have tried the same with different .mha files found on picai_prep project, but it throws the same error: εικόνα

Do you know why is this happening?

2) Does this implementation support the reading of multiple .mha files (t2 or adc or whatever) found on the respective folders?

Thank you in advance!!!

joeranbosma commented 11 months ago

Hi @iladakis!

1. Could you provide the exact command you issued to perform the inference? Could you check the file size of the images in the test folder? It could be that you don't have Git LFS set up properly.

  1. No, this is not supported. You will have to present each patient case independently, for the algorithm to be sure which images belong to each other. You have to prepare the different cases in individual folders, like this:

input data
├── images-case-1
│   ├── transverse-adc-prostate-mri
│   │   └── case1_adc.mha
│   ├── transverse-hbv-prostate-mri
│   │   └── case1_hbv.mha
│   └── transverse-t2-prostate-mri
│       └── case1_t2w.mha
├── images-case-2
│   ├── transverse-adc-prostate-mri
│   │   └── case2_adc.mha
│   ├── transverse-hbv-prostate-mri
│   │   └── case2_hbv.mha
│   └── transverse-t2-prostate-mri
│       └── case2_t2w.mha
etc

Best, Joeran

iladakis commented 11 months ago

Hi @joeranbosma,

1) I have prepared a docker-compose.yml that actually just executes process.py (command: python3 process.py with the proper input and output binds defined) 2) Indeed, you were right about the size of the images! I replaced them with the proper files, but now I have the following problem:

Attaching to prostate-mask

prostate-mask |

prostate-mask |

prostate-mask | Please cite the following paper when using nnUNet:

prostate-mask |

prostate-mask | Isensee, F., Jaeger, P.F., Kohl, S.A.A. et al. "nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation." Nat Methods (2020). https://doi.org/10.1038/s41592-020-01008-z

prostate-mask |

prostate-mask |

prostate-mask | If you have questions or suggestions, feel free to open an issue at https://github.com/MIC-DKFZ/nnUNet

prostate-mask |

prostate-mask | nnUNet_raw_data_base is not defined and nnU-Net can only be used on data for which preprocessed files are already present on your system. nnU-Net cannot be used for experiment planning and preprocessing like this. If this is not intended, please read documentation/setting_up_paths.md for information on how to set this up properly.

prostate-mask | nnUNet_preprocessed is not defined and nnU-Net can not be used for preprocessing or training. If this is not intended, please read documentation/setting_up_paths.md for information on how to set this up.

prostate-mask | using model stored in /opt/algorithm/results/nnUNet/3d_fullres/Task2202_prostate_segmentation/nnUNetTrainerV2_Loss_FL_and_CE_checkpoints__nnUNetPlansv2.1

prostate-mask | Traceback (most recent call last):

prostate-mask | File "/opt/conda/bin/nnUNet_predict", line 8, in

prostate-mask | sys.exit(main())

prostate-mask | File "/opt/conda/lib/python3.8/site-packages/nnunet/inference/predict_simple.py", line 219, in main

prostate-mask | predict_from_folder(model_folder_name, input_folder, output_folder, folds, save_npz, num_threads_preprocessing,

prostate-mask | File "/opt/conda/lib/python3.8/site-packages/nnunet/inference/predict.py", line 633, in predict_from_folder

prostate-mask | expected_num_modalities = load_pickle(join(model, "plans.pkl"))['num_modalities']

prostate-mask | File "/opt/conda/lib/python3.8/site-packages/batchgenerators/utilities/file_and_folder_operations.py", line 58, in load_pickle

prostate-mask | a = pickle.load(f)

prostate-mask | _pickle.UnpicklingError: invalid load key, 'v'.

prostate-mask | Traceback (most recent call last):

prostate-mask | File "/opt/conda/lib/python3.8/runpy.py", line 194, in _run_module_as_main

prostate-mask | return _run_code(code, main_globals, None,

prostate-mask | File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code

prostate-mask | exec(code, run_globals)

prostate-mask | File "/opt/algorithm/process.py", line 185, in

prostate-mask | ProstateSegmentationAlgorithm().process()

prostate-mask | File "/opt/algorithm/process.py", line 122, in process

prostate-mask | self.predict(

prostate-mask | File "/opt/algorithm/process.py", line 181, in predict

prostate-mask | subprocess.check_call(cmd)

prostate-mask | File "/opt/conda/lib/python3.8/subprocess.py", line 364, in check_call

prostate-mask | raise CalledProcessError(retcode, cmd)

prostate-mask | subprocess.CalledProcessError: Command '['nnUNet_predict', '-t', 'Task2202_prostate_segmentation', '-i', '/opt/algorithm/nnunet/input', '-o', '/opt/algorithm/nnunet/output', '-m', '3d_fullres', '-tr', 'nnUNetTrainerV2_Loss_FL_and_CE_checkpoints', '--num_threads_preprocessing', '2', '--num_threads_nifti_save', '1', '-f', '0', '1', '2', '3', '4', '-chk', 'model_final_checkpoint', '--save_npz']' returned non-zero exit status 1.

prostate-mask | If you have questions or suggestions, feel free to open an issue at https://github.com/DIAGNijmegen/picai_prep

prostate-mask |

prostate-mask | /opt/algorithm

prostate-mask | $$$$$$$$$$$

prostate-mask | ['pycache', 'docker-compose.platform.yml', 'export.sh', 'build.sh', 'input', '.gitignore', 'results', 'inference', 'LICENSE', 'docker-compose.yml', 'README.md', '.gitattributes', '.dockerignore', 'test.sh', 'process.py', 'output', 'nnUNetTrainerV2_Loss_FL_and_CE.py', 'Dockerfile', 'nnUNetTrainerV2_focalLoss.py', 'requirements.txt']

prostate-mask | ['ProstateX-0000_07-07-2011_t2w.mha']

prostate-mask | ['images']

prostate-mask exited with code 1

Thank you for your prompt response, I am very grateful!

Regards, Ioannis

joeranbosma commented 10 months ago

Dear @iladakis,

Thanks for providing the full error trace. Unfortunately, it's an error I have not seen before. Could you try it with the Docker container from Docker Hub? https://hub.docker.com/repository/docker/joeranbosma/picai_prostate_segmentation_processor/general Either version v2.2 or v2.1 should do the trick.

This algorithm did work recently for me, so it should also work for you.

iladakis commented 10 months ago

Dear @joeranbosma,

thank you very much for your suggestion! It is actually working (printing: "This worker has ended successfully, no errors to report"), but it doesn't seem to return any output. I have binded a local output directory with /output volume inside docker, but even inside docker there is no returned result (prostate-gland.mha). Have you ever come across with such an issue?

Thank you for your overall help!