-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Unused 'affine' argument in Spacing transform #4791
Copy link
Copy link
Closed
Description
Describe the bug
The Spacing transform accepts an affine argument, but the argument is unused by the __call__ function and has no effect on the output.
To Reproduce
from monai import transforms as trans
from monai.data.meta_tensor import MetaTensor
def test_monai_utils():
# fake data
x = np.ones((1, 64, 64, 64))
# fake affines
affine_1 = np.eye(4)
affine_2 = np.eye(4) * 2
resamp = trans.Spacing(pixdim=[1, 1, 1], diagonal=False, mode='bilinear')
# using MetaTensor works as expected
y_1 = resamp(MetaTensor(x, affine=affine_1))
y_2 = resamp(MetaTensor(x, affine=affine_2))
assert not all(i == j for i, j in zip(y_1.shape, y_2.shape))
# using affine has no effect
y_1 = resamp(x, affine=affine_1)
y_2 = resamp(x, affine=affine_2)
# these shapes should be different!
assert not all(i == j for i, j in zip(y_1.shape, y_2.shape))Expected behavior
Either have the affine argument override the input data_array.affine, or remove the affine argument altogether in favor of data_array.affine.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels