Skip to content

SpacingD transform bug for certain affine input #5253

@wyli

Description

@wyli

I use the SpacingD transforms after LoadImageD and AddChannelD. I read in a nifti file of shape [368, 336, 368] , the input to the spacingD [1, 368, 336, 368]. The outputs of spacingD is a matrix with zeros.

I followed the trace and the last time I see non-zeros matrix is at

https://github.com/Project-MONAI/MONAI/blob/dev/monai/networks/layers/spatial_transforms.py#L575

The generated grid has a range [1,3] but the torch.grid_sample expects range [-1, 1].
More details here-
https://pytorch.org/docs/stable/generated/torch.nn.functional.affine_grid.html
https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html

I tried it various nifti files and gives me the same trouble. When I change the range to the expected range by substracting 2. i get a output, which looks good.

Can anyone verify the issue. I am using MonAi 1.0.0

Originally posted by @a-parida12 in #5241

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions