Skip to content

Data

Source

Data Pydantic configuration models.

DataConfig

Bases: BaseModel

Data configuration.

If std is specified, mean must be specified as well. Note that setting the std first and then the mean (if they were both None before) will raise a validation error. Prefer instead set_mean_and_std to set both at once. Means and stds are expected to be lists of floats, one for each channel. For supervised tasks, the mean and std of the target could be different from the input data.

All supported transforms are defined in the SupportedTransform enum.

Examples:

Minimum example:

>>> data = DataConfig(
...     data_type="array", # defined in SupportedData
...     patch_size=[128, 128],
...     batch_size=4,
...     axes="YX"
... )

To change the image_means and image_stds of the data:

>>> data.set_means_and_stds(image_means=[214.3], image_stds=[84.5])

One can pass also a list of transformations, by keyword, using the SupportedTransform value:

>>> from careamics.config.support import SupportedTransform
>>> data = DataConfig(
...     data_type="tiff",
...     patch_size=[128, 128],
...     batch_size=4,
...     axes="YX",
...     transforms=[
...         {
...             "name": "XYFlip",
...         }
...     ]
... )

axes instance-attribute

Axes of the data, as defined in SupportedAxes.

batch_size = Field(default=1, ge=1, validate_default=True) class-attribute instance-attribute

Batch size for training.

data_type instance-attribute

Type of input data, numpy.ndarray (array) or paths (tiff, czi, and custom), as defined in SupportedData.

image_means = Field(default=None, min_length=0, max_length=32) class-attribute instance-attribute

Means of the data across channels, used for normalization.

image_stds = Field(default=None, min_length=0, max_length=32) class-attribute instance-attribute

Standard deviations of the data across channels, used for normalization.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

Patch size, as used during training.

target_means = Field(default=None, min_length=0, max_length=32) class-attribute instance-attribute

Means of the target data across channels, used for normalization.

target_stds = Field(default=None, min_length=0, max_length=32) class-attribute instance-attribute

Standard deviations of the target data across channels, used for normalization.

train_dataloader_params = Field(default={'shuffle': True}, validate_default=True) class-attribute instance-attribute

Dictionary of PyTorch training dataloader parameters. The dataloader parameters, should include the shuffle key, which is set to True by default. We strongly recommend to keep it as True to ensure the best training results.

transforms = Field(default=[XYFlipConfig(), XYRandomRotate90Config()], validate_default=True) class-attribute instance-attribute

List of transformations to apply to the data, available transforms are defined in SupportedTransform.

val_dataloader_params = Field(default={}, validate_default=True) class-attribute instance-attribute

Dictionary of PyTorch validation dataloader parameters.

all_elements_power_of_2_minimum_8(patch_list) classmethod

Validate patch size.

Patch size must be powers of 2 and minimum 8.

Parameters:

Name Type Description Default
patch_list list of int

Patch size.

required

Returns:

Type Description
list of int

Validated patch size.

Raises:

Type Description
ValueError

If the patch size is smaller than 8.

ValueError

If the patch size is not a power of 2.

axes_valid(axes) classmethod

Validate axes.

Axes must: - be a combination of 'STCZYX' - not contain duplicates - contain at least 2 contiguous axes: X and Y - contain at most 4 axes - not contain both S and T axes

Parameters:

Name Type Description Default
axes str

Axes to validate.

required

Returns:

Type Description
str

Validated axes.

Raises:

Type Description
ValueError

If axes are not valid.

set_3D(axes, patch_size)

Set 3D parameters.

Parameters:

Name Type Description Default
axes str

Axes.

required
patch_size list of int

Patch size.

required

set_default_pin_memory(dataloader_params) classmethod

Set default pin_memory for dataloader parameters if not provided.

  • If 'pin_memory' is not set, it defaults to True if CUDA is available.

Parameters:

Name Type Description Default
dataloader_params dict of {str: Any}

The dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The dataloader parameters with pin_memory default applied.

set_default_train_workers(dataloader_params) classmethod

Set default num_workers for training dataloader if not provided.

  • If 'num_workers' is not set, it defaults to the number of available CPU cores.

Parameters:

Name Type Description Default
dataloader_params dict of {str: Any}

The training dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The dataloader parameters with num_workers default applied.

set_means_and_stds(image_means, image_stds, target_means=None, target_stds=None)

Set mean and standard deviation of the data across channels.

This method should be used instead setting the fields directly, as it would otherwise trigger a validation error.

Parameters:

Name Type Description Default
image_means (ndarray, tuple or list)

Mean values for normalization.

required
image_stds (ndarray, tuple or list)

Standard deviation values for normalization.

required
target_means (ndarray, tuple or list)

Target mean values for normalization, by default ().

None
target_stds (ndarray, tuple or list)

Target standard deviation values for normalization, by default ().

None

set_val_workers_to_match_train()

Set validation dataloader num_workers to match training dataloader.

If num_workers is not specified in val_dataloader_params, it will be set to the same value as train_dataloader_params["num_workers"].

Returns:

Type Description
Self

Validated data model with synchronized num_workers.

shuffle_train_dataloader(train_dataloader_params) classmethod

Validate that "shuffle" is included in the training dataloader params.

A warning will be raised if shuffle=False.

Parameters:

Name Type Description Default
train_dataloader_params dict of {str: Any}

The training dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The validated training dataloader parameters.

Raises:

Type Description
ValueError

If "shuffle" is not included in the training dataloader params.

std_only_with_mean()

Check that mean and std are either both None, or both specified.

Returns:

Type Description
Self

Validated data model.

Raises:

Type Description
ValueError

If std is not None and mean is None.

validate_dimensions()

Validate 2D/3D dimensions between axes, patch size and transforms.

Returns:

Type Description
Self

Validated data model.

Raises:

Type Description
ValueError

If the transforms are not valid.

MaskFilterConfig

Bases: FilterConfig

Pydantic model for the mask coordinate filter.

coverage = Field(0.5, ge=0.0, le=1.0) class-attribute instance-attribute

Percentage of masked pixels required to keep a patch.

name = 'mask' class-attribute instance-attribute

Name of the filter.

p = Field(1.0, ge=0.0, le=1.0) class-attribute instance-attribute

Probability of applying the filter to a patch or coordinate.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Seed for the random number generator for reproducibility.

MaxFilterConfig

Bases: FilterConfig

Pydantic model for the max patch filter.

name = 'max' class-attribute instance-attribute

Name of the filter.

p = Field(1.0, ge=0.0, le=1.0) class-attribute instance-attribute

Probability of applying the filter to a patch or coordinate.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Seed for the random number generator for reproducibility.

threshold instance-attribute

Threshold for the minimum of the max-filtered patch.

MeanSTDFilterConfig

Bases: FilterConfig

Pydantic model for the mean std patch filter.

mean_threshold instance-attribute

Minimum mean intensity required to keep a patch.

name = 'mean_std' class-attribute instance-attribute

Name of the filter.

p = Field(1.0, ge=0.0, le=1.0) class-attribute instance-attribute

Probability of applying the filter to a patch or coordinate.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Seed for the random number generator for reproducibility.

std_threshold = None class-attribute instance-attribute

Minimum standard deviation required to keep a patch.

MeanStdConfig

Bases: BaseModel

Mean and standard deviation normalization configuration.

Holds mean and standard deviation statistics for input and target, used to normalize data. Each statistic can be a single float (applied globally to all channels) or a list of floats (one per channel). If not provided, statistics can be computed automatically.

Attributes:

Name Type Description
name Literal['mean_std']

Identifier for the mean-std normalization scheme.

input_means float | list[float] | None

Means for input normalization. None for automatic computation.

input_stds float | list[float] | None

Standard deviations for input normalization. None for automatic computation.

target_means float | list[float] | None

Means for target normalization. None for automatic computation.

target_stds float | list[float] | None

Standard deviations for target normalization. None for automatic computation.

per_channel bool

When True (default), statistics are computed independently for each channel. When False, a single statistic is computed across all channels.

needs_computation()

Check if statistics need to be computed.

Returns:

Type Description
bool

True if input statistics are missing, False otherwise.

set_input_stats(means, stds)

Set input means and stds together to avoid validation errors.

Parameters:

Name Type Description Default
means list[float]

Mean values per channel.

required
stds list[float]

Standard deviation values per channel.

required

set_target_stats(means, stds)

Set target means and stds together to avoid validation errors.

Parameters:

Name Type Description Default
means list[float]

Mean values per channel.

required
stds list[float]

Standard deviation values per channel.

required

validate_means_stds()

Validate that means and stds are provided in pairs or set to None.

Returns:

Type Description
Self

The validated model instance.

Raises:

Type Description
ValueError

If only one of means or stds is provided for input or target, or if paired lists have mismatched lengths.

MinMaxConfig

Bases: BaseModel

Min-max normalization configuration.

Stores minimum and maximum statistics for scaling data into a desired range. Each statistic can be a single float (applied globally to all channels) or a list of floats (one per channel). If not provided, statistics can be computed automatically.

Attributes:

Name Type Description
name Literal['min_max']

Identifier for min-max normalization.

input_mins float | list[float] | None

Minimum values for input normalization. None for automatic computation.

input_maxes float | list[float] | None

Maximum values for input normalization. None for automatic computation.

target_mins float | list[float] | None

Minimum values for target normalization. None for automatic computation.

target_maxes float | list[float] | None

Maximum values for target normalization. None for automatic computation.

per_channel bool

When True (default), statistics are computed independently for each channel. When False, a single statistic is computed across all channels.

needs_computation()

Check if min/max values need to be computed.

Returns:

Type Description
bool

True if input statistics are missing, False otherwise.

set_input_range(mins, maxes)

Set input mins and maxes together to avoid validation errors.

Parameters:

Name Type Description Default
mins list[float]

Minimum values per channel.

required
maxes list[float]

Maximum values per channel.

required

set_target_range(mins, maxes)

Set target mins and maxes together to avoid validation errors.

Parameters:

Name Type Description Default
mins list[float]

Minimum values per channel.

required
maxes list[float]

Maximum values per channel.

required

validate_mins_maxes()

Validate that mins and maxes are provided in pairs or both None.

Returns:

Type Description
Self

The validated model instance.

Raises:

Type Description
ValueError

If only one of mins or maxes is provided for input or target, or if paired lists have mismatched lengths.

NGDataConfig

Bases: BaseModel

Next-Generation Dataset configuration.

NGDataConfig are used for both training and prediction, with the patching strategy determining how the data is processed. Note that random is the only patching strategy compatible with training, while tiled and whole are only used for prediction.

All supported transforms are defined in the SupportedTransform enum.

augmentations = Field(default=(XYFlipConfig(), XYRandomRotate90Config()), validate_default=True) class-attribute instance-attribute

List of augmentations to apply to the data, available transforms are defined in SupportedTransform.

axes instance-attribute

Axes of the data, as defined in SupportedAxes.

batch_size = Field(default=1, ge=1, validate_default=True) class-attribute instance-attribute

Batch size for training.

channels = Field(default=None) class-attribute instance-attribute

Channels to use from the data. If None, all channels are used.

coord_filter = Field(default=None, discriminator='name') class-attribute instance-attribute

Coordinate filter to apply when using random patching. Only available if mode is training.

data_type instance-attribute

Type of input data.

in_memory = Field(default_factory=default_in_memory, validate_default=True) class-attribute instance-attribute

Whether to load all data into memory. This is only supported for 'array', 'tiff' and 'custom' data types. Must be True for array. If None, defaults to True for 'array', 'tiff' and custom, and False for 'zarr' and 'czi' data types.

mode instance-attribute

Dataset mode, either training, validating or predicting.

n_val_patches = Field(default=8, ge=0, validate_default=True) class-attribute instance-attribute

The number of patches to set aside for validation during training. This parameter will be ignored if separate validation data is specified for training.

normalization = Field(...) class-attribute instance-attribute

Normalization configuration to use.

patch_filter = Field(default=None, discriminator='name') class-attribute instance-attribute

Patch filter to apply when using random patching. Only available if mode is training.

patch_filter_patience = Field(default=5, ge=1) class-attribute instance-attribute

Number of consecutive patches not passing the filter before accepting the next patch.

patching = Field(..., discriminator='name') class-attribute instance-attribute

Patching strategy to use. Note that random is the only supported strategy for training, while tiled and whole are only used for prediction.

pred_dataloader_params = Field(default={}) class-attribute instance-attribute

Dictionary of PyTorch prediction dataloader parameters.

seed = Field(default_factory=generate_random_seed, gt=0) class-attribute instance-attribute

Random seed for reproducibility. If not specified, a random seed is generated.

train_dataloader_params = Field(default={'shuffle': True}, validate_default=True) class-attribute instance-attribute

Dictionary of PyTorch training dataloader parameters. The dataloader parameters, should include the shuffle key, which is set to True by default. We strongly recommend to keep it as True to ensure the best training results.

val_dataloader_params = Field(default={}) class-attribute instance-attribute

Dictionary of PyTorch validation dataloader parameters.

axes_valid(axes, info) classmethod

Validate axes.

Axes must: - be a combination of 'STCZYX' - not contain duplicates - contain at least 2 contiguous axes: X and Y - contain at most 4 axes - not contain both S and T axes

Parameters:

Name Type Description Default
axes str

Axes to validate.

required
info ValidationInfo

Validation information.

required

Returns:

Type Description
str

Validated axes.

Raises:

Type Description
ValueError

If axes are not valid.

batch_size_not_in_dataloader_params(dataloader_params) classmethod

Validate that batch_size is not set in the dataloader parameters.

batch_size must be set through batch_size field, not through the dataloader parameters.

Parameters:

Name Type Description Default
dataloader_params dict of {str: Any}

The dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The validated dataloader parameters.

Raises:

Type Description
ValueError

If batch_size is present in the dataloader parameters.

convert_mode(new_mode, new_patch_size=None, overlap_size=None, new_batch_size=None, new_data_type=None, new_axes=None, new_channels=None, new_in_memory=None, new_dataloader_params=None)

Convert a training dataset configuration to a different mode.

This method is intended to facilitate creating validation or prediction configurations from a training configuration.

To perform tile prediction when switching to predicting mode, please provide both new_patch_size and overlap_size. Switching mode to predicting without specifying new_patch_size and overlap_size will apply the default patching strategy, namely whole image strategy. new_patch_size and overlap_size are only used when switching to predicting.

channels=None will retain the same channels as in the current configuration. To select all channels, please specify all channels explicitly or pass channels='all'.

New dataloader parameters will be placed in the appropriate dataloader params field depending on the new mode.

To create a new training configuration, please use careamics.config.create_ng_data_configuration.

This method compares the new parameters with the current ones and raises errors if incompatible changes are requested, such as switching between 2D and 3D axes, or changing the number of channels. Incompatibility across parameters may be delegated to Pydantic validation.

Parameters:

Name Type Description Default
new_mode Literal['validating', 'predicting']

The new dataset mode, one of validating or predicting.

required
new_patch_size Sequence of int

New patch size. If None for predicting, uses default whole image strategy.

None
overlap_size Sequence of int

New overlap size. Necessary when switching to predicting with tiled patching.

None
new_batch_size int

New batch size.

None
new_data_type Literal['array', 'tiff', 'zarr', 'czi', 'custom']

New data type.

None
new_axes str

New axes.

None
new_channels Sequence of int or "all"

New channels.

None
new_in_memory bool

New in_memory value.

None
new_dataloader_params dict of {str: Any}

New dataloader parameters. These will be placed in the appropriate dataloader params field depending on the new mode.

None

Returns:

Type Description
NGDataConfig

New NGDataConfig with the updated mode and parameters.

Raises:

Type Description
ValueError

If conversion to training mode is requested, or if incompatible changes are requested.

is_3D()

Check if the data is 3D based on the axes.

Either "Z" is in the axes and patching patch_size has 3 dimensions, or for CZI data, "Z" is in the axes or "T" is in the axes and patching patch_size has 3 dimensions.

This method is used during NGConfiguration validation to cross checks dimensions with the algorithm configuration.

Returns:

Type Description
bool

True if the data is 3D, False otherwise.

propagate_seed_to_augmentations()

Propagate the main seed to all augmentations that support seeds.

This ensures that all augmentations use the same seed for reproducibility, unless they already have a seed explicitly set.

Returns:

Type Description
Self

Data model with propagated seeds.

propagate_seed_to_filters()

Propagate the main seed to patch and coordinate filters that support seeds.

This ensures that all filters use the same seed for reproducibility, unless they already have a seed explicitly set.

Returns:

Type Description
Self

Data model with propagated seeds.

propagate_seed_to_patching()

Propagate the main seed to the patching strategy if it supports seeds.

This ensures that the patching strategy uses the same seed for reproducibility, unless it already has a seed explicitly set.

Returns:

Type Description
Self

Data model with propagated seed.

set_default_pin_memory(dataloader_params) classmethod

Set default pin_memory for dataloader parameters if not provided.

  • If 'pin_memory' is not set, it defaults to True if CUDA is available.

Parameters:

Name Type Description Default
dataloader_params dict of {str: Any}

The dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The dataloader parameters with pin_memory default applied.

set_default_train_workers(dataloader_params) classmethod

Set default num_workers for training dataloader if not provided.

  • If 'num_workers' is not set, it defaults to the number of available CPU cores.

Parameters:

Name Type Description Default
dataloader_params dict of {str: Any}

The training dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The dataloader parameters with num_workers default applied.

set_val_workers_to_match_train()

Set validation dataloader num_workers to match training dataloader.

If num_workers is not specified in val_dataloader_params, it will be set to the same value as train_dataloader_params["num_workers"].

Returns:

Type Description
Self

Validated data model with synchronized num_workers.

shuffle_train_dataloader(train_dataloader_params) classmethod

Validate that "shuffle" is included in the training dataloader params.

A warning will be raised if shuffle=False.

Parameters:

Name Type Description Default
train_dataloader_params dict of {str: Any}

The training dataloader parameters.

required

Returns:

Type Description
dict of {str: Any}

The validated training dataloader parameters.

Raises:

Type Description
ValueError

If "shuffle" is not included in the training dataloader params.

validate_channels(channels, info) classmethod

Validate channels.

Channels must be a sequence of non-negative integers without duplicates. If channels are not None, then C must be present in the axes.

Parameters:

Name Type Description Default
channels Sequence of int or None

Channels to validate.

required
info ValidationInfo

Validation information.

required

Returns:

Type Description
Sequence of int or None

Validated channels.

Raises:

Type Description
ValueError

If channels are not valid.

validate_dimensions()

Validate 2D/3D dimensions between axes and patch size.

Returns:

Type Description
Self

Validated data model.

Raises:

Type Description
ValueError

If the patch size dimension is not compatible with the axes.

validate_filters_against_mode(filter_obj, info) classmethod

Validate that the filters are only used during training.

Parameters:

Name Type Description Default
filter_obj PatchFilters or CoordFilters or None

Filter to validate.

required
info ValidationInfo

Validation information.

required

Returns:

Type Description
PatchFilters or CoordFilters or None

Validated filter.

Raises:

Type Description
ValueError

If a filter is used in a mode other than training.

validate_in_memory_with_data_type(in_memory, info) classmethod

Validate that in_memory is compatible with data_type.

in_memory can only be True for 'array', 'tiff' and 'custom' data types.

Parameters:

Name Type Description Default
in_memory bool

Whether to load data into memory.

required
info Any

Additional information about the field being validated.

required

Returns:

Type Description
bool

Validated in_memory value.

Raises:

Type Description
ValueError

If in_memory is True for unsupported data types.

validate_patching_strategy_against_mode(patching, info) classmethod

Validate that the patching strategy is compatible with the dataset mode.

  • If mode is training, patching strategy must be random or stratified.
  • If mode is validating, patching must be fixed_random.
  • If mode is predicting, patching strategy must be tiled or whole.

Parameters:

Name Type Description Default
patching PatchingStrategies

Patching strategy to validate.

required
info ValidationInfo

Validation information.

required

Returns:

Type Description
PatchingStrategies

Validated patching strategy.

Raises:

Type Description
ValueError

If the patching strategy is not compatible with the dataset mode.

NoNormConfig

Bases: BaseModel

No normalization configuration.

Indicates that no normalization should be applied.

Attributes:

Name Type Description
name Literal['none']

Identifier for no normalization scheme.

needs_computation()

Check if statistics need to be computed.

Returns:

Type Description
bool

Always False, as no statistics are required.

QuantileConfig

Bases: BaseModel

Quantile normalization configuration.

Normalizes data using quantile-based range scaling. Quantile levels can be specified as a single value (applied to all channels) or a list (one per channel). If not provided, quantile values can be computed automatically.

Attributes:

Name Type Description
name Literal['quantile']

Identifier for quantile normalization.

lower_quantiles float | list[float]

Lower quantile level(s). Values must be in [0, 1).

upper_quantiles float | list[float]

Upper quantile level(s). Values must be in (0, 1].

input_lower_quantile_values float | list[float] | None

Computed lower quantile values for input.

input_upper_quantile_values float | list[float] | None

Computed upper quantile values for input.

target_lower_quantile_values float | list[float] | None

Computed lower quantile values for target.

target_upper_quantile_values float | list[float] | None

Computed upper quantile values for target.

per_channel bool

When True (default), quantile values are computed independently for each channel. When False, a single quantile is computed across all channels.

needs_computation()

Check if quantile values need to be computed.

Returns:

Type Description
bool

True if quantile values need to be computed.

set_input_quantile_values(lower, upper)

Set input quantile values together to avoid validation errors.

Parameters:

Name Type Description Default
lower list[float]

Lower quantile values per channel.

required
upper list[float]

Upper quantile values per channel.

required

set_target_quantile_values(lower, upper)

Set target quantile values together to avoid validation errors.

Parameters:

Name Type Description Default
lower list[float]

Lower quantile values per channel.

required
upper list[float]

Upper quantile values per channel.

required

validate_per_channel()

Validate quantile levels match per_channel setting.

Returns:

Type Description
Self

The validated model instance.

Raises:

Type Description
ValueError

If per_channel=False but quantile levels are not length 1.

validate_quantile_levels()

Validate quantile levels are in valid range and properly ordered.

Returns:

Type Description
Self

The validated model instance.

validate_quantile_values()

Validate that computed quantile value lists are provided in pairs.

Returns:

Type Description
Self

The validated model instance.

RandomPatchingConfig

Bases: _PatchedConfig

Random patching Pydantic model.

Attributes:

Name Type Description
name random

The name of the patching strategy.

patch_size sequence of int

The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

name = 'random' class-attribute instance-attribute

The name of the patching strategy.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions, each patch size must be a power of 2 and larger than 8.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Random seed for patch sampling, set to None for random seeding.

all_elements_power_of_2_minimum_8(patch_list) classmethod

Validate patch size.

Patch size must be powers of 2 and minimum 8.

Parameters:

Name Type Description Default
patch_list Sequence of int

Patch size.

required

Returns:

Type Description
Sequence of int

Validated patch size.

Raises:

Type Description
ValueError

If the patch size is smaller than 8.

ValueError

If the patch size is not a power of 2.

ShannonFilterConfig

Bases: FilterConfig

Pydantic model for the Shannon entropy patch filter.

name = 'shannon' class-attribute instance-attribute

Name of the filter.

p = Field(1.0, ge=0.0, le=1.0) class-attribute instance-attribute

Probability of applying the filter to a patch or coordinate.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Seed for the random number generator for reproducibility.

threshold instance-attribute

Minimum Shannon entropy required to keep a patch.

TiledPatchingConfig

Bases: _OverlappingPatchedConfig

Tiled patching Pydantic model.

Attributes:

Name Type Description
name tiled

The name of the patching strategy.

patch_size sequence of int

The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

overlaps sequence of int

The overlaps between patches in each spatial dimension. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

name = 'tiled' class-attribute instance-attribute

The name of the patching strategy.

overlaps = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The overlaps between patches in each spatial dimension. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions, each patch size must be a power of 2 and larger than 8.

all_elements_power_of_2_minimum_8(patch_list) classmethod

Validate patch size.

Patch size must be powers of 2 and minimum 8.

Parameters:

Name Type Description Default
patch_list Sequence of int

Patch size.

required

Returns:

Type Description
Sequence of int

Validated patch size.

Raises:

Type Description
ValueError

If the patch size is smaller than 8.

ValueError

If the patch size is not a power of 2.

overlap_even(overlaps) classmethod

Validate overlaps.

Overlap must be even.

Parameters:

Name Type Description Default
overlaps Sequence of int

Overlaps.

required

Returns:

Type Description
Sequence of int

Validated overlap.

overlap_smaller_than_patch_size(overlaps, values) classmethod

Validate overlap.

Overlaps must be smaller than the patch size in each spatial dimension.

Parameters:

Name Type Description Default
overlaps Sequence of int

Overlap in each dimension.

required
values ValidationInfo

Dictionary of values.

required

Returns:

Type Description
Sequence of int

Validated overlap.

WholePatchingConfig

Bases: BaseModel

Whole image patching Pydantic model.

name = 'whole' class-attribute instance-attribute

The name of the patching strategy.