# Copyright (c) MONAI Consortium # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import annotations import logging import os from collections.abc import Sequence import numpy as np from monai.config import PathLike from monai.transforms import Compose, EnsureChannelFirstd, LoadImaged, Orientationd, Spacingd, SqueezeDimd, Transform from monai.utils import GridSampleMode def create_dataset( datalist: list[dict], output_dir: str, dimension: int, pixdim: Sequence[float] | float, image_key: str = "image", label_key: str = "label", base_dir: PathLike | None = None, limit: int = 0, relative_path: bool = False, transforms: Transform | None = None, ) -> list[dict]: """ Utility to pre-process and create dataset list for Deepgrow training over on existing one. The input data list is normally a list of images and labels (3D volume) that needs pre-processing for Deepgrow training pipeline. Args: datalist: A list of data dictionary. Each entry should at least contain 'image_key': . For example, typical input data can be a list of dictionaries:: [{'image': , 'label':