Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion monai/transforms/spatial/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = No
output_spatial_shape=output_shape_k if should_match else None,
lazy=lazy_,
)
output_shape_k = d[key].peek_pending_shape() if isinstance(d[key], MetaTensor) else d[key].shape[1:]
if output_shape_k is None:
Comment thread
wyli marked this conversation as resolved.
output_shape_k = d[key].peek_pending_shape() if isinstance(d[key], MetaTensor) else d[key].shape[1:]
return d

def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor]:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_spacingd.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@
*device,
)
)
TESTS.append(
(
"interp sep",
{
"image": MetaTensor(torch.ones((2, 1, 10)), affine=torch.eye(4)),
"seg1": MetaTensor(torch.ones((2, 1, 10)), affine=torch.diag(torch.tensor([2, 2, 2, 1]))),
"seg2": MetaTensor(torch.ones((2, 1, 10)), affine=torch.eye(4)),
},
dict(keys=("image", "seg1", "seg2"), mode=("bilinear", "nearest", "nearest"), pixdim=(1, 1, 1)),
(2, 1, 10),
torch.as_tensor(np.diag((1, 1, 1, 1))),
*device,
)
)

TESTS_TORCH = []
for track_meta in (False, True):
Expand Down