Nnunet output
nnunet_output
#
MaskSavingStrategy
#
Bases: str
, enum.Enum
Enum for mask saving strategies.
Attributes:
Name | Type | Description |
---|---|---|
LABEL_IMAGE |
str
|
No overlaps allowed. |
SPARSE_MASK |
str
|
Allows overlaps, but is lossy if overlaps exist. |
REGION_MASK |
str
|
Work around that creates a new region for each overlap. |
MaskSavingStrategyError
#
Bases: imgtools.io.nnunet_output.nnUNetOutputError
Raised when an invalid mask saving strategy is provided.
MissingROIsError
#
Bases: imgtools.io.nnunet_output.nnUNetOutputError
Raised when a VectorMask does not contain all required ROI keys.
Source code in src/imgtools/io/nnunet_output.py
NoSegmentationImagesError
#
Bases: imgtools.io.nnunet_output.nnUNetOutputError
Raised when no segmentation images are found in a sample.
Source code in src/imgtools/io/nnunet_output.py
nnUNetOutput
#
Bases: pydantic.BaseModel
Configuration model for saving medical imaging outputs in nnUNet format.
This class provides a standardized configuration for saving medical images, supporting various file formats and output organization strategies.
Attributes:
Name | Type | Description |
---|---|---|
directory |
pathlib.Path
|
Directory where output files will be saved. Must exist and be writable. |
filename_format |
str
|
Format string for output filenames with placeholders for metadata values. |
existing_file_mode |
imgtools.io.writers.ExistingFileMode
|
How to handle existing files (FAIL, SKIP, OVERWRITE). |
extra_context |
typing.Dict[str, typing.Any]
|
Additional metadata to include when saving files. |
Examples:
>>> from imgtools.io import nnUNetOutput
>>> from imgtools.io.writers import ExistingFileMode
>>> output = nnUNetOutput(
... directory="results/patient_scans",
... existing_file_mode=ExistingFileMode.SKIP,
... )
>>> output(scan_list) # Save all scans in the list
Methods:
Name | Description |
---|---|
default |
Create a default instance of SampleOutput. |
finalize_dataset |
Finalize dataset by generating preprocessing scripts and dataset JSON configuration. |
model_post_init |
Initialize the writer after model initialization. |
validate_directory |
Validate that the output directory exists or can be created, and is writable. |
default
classmethod
#
default() -> imgtools.io.nnunet_output.nnUNetOutput
Create a default instance of SampleOutput.
Source code in src/imgtools/io/nnunet_output.py
finalize_dataset
#
Finalize dataset by generating preprocessing scripts and dataset JSON configuration.
Source code in src/imgtools/io/nnunet_output.py
model_post_init
#
Initialize the writer after model initialization.
Source code in src/imgtools/io/nnunet_output.py
validate_directory
classmethod
#
Validate that the output directory exists or can be created, and is writable.
nnUNetOutputError
#
Bases: Exception
Base class for errors related to sample data.