mrpro.phantoms.brainweb.augment

mrpro.phantoms.brainweb.augment(size: int = 256, trim: bool = True, max_random_shear: float = 5, max_random_rotation: float = 10, max_random_scaling_factor: float = 0.1, p_horizontal_flip: float = 0.5, p_vertical_flip: float = 0.5) Callable[[Tensor, Generator | None], Tensor][source]

Get an augmentation function.

Creates a function that applies augmentation to the input tensor consisting of rotation, shearing, scaling and horizontal/vertical flipping.

The image is scaled such that the largest dimension is in [size * (1 - max_random_scaling), size * (1 + max_random_scaling)], then padded/cropped to size size x size. In scaling, the aspect ratio is preserved. Random horizontal and vertical flips are applied with probability p_horizontal_flip and p_vertical_flip.

Parameters:
  • size (int, default: 256) – resulting image will be (size x size) pixels.

  • trim (bool, default: True) – If True, remove fully zero outer rows and columns before scaling

  • max_random_shear (float, default: 5) – Maximum random shear in degrees, shear is in [-max_shear, max_shear] in x and y direction.

  • max_random_rotation (float, default: 10) – Maximum random rotation in degrees, rotation is in [-max_rotation, max_rotation].

  • max_random_scaling_factor (float, default: 0.1) – Strength of the scaling randomization (see above).

  • p_horizontal_flip (float, default: 0.5) – Probability of horizontal flip.

  • p_vertical_flip (float, default: 0.5) – Probability of vertical flip.

Returns:

Callable that applies augmentation to the input tensor