MIC-DKFZ / nnUNet

Apache License 2.0
5.71k stars 1.73k forks source link

Issue (bugs) with function "key_to_label_or_region" when handling region-based labels #1470

Closed zzl120 closed 1 year ago

zzl120 commented 1 year ago

Hi,

I'm trying to run remove_connected_components.py to apply postprocessing to BraTS dataset which is region-based.

There is error when running: baseline_results = load_summary_json(join(folder_predictions, 'summary.json'))

The error message is

File "/home/.conda/envs/lib/python3.9/site-packages/nnunetv2/evaluation/evaluate_predictions.py", line 32, in return tuple([int(i) for i in splitted]) ValueError: invalid literal for int() with base 10: ''

which is traced back to the function key_to_label_or_region

def key_to_label_or_region(key: str): try: return int(key) except ValueError key = key.replace('(', '') key = key.replace(')', '') splitted = key.split(',') return tuple([int(i) for i in splitted])

I suppose this error is caused by the region-based labels. In the BraTS case, the corresponding label of "enhancing tumor" is (3,) , and the splitted is printed out to be ['3', ''] which appears to cause the error.

zzl120 commented 1 year ago

I suggest a simple solution to this error : return tuple([int(i) for i in splitted if i])

constantinulrich commented 1 year ago

Hi, sorry for the delay. We just assigned multiple team members to work on all issues. Your solution looks fine for your case. Did you follow the instructions how to define the regions here
Normally there should not be a "," for "enhancing tumor" .