MIC-DKFZ / nnUNet

Apache License 2.0
5.87k stars 1.76k forks source link

Error when running plan_and_preprocess. AssertionError: some image files are missing for case vert_000. Expected files #729

Closed sainatarajan closed 3 years ago

sainatarajan commented 3 years ago

Hi Fabian,

Thanks for this repo. I'm trying to run the nnUNet for my custom dataset and I encounter some errors when I run the plan_and_preprocess script.

My dataset has the following structure:

Task600_Spine/
    ├── dataset.json
    ├── imagesTr
    │   ├── vert_003.nii.gz
    │   ├── vert_004.nii.gz
    │   ├── ...
    ├── imagesTs
    │   ├── vert_001.nii.gz
    │   ├── vert_002.nii.gz
    │   ├── ...
    └── labelsTr
        ├── vert_003.nii.gz
        ├── vert_004.nii.gz
        ├── ...

Note that in the above volumes, there are no suffixes 0000 or 0001. The dataset.json has the modality of 0. The code searches for the file vert_003_0000.nii.gz, and it throws the above error since the file doesn't exist.

Now when I rename all the volumes and append the suffixes to their original filenames, for eg: changing vert_003.nii.gz to vert_003_0000.nii.gz, the code searches for the file vert_003_0000_0000.nii.gz which is not available and again throws the above error.

When I started debugging, I found this line that adds the suffix 0000 to the filenames irrespective of whether the filename has the suffix or not, and therefore it throws the above error.

Do you have any solutions for this? Or is there any step that I'm doing wrong?

Thanks!

sainatarajan commented 3 years ago

Issue solved. Error in the dataset.json

sunshinelike commented 2 years ago

Can you share your experience with solving this problem? Thanks a lot! I meet the same issue.

sainatarajan commented 2 years ago

@sunshinelike I hope this helps. Your folder structure should look something like this:

Task600_Spine/
    ├── dataset.json
    ├── imagesTr
    │   ├── vert_001_0000.nii.gz
    │   ├── vert_002_0000.nii.gz
    │   ├── ...
    └── labelsTr
        ├── vert_001.nii.gz
        ├── vert_002.nii.gz
        ├── ...

And your dataset.json should look something like this:

{
    "name": "Vertebra Segmentation",
    "description": "Vertebra Segmentation",
    "reference": "NCSD 2013",
    "licence": "CC-BY-SA 4.0",
    "relase": "1.0 04/05/2018",
    "tensorImageSize": "3D",
    "modality": {
        "0": "CT"
    },
    "labels": {
        "0": "background",
        "1": "Vertebra"
    },
    "numTraining": 30,
    "test": [],
    "training": [
        {
            "image": "./imagesTr/Vert_001.nii.gz",
            "label": "./labelsTr/Vert_001.nii.gz"
        },...,
        {
            "image": "./imagesTr/Vert_030.nii.gz",
            "label": "./labelsTr/Vert_030.nii.gz"
        }
    ]
}
sunshinelike commented 2 years ago

oh ,I see. Thank you very much.😊 Thank you for your quick response.