pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
110 stars 27 forks source link

Running cardiac segmentation encounts problems #275

Closed Westeven closed 1 month ago

Westeven commented 1 month ago

When I use linux to run the cardiac segmentation project,it shows: WARNING! Cannot run postprocessing because the postprocessing file is missing. Make sure to run consolidate_folds in the output folder of the model first! It reminds me that I miss the processing json file?But I think I downloaded the right final model. Dose it mean I need to train the model by myself?

pchlap commented 1 month ago

Hi @Westeven, this warning comes from nnUNet. Since we only trained one fold, nnUNet is unable to apply it's processing module. This is expected, and can safely be ignored. Can you confirm that the remainder of the process runs and the auto-segmentations are generated successfully?

Westeven commented 1 month ago

Thank you for your response. How long will the subsequent process approximately take? When I use PyCharm, the program keeps running and crashes after a few minutes without producing the automatic segmentation results. If I use Jupyter, the kernel crashes after a while.

pchlap commented 1 month ago

Thank you for your response. How long will the subsequent process approximately take? When I use PyCharm, the program keeps running and crashes after a few minutes without producing the automatic segmentation results. If I use Jupyter, the kernel crashes after a while.

Runtime depends on your system specifications. The crash sounds like you may be running into memory limitations. What resources does your system have? Does it have a GPU setup for processing?

I would recommend at least 8 core CPU and 16GB RAM and a GPU if possible.

Westeven commented 1 month ago

Our system specification is RTX 4090 24G 64G RAM. The system should be able to run the code. However, it still encountered the mentioned problem. We monitored memory usage, but the occupancy rate did not appear high, and it seemed the code was running continuously.

pchlap commented 1 month ago

Yes that should be more than sufficient to run the code (I'd expect this to take less than 5 mins on this system).

Perhaps there is something unusual about the image you are testing with causing the issue? Are you able to test this with some other images? The tool is designed to work for radiotherapy planning CT images.

Westeven commented 1 month ago

We are using the data and corresponding code from the script, but I noticed that it generates a fold_0 folder which is empty. Is this normal?

pchlap commented 1 month ago

The fold_0 folder in ~/.platipy/nnUNet_models/nnUNet/3d_lowres/Task400_OPEN_HEART_1FOLD/nnUNetTrainerV2__nnUNetPlansv2.1 should be empty. The model is contained in the all folder.

I just ran through the test notebook successfully using Google CoLab: https://colab.research.google.com/github/pyplati/platipy/blob/master/examples/cardiac_segmentation.ipynb

This took about 10 mins after switching to a T4 GPU runtime. Perhaps you can try running this example, then compare that environment to yours? I can't think of any other things to check other than the versions of the installed dependencies (you can run ! pip list in the CoLab notebook and your environment). Also, which Python version do you use?

Westeven commented 1 month ago

Package Version


amqp 5.2.0 aniso8601 9.0.1 anyio 4.2.0 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 asttokens 2.0.5 async-timeout 4.0.3 attrs 23.1.0 backcall 0.2.0 backports.zoneinfo 0.2.1 batchgenerators 0.25 beautifulsoup4 4.12.3 billiard 4.2.0 bleach 4.1.0 blinker 1.8.2 celery 5.4.0 certifi 2024.7.4 cffi 1.16.0 charset-normalizer 3.3.2 click 8.1.7 click-didyoumean 0.3.1 click-plugins 1.1.1 click-repl 0.3.0 comm 0.2.1 contourpy 1.1.1 cycler 0.12.1 dataclasses 0.6 debugpy 1.6.7 decorator 5.1.1 defusedxml 0.7.1 dicom2nifti 2.4.11 entrypoints 0.4 exceptiongroup 1.2.0 executing 0.8.3 fastjsonschema 2.16.2 filelock 3.15.4 Flask 2.3.3 Flask-RESTful 0.3.10 Flask-SQLAlchemy 3.1.1 fonttools 4.53.1 fsspec 2024.6.1 future 1.0.0 greenlet 3.0.3 gunicorn 22.0.0 idna 3.7 imageio 2.34.2 importlib-metadata 7.0.1 importlib_resources 6.4.0 ipykernel 6.28.0 ipython 8.12.2 ipython-genutils 0.2.0 itsdangerous 2.2.0 jedi 0.18.1 Jinja2 3.1.4 joblib 1.4.2 jsonschema 4.19.2 jsonschema-specifications 2023.7.1 jupyter_client 7.4.9 jupyter_core 5.7.2 jupyter-events 0.10.0 jupyter_server 2.14.1 jupyter_server_terminals 0.4.4 jupyterlab-pygments 0.2.2 kiwisolver 1.4.5 kombu 5.3.7 lazy_loader 0.4 linecache2 1.0.0 MarkupSafe 2.1.3 matplotlib 3.7.5 matplotlib-inline 0.1.6 MedPy 0.5.1 mistune 2.0.4 mpmath 1.3.0 nbclassic 1.1.0 nbclient 0.8.0 nbconvert 7.10.0 nbformat 5.9.2 nest-asyncio 1.6.0 networkx 3.1 nibabel 5.2.1 nnunet 1.7.1 notebook 6.5.4 notebook_shim 0.2.3 numpy 1.24.4 nvidia-cublas-cu12 12.1.3.1 nvidia-cuda-cupti-cu12 12.1.105 nvidia-cuda-nvrtc-cu12 12.1.105 nvidia-cuda-runtime-cu12 12.1.105 nvidia-cudnn-cu12 8.9.2.26 nvidia-cufft-cu12 11.0.2.54 nvidia-curand-cu12 10.3.2.106 nvidia-cusolver-cu12 11.4.5.107 nvidia-cusparse-cu12 12.1.0.106 nvidia-nccl-cu12 2.20.5 nvidia-nvjitlink-cu12 12.5.82 nvidia-nvtx-cu12 12.1.105 opencv-python 4.10.0.84 overrides 7.4.0 packaging 24.1 pandas 2.0.3 pandocfilters 1.5.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 pillow 10.4.0 pip 24.0 pkgutil_resolve_name 1.3.10 platformdirs 3.10.0 platipy 0.7.2 prometheus-client 0.14.1 prompt-toolkit 3.0.43 psutil 5.9.0 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.21 pydicom 2.4.4 Pygments 2.15.1 pymedphys 0.40.0 pynetdicom 2.0.2 pyparsing 3.1.2 python-dateutil 2.9.0.post0 python-gdcm 3.0.24.1 python-json-logger 2.0.7 pytz 2024.1 PyWavelets 1.4.1 PyYAML 6.0.1 pyzmq 24.0.1 redis 4.6.0 referencing 0.30.2 requests 2.32.3 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.10.6 rt-utils 1.2.7 scikit-image 0.21.0 scikit-learn 1.3.2 scipy 1.10.1 Send2Trash 1.8.2 setuptools 69.5.1 SimpleITK 2.3.1 six 1.16.0 sniffio 1.3.0 soupsieve 2.5 SQLAlchemy 2.0.31 stack-data 0.2.0 sympy 1.13.0 terminado 0.17.1 threadpoolctl 3.5.0 tifffile 2023.7.10 tinycss2 1.2.1 tomlkit 0.13.0 torch 2.3.1 tornado 6.4.1 tqdm 4.66.4 traceback2 1.4.0 traitlets 5.9.0 triton 2.3.1 typing_extensions 4.11.0 tzdata 2024.1 unittest2 1.1.0 urllib3 2.2.2 vine 5.1.0 vtk 9.3.1 wcwidth 0.2.13 webencodings 0.5.1 websocket-client 1.8.0 Werkzeug 3.0.3 wheel 0.43.0 zipp 3.17.0 This is our environment. It has been running for 2 hours for no result this time.

Westeven commented 1 month ago

We use the Python 3.8. Any recommendation?

Westeven commented 1 month ago

We have changed another CPU and it finally worked.

pchlap commented 1 month ago

We have changed another CPU and it finally worked.

Thanks for the update @Westeven. As you could probably tell I was somewhat stumped on what the issue was here. Glad to hear you have this working now.