MIC-DKFZ / nnUNet

Apache License 2.0
5.96k stars 1.77k forks source link

free(): invalid pointer #2500

Open Esther-shi opened 2 months ago

Esther-shi commented 2 months ago

Hi!

I'm getting started with nnUNet and when trying to preprocess my first dataset this happens: The estructures of my data is:

nnUNet_raw_data_base/nnUNet_raw_data/Dataset304_appendicular ├── dataset.json ├── imagesTr │ ├──appendicular_001_0000.nii.gz │ ├── appendicular_002_0000.nii.gz │ ├── ... └── labelsTr ├──appendicular_001.nii.gz ├── appendicular_002.nii.gz ├── ...

My dataset.json is:

{ "channel_names": { "0": "CT" }, "labels": { "background": 0, "Segment_2": 1,
"Segment_3": 2, "Segment_4": 3, "Segment_5": 4 }, "numTraining": 22, "numTest": 3, "file_ending": ".nii.gz" } and my environment variables are set as follows: export nnUNet_raw="/home/shm/totalsegmentator/nnUNet/DATASET/nnUNet_raw/" export nnUNet_preprocessed="/home/shm/totalsegmentator/nnUNet/DATASET/nnUNet_preprocessed/" export nnUNet_results="/home/shm/totalsegmentator/nnUNet/DATASET/nnUNet_results/"

But I get the following error when using the command: nnUNetv2_plan_and_preprocess -d 304 --verify_dataset_integrity

Error: Unexpected labels found in file /home/shm/totalsegmentator/nnUNet/DATASET/nnUNet_raw/Dataset304_appendicular/labelsTr/appendicular_002.nii.gz. Expected: [0, 1, 2, 3, 4] Found: [0. 2. 3. 4. 5.] Error: Unexpected labels found in file /home/shm/totalsegmentator/nnUNet/DATASET/nnUNet_raw/Dataset304_appendicular/labelsTr/appendicular_005.nii.gz. Expected: [0, 1, 2, 3, 4] Found: [0. 2. 3. 4. 5.] ……

(For every single image) So then I tried to change the dataset.json to: { "channel_names": { "0": "CT" }, "labels": { "background": 0, "Segment_1": 1,
"Segment_2": 2, "Segment_3": 3, "Segment_4": 4, "Segment_5": 5 }, "numTraining": 22, "numTest": 3, "file_ending": ".nii.gz" }

Then a big, bad new mistake happened when using the command: nnUNetv2_plan_and_preprocess -d 304 --verify_dataset_integrity: image

Finally I stopped the run

I don't know how to deal with this error please help.

Thank you!

gaojh135 commented 2 months ago

运行这个命令后,nnUNetv2_plan_and_preprocess -d 304 --verify_dataset_integrity,会检查你的标签是否是按0,1,2,3...的顺序, Expected: [0, 1, 2, 3, 4] Found: [0. 2. 3. 4. 5.] 这里就检查到你缺少1的标签,建议最好处理成这种按顺序的。 当然也可以运行,试试这样 nnUNetv2_plan_and_preprocess -d 304

mrokuss commented 4 days ago

Hey @Esther-shi

As the first error suggests something seems to be wrong with your labels. It seems that you only have 4 segments (Segment_2, ...) but the labels are 2,3,4,5 in the images, meaning label 1 is missing. nnUNet needs consecutive labels and will struggle with missing labels - this is probably why the second run failed when you changed the dataset.json.

Double check your labels in the labelsTr folder and if none of it has the label 1, remap all labels 2->1, 3->2, ..., 5->4 and try the first dataset.json again.

Hope this helps!