Closed linamedicalimaging closed 6 months ago
I'm sorry, I realized that I forgot to post the error message from the CMD. Here's an addition of the error message I received (it's too long, so I've only included a part): (nnunet_ACDC_Heart) lina@UP-CS-GPU01:~/nnunet_ACDC_heart/nnUNet/nnunetv2/dataset_conversion$ nnUNetv2_plan_and_preprocess -d 300 --verify_dataset_integrity Fingerprint extraction... Dataset300_ACDCHeartSegmentation Using <class 'nnunetv2.imageio.natural_image_reader_writer.NaturalImage2DIO'> as reader/writer Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_124_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_149_0000.png'] Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_174_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_248_0000.png'] Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_1_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_222_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_199_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_272_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_125_0000.png'] ...... ...... ...... Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_826_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_827_0000.png']
Error: Unexpected number of modalities. Expected: 3. Got: 4. Images: ['/home/lina/nnunet_ACDC_heart/nnUNet/DATASET/nnUNet_raw/Dataset300_ACDCHeartSegmentation/imagesTr/image_828_0000.png']
Traceback (most recent call last):
File "/home/lina/anaconda3/envs/nnunet_ACDC_Heart/bin/nnUNetv2_plan_and_preprocess", line 8, in
Thank you again!!!
Hi @linamedicalimaging , the error comes from this line: https://github.com/MIC-DKFZ/nnUNet/blob/3808231601265aed98d70de4218fc845e185959d/nnunetv2/experiment_planning/verify_dataset_integrity.py#L84
Did you maybe not specify the correct image reader class for png?
Closing this issue for now, as it was stale for roughly a week. Please feel free to re-open if you're still facing this issue!
Dear @GregorKoehler:
I am having the same issue. I think it is a problem with the image channels that they are confused with the modalities (maybe somewhere is an ordering wrong (c,1,x,y) vs (1,c,x,y)?
<
<
I think I found the problem, the dimensions were ordered (c,1,x,y) but expected was (1,c,x,y). I created a PR on it: #2158
Hi, FabianIsensee, I have a question again.
I've been training nnUNet with my own dataset. I modified the script Dataset120_RoadSegmentation.py. Here are the modifications I made: **import multiprocessing import shutil from multiprocessing import Pool
from batchgenerators.utilities.file_and_folder_operations import *
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json from nnunetv2.paths import nnUNet_raw from skimage import io from acvl_utils.morphology.morphology_helper import generic_filter_components from scipy.ndimage import binary_fill_holes
def load_and_convert_case(input_image: str, input_seg: str, output_image: str, output_seg: str, min_component_size: int = 50): seg = io.imread(input_seg) seg[seg == 255] = 1 image = io.imread(input_image) image = image.sum(2) mask = image == (3 * 255)
the dataset has large white areas where road segmentations can exist but no image information is available.
if name == "main": source = '/home/lina/nnunet_ACDC_heart/Dataset_raw' dataset_name = 'Dataset300_ACDCHeartSegmentation' imagestr = join(nnUNet_raw, dataset_name, 'imagesTr') imagests = join(nnUNet_raw, dataset_name, 'imagesTs') labelstr = join(nnUNet_raw, dataset_name, 'labelsTr') labelsts = join(nnUNet_raw, dataset_name, 'labelsTs') maybe_mkdir_p(imagestr) maybe_mkdir_p(imagests) maybe_mkdir_p(labelstr) maybe_mkdir_p(labelsts)
After modifying, I ran the script “Dataset120_RoadSegmentation.py” and there were no errors. However, I noticed that the images in labelsTr were all white (instead of black). I didn't pay much attention to it and continued to run “nnUNetv2_plan_and_preprocess -d 300 --verify_dataset_integrity” in CMD. It showed that all data in imagesTr had issues: Error: Unexpected number of modalities.
I really don't know where the problem lies. I have previously trained nnUNet with my own data (.tif) quite smoothly. This time the data is in ".png" format.
Thank you for taking the time to read my question. I look forward to your reply.
Lina