RemoveLabels
Bases: Transform
Set specified label values to a background value.
This is a convenience wrapper that builds a remapping dict
internally. For more control, use
RemapLabels directly.
Only LabelMap images are affected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Sequence[int]
|
Label values to remove. |
required |
background_label
|
int
|
Value to assign to removed labels. |
0
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> transform = tio.RemoveLabels([3, 4, 5])
>>> transform = tio.RemoveLabels([2], background_label=0)
Source code in src/torchio/transforms/label/remove_labels.py
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
inverse(params)
Return a transform that undoes this one.
Override in invertible subclasses. The returned transform, when applied, reverses the effect of the forward pass with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[str, Any]
|
The parameters recorded in the forward pass. |
required |
Returns:
| Type | Description |
|---|---|
Transform
|
A new |
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)
apply_transform(batch, params)
Set specified labels to the background value.