Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement Apply and Resample #5436

Merged
merged 21 commits into from
Nov 25, 2022
Merged

Replacement Apply and Resample #5436

merged 21 commits into from
Nov 25, 2022

Conversation

atbenmurray
Copy link
Contributor

@atbenmurray atbenmurray commented Oct 30, 2022

Signed-off-by: Ben Murray ben.murray@gmail.com

Description

This is part of the work towards #4855. It adds:

  • a lazy apply method
  • A transform-like wrapper for apply called Apply
    - MetaMatrix and related functionality to represent abstracted grid and matrix transforms with metadata
  • A universal resample function that can be used to apply grid / matrix transforms
    - Functional spatial and croppad implementations that define but don't apply transforms

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.

@atbenmurray atbenmurray mentioned this pull request Oct 30, 2022
7 tasks
@atbenmurray atbenmurray mentioned this pull request Oct 30, 2022
33 tasks
@wyli
Copy link
Contributor

wyli commented Nov 1, 2022

/black
thanks, I think this PR introduces quite a few APIs at a time and some of them (MatrixFactory/MetaMatrix) need more discussions... is it possible to make it smaller, for example, only including croppad, apply, and an example of SpatialCrop transform, so that we can create a working example of lazy cropping, then finalise the functional and apply API? cc @ericspod @rijobro @Nic-Ma

@atbenmurray
Copy link
Contributor Author

atbenmurray commented Nov 1, 2022

thanks, I think this PR introduces quite a few APIs at a time and some of them (MatrixFactory/MetaMatrix) need more discussions... is it possible to make it smaller, for example, only including croppad, apply, and an example of SpatialCrop transform, so that we can create a working example of lazy cropping, then finalise the functional and apply API? cc @ericspod @rijobro @Nic-Ma

The problem is that MatrixFactory/MetaMatrix are the classes by which a lot of the internal stuff for lazy resampling is done. They could certainly change before the PR goes in, but that would necessitate some plumbing to happen and I don't know if I'll have time before I am on holiday. The key thing here at the moment is that this PR doesn't change any existing behaviour so if we want to refactor we certainly can.

What they do:

  • MatrixFactory is an attempt to wrap up the various affine operations in a way that it can be simply constructed by either defining dimensions, device etc or by passing a tensor so that is determined automatically, and used in an OO way.
  • MetaTensor is the transformation + metadata that accompanies it. It contains either a Matrix or a Grid object, depending

In theory, one or both could go, but it might make everything somewhat verbose. Neither are supposed to be user-facing

Might be a good topic for tomorrow, but I am trying to get the PRs as populated as possible for tonight.

@atbenmurray atbenmurray self-assigned this Nov 2, 2022
atbenmurray added a commit that referenced this pull request Nov 2, 2022
…nd dictionary transforms to operate while waiting for PR #5436

Signed-off-by: Ben Murray <ben.murray@gmail.com>
atbenmurray added a commit that referenced this pull request Nov 2, 2022
…al, array and dictionary transforms to operate while waiting for PR #5436

Signed-off-by: Ben Murray <ben.murray@gmail.com>
atbenmurray added a commit that referenced this pull request Nov 2, 2022
…al, array and dictionary transforms to operate while waiting for PR #5436

Signed-off-by: Ben Murray <ben.murray@gmail.com>
atbenmurray added a commit that referenced this pull request Nov 2, 2022
atbenmurray and others added 10 commits November 23, 2022 09:51
…with rabasing and automatic signatures

Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
Signed-off-by: Ben Murray <ben.murray@gmail.com>
monai-bot and others added 5 commits November 23, 2022 09:51
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
  - `_pending_operations` defaults to `MetaObj.get_default_applied_operations()`
  - removes the unused `Apply` class
  - fixes unit tests, style checks
  - torch.pi doesn't exist before torch 1.10

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
@wyli wyli marked this pull request as ready for review November 23, 2022 13:10
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Copy link
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.

@atbenmurray please make more changes if needed and let me know when you think it's ready.. cc @Nic-Ma this mainly introduces necessary APIs monai.transforms.lazy.*

@wyli
Copy link
Contributor

wyli commented Nov 24, 2022

/build

@wyli wyli merged commit 2c7ba9e into dev Nov 25, 2022
@wyli wyli deleted the lr_apply_2 branch November 25, 2022 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants