Skip to content

Commit

Permalink
try to remove preprocessing dict
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau committed Oct 23, 2024
1 parent 5b47656 commit 442a0e3
Show file tree
Hide file tree
Showing 15 changed files with 1,043 additions and 269 deletions.
52 changes: 2 additions & 50 deletions clinicadl/caps_dataset/caps_dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,62 +56,14 @@ def read_json(json_path: Path) -> Dict[str, Any]:
parameters["deterministic"] = not parameters["nondeterministic"]
del parameters["nondeterministic"]

# Build preprocessing_dict
if "preprocessing_dict" not in parameters:
parameters["preprocessing_dict"] = {"mode": parameters["mode"]}
preprocessing_options = [
"preprocessing",
"use_uncropped_image",
"prepare_dl",
"custom_suffix",
"tracer",
"suvr_reference_region",
"patch_size",
"stride_size",
"slice_direction",
"slice_mode",
"discarded_slices",
"roi_list",
"uncropped_roi",
"roi_custom_suffix",
"roi_custom_template",
"roi_custom_mask_pattern",
]
for preprocessing_var in preprocessing_options:
if preprocessing_var in parameters:
parameters["preprocessing_dict"][preprocessing_var] = parameters[
preprocessing_var
]
del parameters[preprocessing_var]

# Add missing parameters in previous version of extract
if "use_uncropped_image" not in parameters["preprocessing_dict"]:
parameters["preprocessing_dict"]["use_uncropped_image"] = False

if (
"prepare_dl" not in parameters["preprocessing_dict"]
and parameters["mode"] != "image"
):
parameters["preprocessing_dict"]["prepare_dl"] = False

if (
parameters["mode"] == "slice"
and "slice_mode" not in parameters["preprocessing_dict"]
):
parameters["preprocessing_dict"]["slice_mode"] = "rgb"

if "preprocessing" not in parameters:
parameters["preprocessing"] = parameters["preprocessing_dict"]["preprocessing"]

from clinicadl.caps_dataset.caps_dataset_config import CapsDatasetConfig

config = CapsDatasetConfig.from_preprocessing_and_extraction_method(
extraction=parameters["mode"],
preprocessing_type=parameters["preprocessing"],
**parameters,
)
if "file_type" not in parameters["preprocessing_dict"]:
file_type = config.preprocessing.get_filetype()
parameters["preprocessing_dict"]["file_type"] = file_type.model_dump()

file_type = config.preprocessing.get_filetype()

return parameters
Loading

0 comments on commit 442a0e3

Please sign in to comment.