Description
RemapLabels, RemoveLabels, and OneHot modify label maps that should be excluded by the include or exclude arguments.
Reproduction
import torch
import torchio as tio
subject = tio.Subject(
a=tio.LabelMap(torch.ones(1, 2, 2, 2)),
b=tio.LabelMap(torch.ones(1, 2, 2, 2)),
)
result = tio.RemapLabels({1: 9}, include=["a"])(subject)
print(result.a.data.unique()) # tensor([9.])
print(result.b.data.unique()) # tensor([9.]), expected tensor([1.])
The same problem occurs with:
tio.RemapLabels({1: 9}, exclude=["b"])
tio.RemoveLabels([1], include=["a"])
tio.RemoveLabels([1], exclude=["b"])
tio.OneHot(include=["a"])
tio.OneHot(exclude=["b"])
Expected behavior
Only the selected label maps should change.
Excluded label maps should retain their original values and shape.
Possible cause
These transforms iterate over batch.images.items() directly instead of using self._get_images(batch), which applies the include/exclude filters.
Version
Reproduced on main, commit 2b019d2a9659c838408c73ae77327ac5eb87b190, TorchIO 2.0.0a2, using synthetic CPU tensors.
Description
RemapLabels,RemoveLabels, andOneHotmodify label maps that should be excluded by theincludeorexcludearguments.Reproduction
The same problem occurs with:
Expected behavior
Only the selected label maps should change.
Excluded label maps should retain their original values and shape.
Possible cause
These transforms iterate over
batch.images.items()directly instead of usingself._get_images(batch), which applies the include/exclude filters.Version
Reproduced on
main, commit2b019d2a9659c838408c73ae77327ac5eb87b190, TorchIO2.0.0a2, using synthetic CPU tensors.