"vscode:/vscode.git/clone" did not exist on "d54ee0fb2660ead4d4bc5bf2d3225238407e3a96"
Commit 252fa7d2 authored by mibaumgartner's avatar mibaumgartner
Browse files

bugfix

parent 5852200b
...@@ -10,6 +10,7 @@ import SimpleITK as sitk ...@@ -10,6 +10,7 @@ import SimpleITK as sitk
from nndet.io import load_json, load_sitk from nndet.io import load_json, load_sitk
from nndet.io.paths import get_task, get_paths_from_splitted_dir from nndet.io.paths import get_task, get_paths_from_splitted_dir
from nndet.utils.config import load_dataset_info from nndet.utils.config import load_dataset_info
from nndet.utils.info import maybe_verbose_iterable
def env_guard(func): def env_guard(func):
...@@ -76,6 +77,7 @@ def check_dataset_file(task_name: str): ...@@ -76,6 +77,7 @@ def check_dataset_file(task_name: str):
Args: Args:
task_name: task identifier to check info for task_name: task identifier to check info for
""" """
print("Start dataset info check.")
cfg = load_dataset_info(get_task(task_name)) cfg = load_dataset_info(get_task(task_name))
_check_key_missing(cfg, "task", ktype=str) _check_key_missing(cfg, "task", ktype=str)
_check_key_missing(cfg, "dim", ktype=int) _check_key_missing(cfg, "dim", ktype=int)
...@@ -113,6 +115,7 @@ def check_dataset_file(task_name: str): ...@@ -113,6 +115,7 @@ def check_dataset_file(task_name: str):
if ic != idx: if ic != idx:
raise ValueError("Found wrong order of modalities in dataset info." raise ValueError("Found wrong order of modalities in dataset info."
f"Found {found_mods} but expected {list(range(len(found_mods)))}") f"Found {found_mods} but expected {list(range(len(found_mods)))}")
print("Dataset info check complete.")
def check_data_and_label_splitted( def check_data_and_label_splitted(
...@@ -138,6 +141,7 @@ def check_data_and_label_splitted( ...@@ -138,6 +141,7 @@ def check_data_and_label_splitted(
ValueError: instances in label info file need to start at 1 ValueError: instances in label info file need to start at 1
ValueError: instances in label info file need to be consecutive ValueError: instances in label info file need to be consecutive
""" """
print("Start data and label check.")
cfg = load_dataset_info(get_task(task_name)) cfg = load_dataset_info(get_task(task_name))
splitted_paths = get_paths_from_splitted_dir( splitted_paths = get_paths_from_splitted_dir(
...@@ -147,7 +151,7 @@ def check_data_and_label_splitted( ...@@ -147,7 +151,7 @@ def check_data_and_label_splitted(
test=test, test=test,
) )
for case_paths in splitted_paths: for case_paths in maybe_verbose_iterable(splitted_paths):
# check all files exist # check all files exist
for cp in case_paths: for cp in case_paths:
if not Path(cp).is_file(): if not Path(cp).is_file():
...@@ -167,7 +171,7 @@ def check_data_and_label_splitted( ...@@ -167,7 +171,7 @@ def check_data_and_label_splitted(
if j := not min(mask_info_instances) == 1: if j := not min(mask_info_instances) == 1:
raise ValueError(f"Instance IDs need to start at 1, found {j} in {mask_info_path}") raise ValueError(f"Instance IDs need to start at 1, found {j} in {mask_info_path}")
for i in range(len(mask_info_instances)): for i in range(1, len(mask_info_instances) + 1):
if i not in mask_info_instances: if i not in mask_info_instances:
raise ValueError(f"Exptected {i} to be an Instance ID in " raise ValueError(f"Exptected {i} to be an Instance ID in "
f"{mask_info_path} but only found {mask_info_instances}") f"{mask_info_path} but only found {mask_info_instances}")
...@@ -176,6 +180,7 @@ def check_data_and_label_splitted( ...@@ -176,6 +180,7 @@ def check_data_and_label_splitted(
if full_check: if full_check:
_full_check(case_paths, mask_info_path) _full_check(case_paths, mask_info_path)
print("Data and label check complete.")
def _full_check(case_paths: List[Path], mask_info_path: Optional[Path] = None) -> None: def _full_check(case_paths: List[Path], mask_info_path: Optional[Path] = None) -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment