Skip to content

overriding argument bug in spatial_resample #4938

@wyli

Description

@wyli

Describe the bug
the align_corners default value is False in SpatialResample.__call__

align_corners: Optional[bool] = False,

this by default makes self.align_corners not in use, because:
align_corners = self.align_corners if align_corners is None else align_corners

it easily causes confusions and hides some bugs.

expected:
align_corners=None in SpatialResample.__call__

example to show the errors:

import torch

from monai.transforms import SpatialResample

img = torch.arange(12).reshape((1, 2, 2, 3))
xform = SpatialResample(mode=0, padding_mode="reflect", align_corners=True)
dst_affine = torch.tensor([[1.0, 0.0, 0.0, 0.0], [0.0, -1.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
print(xform(img, dst_affine=dst_affine))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions