BiasField
Bases: IntensityTransform
Corrupt an image with a smooth multiplicative bias field.
The bias field is generated by:
- Sampling a small 3D tensor from \(\mathcal{N}(0, \sigma)\).
- Trilinearly upsampling it to the image spatial shape.
- Taking the voxel-wise exponential to make it strictly positive.
- Multiplying the image by the resulting field.
This follows the approach used in SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
std
|
float | tuple[float, float] | Distribution
|
Standard deviation \(\sigma\) of the normal distribution
used to sample the coarse bias field. Larger values produce
stronger inhomogeneity. If two values \((a, b)\) are provided,
\(\sigma \sim \mathcal{U}(a, b)\). A
|
0.5
|
scale
|
float
|
Ratio between the coarse field size and the image spatial shape. Smaller values produce smoother fields. |
0.025
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> transform = tio.BiasField()
>>> transform = tio.BiasField(std=0.8)
>>> transform = tio.BiasField(std=(0.0, 1.0))
Source code in src/torchio/transforms/intensity/bias_field.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
invertible
property
Whether this transform can be inverted.
forward(data)
Apply the transform.
The output type always matches the input type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data to transform. |
required |
Source code in src/torchio/transforms/transform.py
to_hydra()
Export as a Hydra-compatible config dict.
Returns a dict with _target_ set to the fully qualified
class name and only non-default field values included.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict suitable for |
Source code in src/torchio/transforms/transform.py
make_params(batch)
Sample the bias field standard deviation (per element when batched).
Source code in src/torchio/transforms/intensity/bias_field.py
apply_transform(batch, params)
Multiply each selected image by a smooth random bias field.
Source code in src/torchio/transforms/intensity/bias_field.py
inverse(params)
Build the inverse by dividing by the same bias field.