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

Unable to determine ImageIO reader for "/input/images/pet/e260efef-0a29-4c68-972e-9e573c740de5.mha" #7

Closed
JunMa11 opened this issue Jul 30, 2022 · 8 comments

Comments

@JunMa11
Copy link

JunMa11 commented Jul 30, 2022

Dear organizers,

I tested the nnunet baseline but got the following error

Checking GPU availability
Available: True
Device count: 2
Current device: 0
Device name: NVIDIA GeForce RTX 2080 Ti
Device memory: 11554848768
Start processing
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/algorithm/process.py", line 202, in <module>
    Autopet_baseline().process()
  File "/opt/algorithm/process.py", line 193, in process
    uuid = self.load_inputs()
  File "/opt/algorithm/process.py", line 63, in load_inputs
    os.path.join(self.nii_path, 'TCIA_001_0000.nii.gz'))
  File "/opt/algorithm/process.py", line 33, in convert_mha_to_nii
    img = SimpleITK.ReadImage(mha_input_path)
  File "/home/algorithm/.local/lib/python3.7/site-packages/SimpleITK/extra.py", line 346, in ReadImage
    return reader.Execute()
  File "/home/algorithm/.local/lib/python3.7/site-packages/SimpleITK/SimpleITK.py", line 8015, in Execute
    return _SimpleITK.ImageFileReader_Execute(self)
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:105:
sitk::ERROR: Unable to determine ImageIO reader for "/input/images/pet/e260efef-0a29-4c68-972e-9e573c740de5.mha"

This is my folder structure

├── data_conversion
│   ├── mha2nii.py
│   ├── nii2mha.py
│   ├── tcia2hdf5.py
│   └── tcia2nifti.py
├── LICENSE
├── nnUNet_baseline
│   ├── build.sh
│   ├── checkpoints
│   │   └── nnUNet
│   │       └── 3d_fullres
│   │           └── Task001_TCIA
│   │               └── nnUNetTrainerV2__nnUNetPlansv2.1
│   │                   ├── fold_0
│   │                   │   ├── debug.json
│   │                   │   ├── model_final_checkpoint.model
│   │                   │   ├── model_final_checkpoint.model.pkl
│   │                   │   └── progress.png
│   │                   └── plans.pkl
│   ├── Dockerfile
│   ├── Dockerfile.eval
│   ├── export.sh
│   ├── predict.py
│   ├── process.py
│   ├── README.md
│   ├── requirements.txt
│   └── test.sh
├── README.md
├── test
│   ├── expected_output_nnUNet
│   │   └── images
│   │       └── TCIA_001.nii.gz
│   ├── expected_output_uNet
│   │   └── PRED.nii.gz
│   └── input
│       └── images
│           ├── ct
│           │   └── af3b6605-c2b9-4067-8af5-8b85aafb2ae3.mha
│           └── pet
│               └── e260efef-0a29-4c68-972e-9e573c740de5.mha

and dockerfile

FROM pytorch/pytorch


RUN groupadd -r algorithm && useradd -m --no-log-init -r -g algorithm algorithm

RUN mkdir -p /opt/algorithm /input /output \
    && chown algorithm:algorithm /opt/algorithm /input /output

USER algorithm

WORKDIR /opt/algorithm

ENV PATH="/home/algorithm/.local/bin:${PATH}"

RUN python -m pip install --user -U pip

COPY --chown=algorithm:algorithm requirements.txt /opt/algorithm/
RUN python -m pip install --user torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
RUN python -m pip install --user -r requirements.txt

COPY --chown=algorithm:algorithm process.py /opt/algorithm/
COPY --chown=algorithm:algorithm predict.py /opt/algorithm/

# RUN mkdir -p /opt/algorithm/checkpoints/nnUNet/

# Store your weights in the container
COPY --chown=algorithm:algorithm checkpoints /opt/algorithm/

# nnUNet specific setup
RUN mkdir -p /opt/algorithm/nnUNet_raw_data_base/nnUNet_raw_data/Task001_TCIA/imagesTs
RUN mkdir -p /opt/algorithm/nnUNet_raw_data_base/nnUNet_raw_data/Task001_TCIA/result

ENV nnUNet_raw_data_base="/opt/algorithm/nnUNet_raw_data_base"
ENV RESULTS_FOLDER="/opt/algorithm/checkpoints"
ENV MKL_SERVICE_FORCE_INTEL=1


ENTRYPOINT python -m process $0 $@


Any comments would be highly appreciated:)

@thomaskuestner
Copy link
Member

Can you please confirm that you downloaded the GIT LFS PET/CT image files?

@JunMa11
Copy link
Author

JunMa11 commented Aug 2, 2022

Hi @thomaskuestner ,

I have installed the git lfs https://git-lfs.github.com/

How can I download the image files?

I tried the following command but it doesn't download the complete image files.

git clone https://github.com/lab-midas/autoPET

@thomaskuestner
Copy link
Member

You can try to call

git lfs clone https://github.com/lab-midas/autoPET

@JunMa11
Copy link
Author

JunMa11 commented Aug 3, 2022

@thomaskuestner Thanks for your reply very much.

I tried this command but the complete PET and CT images are still not downloaded

git lfs clone https://github.com/lab-midas/autoPET
WARNING: `git lfs clone` is deprecated and will not be updated
          with new flags from `git clone`

`git clone` has been updated in upstream Git to have comparable
speeds to `git lfs clone`.
Cloning into 'autoPET'...
remote: Enumerating objects: 230, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 230 (delta 6), reused 13 (delta 4), pack-reused 195
Receiving objects: 100% (230/230), 130.38 MiB | 27.40 MiB/s, done.
Resolving deltas: 100% (104/104), done.
Skipping object checkout, Git LFS is not installed./s
cd autoPET/test/input/images/ct
ls -l
133 Aug  3 15:17 af3b6605-c2b9-4067-8af5-8b85aafb2ae3.mha

The CT image file only has 133KB.

@JunMa11
Copy link
Author

JunMa11 commented Aug 3, 2022

Update: It was solved by directly download the image files from github web page.

BTW, why the names of the PET and CT image are different?

During testing, the prediction is successful but I got an error during evaluation.

prediction done
force_separate_z: None interpolation order: 1
no resampling necessary
Preprocessing done
inference done. Now waiting for the segmentation export to finish...
WARNING! Cannot run postprocessing because the postprocessing file is missing. Make sure to run consolidate_folds in the output folder of the model first!
The folder you need to run this in is /opt/algorithm/checkpoints/nnUNet/3d_fullres/Task001_TCIA/nnUNetTrainerV2__nnUNetPlansv2.1
nnUNet segmentation done!
Prediction finished
Start output writing
WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/Meta/src/itkMetaImageIO.cxx, line 669
MetaImageIO (0x55b0c09c6840): Unsupported or empty metaData item ITK_FileNotes of type Ssfound, won't be written to image file

WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/Meta/src/itkMetaImageIO.cxx, line 669
MetaImageIO (0x55b0c09c6840): Unsupported or empty metaData item aux_file of type Ssfound, won't be written to image file

WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/Meta/src/itkMetaImageIO.cxx, line 669
MetaImageIO (0x55b0c09c6840): Unsupported or empty metaData item descrip of type Ssfound, won't be written to image file

WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/Meta/src/itkMetaImageIO.cxx, line 669
MetaImageIO (0x55b0c09c6840): Unsupported or empty metaData item intent_name of type Ssfound, won't be written to image file

Output written to: /output/images/automated-petct-lesion-segmentation/af3b6605-c2b9-4067-8af5-8b85aafb2ae3.mha
Evaluation done, checking results
Sending build context to Docker daemon  252.6MB
Step 1/9 : FROM python:3.9-slim
 ---> ae64b82339a8
Step 2/9 : RUN groupadd -r algorithm && useradd -m --no-log-init -r -g algorithm algorithm
 ---> Using cache
 ---> e4bcf2f8512b
Step 3/9 : WORKDIR /opt/algorithm
 ---> Using cache
 ---> e39772ce55a0
Step 4/9 : USER algorithm
 ---> Using cache
 ---> cee24bab77ae
Step 5/9 : ENV PATH="/home/algorithm/.local/bin:${PATH}"
 ---> Using cache
 ---> 7ec6e93d5998
Step 6/9 : RUN python -m pip install --user -U pip
 ---> Using cache
 ---> 059c31a867c1
Step 7/9 : COPY --chown=algorithm:algorithm requirements.txt /opt/algorithm/
 ---> b62a70df51fa
Step 8/9 : RUN python -m pip install --user numpy
 ---> Running in bdd6c11255fa
Collecting numpy
  Downloading numpy-1.23.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 67.8 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.23.1
Removing intermediate container bdd6c11255fa
 ---> b3aabe3c28ff
Step 9/9 : RUN python -m pip install --user simpleitk
 ---> Running in 672729c79f7b
Collecting simpleitk
  Downloading SimpleITK-2.1.1.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (48.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.4/48.4 MB 38.1 MB/s eta 0:00:00
Installing collected packages: simpleitk
Successfully installed simpleitk-2.1.1.2
Removing intermediate container 672729c79f7b
 ---> 99aefda836ac
Successfully built 99aefda836ac
Successfully tagged autopet_eval:latest
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/home/algorithm/.local/lib/python3.9/site-packages/SimpleITK/extra.py", line 346, in ReadImage
    return reader.Execute()
  File "/home/algorithm/.local/lib/python3.9/site-packages/SimpleITK/SimpleITK.py", line 8015, in Execute
    return _SimpleITK.ImageFileReader_Execute(self)
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:105:
sitk::ERROR: Unable to determine ImageIO reader for "/expected_output/images/TCIA_001.nii.gz"
autopet_baseline-output-eba5e4d0ad84e0bcd5c79ad7e0d20779

@thomaskuestner
Copy link
Member

Good to hear that it seems to work now. I haven't seen these warnings before but as long as you get an output I guess you can ignore them.
Grand challenge automatically hashes and converts each filename to be unique. Therefore these files have different names. This is the expected input from the grand challenge platform.

I am closing this issue as solved.

@JunMa11
Copy link
Author

JunMa11 commented Aug 4, 2022

Hi @thomaskuestner ,

During evaluation, the test.sh got an error as shown in the above log RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute:

Does this error matter?

@thomaskuestner
Copy link
Member

No, must likely you cannot read from the directory you mounted there. As long as your container (code above) runs, everything is fine.

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