Sample input
sample_input
#
SampleInput
#
Bases: pydantic.BaseModel
Configuration model for processing medical imaging samples.
This class provides a standardized configuration for loading and processing medical imaging data, including DICOM crawling and ROI matching settings.
Attributes:
Name | Type | Description |
---|---|---|
directory |
pathlib.Path
|
Directory containing the input files. Must exist and be readable. |
dataset_name |
str | None
|
Optional name for the dataset. Defaults to the base name of the input directory. |
update_crawl |
bool
|
Whether to force a new crawl even if one exists. Default is False. |
n_jobs |
int
|
Number of jobs to run in parallel. Default is (CPU cores - 2) or 1. |
modalities |
list[str] | None
|
List of modalities to include. None means include all modalities. |
roi_matcher |
imgtools.coretypes.masktypes.ROIMatcher
|
Configuration for matching regions of interest in the images. |
Examples:
>>> from imgtools.io.loaders.sample_input import (
... SampleInput,
... )
>>> config = SampleInput(
... directory="data/NSCLC-Radiomics"
... )
>>> config.dataset_name
'NSCLC-Radiomics'
>>> # Using the factory method with ROI matching parameters
>>> config = SampleInput.build(
... directory="data/NSCLC-Radiomics",
... roi_match_map={
... "GTV": ["GTV.*"],
... "PTV": ["PTV.*"],
... },
... roi_ignore_case=True,
... roi_handling_strategy="merge",
... )
Methods:
Name | Description |
---|---|
build |
Create a SampleInput with separate parameters for ROIMatcher. |
default |
Create a default SampleInput instance. |
query |
Query the interlacer for a specific modality. |
crawler
property
#
interlacer
property
#
interlacer: imgtools.dicom.interlacer.Interlacer
Get the Interlacer instance, initializing it if needed.
Returns:
Type | Description |
---|---|
imgtools.dicom.interlacer.Interlacer
|
An Interlacer instance tied to the current crawler. |
Notes
The interlacer is lazily initialized on first access, which may trigger crawler initialization if it hasn't been accessed yet.
build
classmethod
#
build(
directory: str | pathlib.Path,
dataset_name: str | None = None,
update_crawl: bool = False,
n_jobs: int | None = None,
modalities: list[str] | None = None,
roi_match_map: imgtools.coretypes.masktypes.Valid_Inputs = None,
roi_ignore_case: bool = True,
roi_handling_strategy: (
str | imgtools.coretypes.masktypes.ROIMatchStrategy
) = imgtools.coretypes.masktypes.ROIMatchStrategy.MERGE,
roi_allow_multi_key_matches: bool = True,
roi_on_missing_regex: (
str
| imgtools.coretypes.masktypes.ROIMatchFailurePolicy
) = imgtools.coretypes.masktypes.ROIMatchFailurePolicy.IGNORE,
) -> "SampleInput"
Create a SampleInput with separate parameters for ROIMatcher.
This factory method allows users to specify ROIMatcher parameters directly instead of constructing a objects separately.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
class
|
The SampleInput class |
required |
|
str | pathlib.Path
|
Directory containing the input files |
required |
|
str | None
|
Name of the dataset, by default None (uses input directory name) |
None
|
|
bool
|
Whether to force recrawling, by default False |
False
|
|
int | None
|
Number of parallel jobs, by default None (uses CPU count - 2) |
None
|
|
list[str] | None
|
List of modalities to include, by default None (all) |
None
|
|
imgtools.coretypes.masktypes.Valid_Inputs
|
ROI matching patterns, by default None |
None
|
|
bool
|
Whether to ignore case in ROI matching, by default True |
True
|
|
str | imgtools.coretypes.masktypes.ROIMatchStrategy
|
Strategy for handling ROI matches, by default ROIMatchStrategy.MERGE |
imgtools.coretypes.masktypes.ROIMatchStrategy.MERGE
|
|
bool
|
Whether to allow one ROI to match multiple keys in the match_map. |
True
|
|
str | imgtools.coretypes.masktypes.ROIMatchFailurePolicy
|
How to handle when no ROI matches any pattern in match_map. |
imgtools.coretypes.masktypes.ROIMatchFailurePolicy.IGNORE
|
Returns:
Type | Description |
---|---|
imgtools.io.sample_input.SampleInput
|
Configured SampleInput instance |
Source code in src/imgtools/io/sample_input.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
default
classmethod
#
query
#
query(
modalities: str | None = None,
) -> list[list[imgtools.dicom.interlacer.SeriesNode]]
Query the interlacer for a specific modality.