Skip to content

Fix For RandSmoothDeform Component Order#4973

Merged
ericspod merged 3 commits intoProject-MONAI:devfrom
ericspod:smooth_field_fix
Aug 23, 2022
Merged

Fix For RandSmoothDeform Component Order#4973
ericspod merged 3 commits intoProject-MONAI:devfrom
ericspod:smooth_field_fix

Conversation

@ericspod
Copy link
Copy Markdown
Member

Signed-off-by: Eric Kerfoot [email protected]

Description

One of the issues with torch.nn.functional.grid_sample is its definition of grid coordinate space versus dimensional ordering in inputs. The Pytorch ordering is HW or DHW which in coordinate terms is YX or ZYX, this is inverse to what the function actually expects in the component ordering of the grid given as input. The solution is to reverse the order of the component dimension. Added tests check that an image with a pattern is effectively unchanged with a deformation having almost 0 magnitude to verify images are not transposed in one dimension or another which was occurring without this fix.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Copy link
Copy Markdown
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Aug 23, 2022

/build

@ericspod
Copy link
Copy Markdown
Member Author

there were some discussions in pytorch as well https://discuss.pytorch.org/t/surprising-convention-for-grid-sample-coordinates/79997

Yes, I saw that earlier. So it's not just me!

@ericspod ericspod enabled auto-merge (squash) August 23, 2022 15:34
@ericspod ericspod merged commit 32af32c into Project-MONAI:dev Aug 23, 2022
@ericspod ericspod deleted the smooth_field_fix branch August 23, 2022 15:41
wojiazaiyugang pushed a commit to wojiazaiyugang/MONAI that referenced this pull request Aug 25, 2022
* Fix For RandSmoothDeform Component Order

Signed-off-by: Eric Kerfoot <[email protected]>

* Fix For RandSmoothDeform Component Order

Signed-off-by: Eric Kerfoot <[email protected]>

Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: wojiazaiyugang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants