Skip to content

Augmentations

Source

CAREamics transformation Pydantic models.

NORM_AND_SPATIAL_UNION = Annotated[Union[NormalizeConfig, XYFlipConfig, XYRandomRotate90Config], Discriminator('name')] module-attribute

All transforms including normalization.

SPATIAL_TRANSFORMS_UNION = Annotated[Union[XYFlipConfig, XYRandomRotate90Config], Discriminator('name')] module-attribute

Available spatial transforms in CAREamics.

N2VManipulateConfig

Bases: TransformConfig

Pydantic model used to represent N2V manipulation.

Attributes:

Name Type Description
name Literal['N2VManipulate']

Name of the transformation.

roi_size int

Size of the masking region, by default 11.

masked_pixel_percentage float

Percentage of masked pixels, by default 0.2.

strategy Literal['uniform', 'median']

Strategy pixel value replacement, by default "uniform".

struct_mask_axis Literal['horizontal', 'vertical', 'none']

Axis of the structN2V mask, by default "none".

struct_mask_span int

Span of the structN2V mask, by default 5.

seed int

Random seed for reproducibility.

masked_pixel_percentage = Field(default=0.2, ge=0.05, le=10.0) class-attribute instance-attribute

Percentage of masked pixels per image.

roi_size = Field(default=11, ge=3, le=21) class-attribute instance-attribute

Size of the region where the pixel manipulation is applied.

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.

strategy = Field(default='uniform') class-attribute instance-attribute

Strategy for pixel value replacement.

struct_mask_axis = Field(default='none') class-attribute instance-attribute

Orientation of the structN2V mask. Set to "non" to not apply StructN2V.

struct_mask_span = Field(default=5, ge=3, le=15) class-attribute instance-attribute

Size of the structN2V mask.

model_dump(**kwargs)

Return the model as a dictionary.

Parameters:

Name Type Description Default
**kwargs

Pydantic BaseMode model_dump method keyword arguments.

{}

Returns:

Type Description
{str: Any}

Dictionary representation of the model.

odd_value(v) classmethod

Validate that the value is odd.

Parameters:

Name Type Description Default
v int

Value to validate.

required

Returns:

Type Description
int

The validated value.

Raises:

Type Description
ValueError

If the value is even.

NormalizeConfig

Bases: TransformConfig

Pydantic model used to represent Normalize transformation.

The Normalize transform is a zero mean and unit variance transformation.

Attributes:

Name Type Description
name Literal['Normalize']

Name of the transformation.

mean float

Mean value for normalization.

std float

Standard deviation value for normalization.

model_dump(**kwargs)

Return the model as a dictionary.

Parameters:

Name Type Description Default
**kwargs

Pydantic BaseMode model_dump method keyword arguments.

{}

Returns:

Type Description
{str: Any}

Dictionary representation of the model.

validate_means_stds()

Validate that the means and stds have the same length.

Returns:

Type Description
Self

The instance of the model.

TransformConfig

Bases: BaseModel

Pydantic model used to represent a transformation.

The model_dump method is overwritten to exclude the name field.

Attributes:

Name Type Description
name str

Name of the transformation.

model_dump(**kwargs)

Return the model as a dictionary.

Parameters:

Name Type Description Default
**kwargs

Pydantic BaseMode model_dump method keyword arguments.

{}

Returns:

Type Description
{str: Any}

Dictionary representation of the model.

XYFlipConfig

Bases: TransformConfig

Pydantic model used to represent XYFlip transformation.

Attributes:

Name Type Description
name Literal['XYFlip']

Name of the transformation.

p float

Probability of applying the transform, by default 0.5.

seed Optional[int]

Seed for the random number generator, by default None.

model_dump(**kwargs)

Return the model as a dictionary.

Parameters:

Name Type Description Default
**kwargs

Pydantic BaseMode model_dump method keyword arguments.

{}

Returns:

Type Description
{str: Any}

Dictionary representation of the model.

XYRandomRotate90Config

Bases: TransformConfig

Pydantic model used to represent the XY random 90 degree rotation transformation.

Attributes:

Name Type Description
name Literal['XYRandomRotate90']

Name of the transformation.

p float

Probability of applying the transform, by default 0.5.

seed Optional[int]

Seed for the random number generator, by default None.

model_dump(**kwargs)

Return the model as a dictionary.

Parameters:

Name Type Description Default
**kwargs

Pydantic BaseMode model_dump method keyword arguments.

{}

Returns:

Type Description
{str: Any}

Dictionary representation of the model.