nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

Background label not declared

Open KavyaP-14 opened this issue 4 months ago • 2 comments

even though i have labeled the background as 0 in my dataset.json file , i still get the following error

Fingerprint extraction... Dataset999_BHSD Traceback (most recent call last): File "C:\Users\HP\miniconda3\envs\nnunet\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\HP\miniconda3\envs\nnunet\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "C:\Users\HP\miniconda3\envs\nnunet\Scripts\nnUNetv2_plan_and_preprocess.exe_main.py", line 7, in File "C:\Users\HP\miniconda3\envs\nnunet\lib\site-packages\nnunetv2\experiment_planning\plan_and_preprocess_entrypoints.py", line 180, in plan_and_preprocess_entry extract_fingerprints(args.d, args.fpe, args.npfp, args.verify_dataset_integrity, args.clean, args.verbose) File "C:\Users\HP\miniconda3\envs\nnunet\lib\site-packages\nnunetv2\experiment_planning\plan_and_preprocess_api.py", line 47, in extract_fingerprints extract_fingerprint_dataset(d, fingerprint_extractor_class, num_processes, check_dataset_integrity, clean, File "C:\Users\HP\miniconda3\envs\nnunet\lib\site-packages\nnunetv2\experiment_planning\plan_and_preprocess_api.py", line 30, in extract_fingerprint_dataset
verify_dataset_integrity(join(nnUNet_raw, dataset_name), num_processes) abel_handling.py", line 53, in _sanity_check raise RuntimeError('Background label not declared (remember that this should be label 0!)') RuntimeError: Background label not declared (remember that this should be label 0!)

this is how i have labeled it

"labels": { "0": "background", "1": "epidural", "2": "intraparenchymal", "3": "intraventricular", "4": "subarachnoid", "5": "subdural" },

KavyaP-14 avatar Aug 17 '25 07:08 KavyaP-14

Hi @KavyaP-14,

you just need to flip label indices and names and it should work fine, i.e. "labels": { "background": 0, "epidural": 1, "intraparenchymal": 2, "intraventricular": 3, "subarachnoid": 4, "subdural": 5 },

Best, Yannick

ykirchhoff avatar Aug 20 '25 15:08 ykirchhoff

Hi @KavyaP-14,

you just need to flip label indices and names and it should work fine, i.e. "labels": { "background": 0, "epidural": 1, "intraparenchymal": 2, "intraventricular": 3, "subarachnoid": 4, "subdural": 5 },

Best, Yannick

it work for me, thx !

Eddy-Cui avatar Sep 02 '25 08:09 Eddy-Cui