Augmentations#
Augmentations are random, train-time data augmentations in
konfai/data/augmentation.py (base class DataAugmentation). Unlike transforms,
they are sampled per case and applied only during training:
Dataset:
augmentations:
DataAugmentation_0:
data_augmentations:
Flip: # bare name → konfai.data.augmentation.Flip
f_prob: [0, 0.5, 0.5] # per-axis flip probability
prob: 1
nb: 1 # number of augmented copies per sample
Note
Lifecycle. Parameters are drawn once per case index and cached, so every
patch of a case shares the same draw within an epoch (mandatory for patch
consistency). reset_state re-samples each epoch. A subclass implements
_state_init (sample params) and _compute (apply); _inverse supports
test-time augmentation reassembly.
Important
Only Mask and Permute may change spatial shape (verified against the
code). Everything else preserves geometry.
Spatial (Euler transforms)#
Reversible affine warps via grid_sample (nearest-neighbour for label tensors).
Name |
Purpose |
Key args (defaults) |
Shape |
Inv |
|---|---|---|---|---|
|
Random translation (voxels). |
|
no |
yes |
|
Random rotation (degrees). |
|
no |
yes |
|
Random log2-normal isotropic scale. |
|
no |
yes |
|
Per-axis random flip; optional vector-field channel negation. |
|
no |
yes (self-inverse) |
|
Random BSpline elastic warp (SimpleITK). |
|
no |
no |
|
Random spatial-axis permutation (3-D only). |
|
yes |
yes |
|
Randomly place a mask volume; outside → |
|
yes |
no |
Intensity (colour transforms)#
Apply a per-index colour affine to RGB(3-ch) or L(1-ch) tensors. Their inverse is a no-op (colour changes don’t move voxels).
Name |
Purpose |
Key args (defaults) |
|---|---|---|
|
Additive brightness. |
|
|
Multiplicative contrast (log2-normal). |
|
|
Random luma (value) inversion. |
— |
|
Random hue rotation. |
|
|
Random saturation scale. |
|
Other#
Name |
Purpose |
Key args (defaults) |
Notes |
|---|---|---|---|
|
Diffusion-style forward noising (zero-terminal-SNR β schedule). |
|
Its |
|
Random cutout box filled with |
|
Gating uses the base probability. |
Note
Elastix and Mask require SimpleITK. The vector_field flag on Flip should
only be enabled for single-channel or genuine vector-field groups.
Next steps#
Transforms — deterministic preprocessing (runs every workflow)
Datasets and groups — where the
augmentations:block sits in a configExtension points — write your own
DataAugmentation