AlbumentationsExplore
DocumentationExploreAdoptionCommercial LicenseBlog
GitHub

BiasField

Targets:
image
volume
Image Types:uint8, float16, float32

Simulate smooth MRI intensity inhomogeneity by multiplying images and volumes by a positive field sampled on a coarse spatial grid.

The transform samples zero-mean Gaussian log-gain coefficients, interpolates them across all spatial axes, and exponentiates the result. The field changes tissue intensity across space while preserving anatomy labels.

Arguments
std_range
tuple[float, float]
[0, 0.5]

Nondecreasing range in [0, 1] for the coarse log-gain standard deviation. Larger values produce stronger intensity variation. Zero gives exact identity. Default: (0.0, 0.5).

scale_range
tuple[float, float]
[0.025, 0.025]

Nondecreasing range in (0, 1] for the ratio of coarse axis length to input axis length. Smaller values produce smoother fields; 1.0 uses an unsmoothed voxel-wise log-gain grid. Each non-singleton coarse axis has at least two points. Default: (0.025, 0.025).

per_channel
bool
false

If True, sample independent log-gain coefficients for each channel. If False, share one field across channels. Default: False.

p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import albumentations as A
>>> import numpy as np
>>> volume = np.full((16, 64, 96, 1), 0.25, dtype=np.float32)
>>> mask3d = np.zeros((16, 64, 96), dtype=np.uint8)
>>> pipeline = A.Compose([
...     A.BiasField(std_range=(0.1, 0.3), scale_range=(0.02, 0.04), p=1),
... ], seed=137, strict=True)
>>> result = pipeline(volume=volume, mask3d=mask3d)
>>> result["volume"].shape
(16, 64, 96, 1)
Notes
  • Images use bilinear interpolation over (H, W); volumes use trilinear interpolation over (D, H, W). Singleton axes remain singleton. Batch elements and aligned additional targets share sampled coefficients.
  • The coarse axis length is min(size, max(2, int(size * scale))). The standard deviation describes the coarse coefficients; interpolation generally reduces the final log-field variance.
  • The positive gain is exp(interpolated_log_gain). Results are clipped to [0, 1] for float32 and rounded back into [0, 255] for uint8. Clipping can change contrast near the intensity maximum.
  • TorchIO uses std=0.5 and scale=0.025 as reference MRI settings. The default range samples up to that strength. Strong fields can obscure tissue contrast or alter clinical semantics; inspect augmented examples for the intended anatomy and task.
  • Parameters use voxel dimensions. Physical spacing and scanner-specific coil sensitivity are not modelled.
References
  • TorchIO BiasFieldhttps://docs.torchio.org/2.0/reference/transforms/bias_field/