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

2177 Add max_roi_size to RandSpatialCrop #2178

Merged
merged 8 commits into from
May 12, 2021

Conversation

Nic-Ma
Copy link
Contributor

@Nic-Ma Nic-Ma commented May 12, 2021

Fixes #2177 .

Description

This PR added support to limit the max random crop size in RandSpatialCrop.

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.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented May 12, 2021

/black

@Nic-Ma Nic-Ma marked this pull request as ready for review May 12, 2021 07:57
@Nic-Ma Nic-Ma changed the title [WIP] 2177 Add max_roi_size to RandSpatialCrop 2177 Add max_roi_size to RandSpatialCrop May 12, 2021
@rijobro
Copy link
Contributor

rijobro commented May 12, 2021

Do you think it would look nicer if, instead of adding max_roi_size, we modified roi_size to also take Sequence[Sequence[int]] i.e., roi_size=((10,10,10), (20, 20, 20))? It's just a shame that we have roi_size and max_roi_size, where roi_size actually means min_roi_size.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented May 12, 2021

Hi @rijobro ,

Thanks for your suggestion, but the problem is that:

  1. roi_size only acts as "min" size when random_size=True, if False, it's the fixed roi size to crop.
  2. We also support to set only 1 value for all the spatial dims in roi_size, for example: roi_size=128, if we put max_roi_size input roi_size as you suggested, when crop a 2D image, what roi_size=(128, 192) means? It can be roi_size=(128, 128) and max_roi_size=(192, 192), or roi_size=(128, 192), right?

What do you think?

Thanks.

Copy link
Contributor

@yiheng-wang-nv yiheng-wang-nv left a comment

Choose a reason for hiding this comment

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

Thanks Nic, I added some comments for this PR.

monai/transforms/croppad/array.py Outdated Show resolved Hide resolved
monai/transforms/croppad/array.py Outdated Show resolved Hide resolved
monai/transforms/croppad/array.py Outdated Show resolved Hide resolved
monai/transforms/croppad/dictionary.py Outdated Show resolved Hide resolved
monai/transforms/croppad/dictionary.py Outdated Show resolved Hide resolved
monai/transforms/croppad/dictionary.py Outdated Show resolved Hide resolved
monai/transforms/croppad/dictionary.py Show resolved Hide resolved
@rijobro
Copy link
Contributor

rijobro commented May 12, 2021

@Nic-Ma Ok makes sense. I suppose we can't change the behaviour of roi_size either, because of backwards compatibility. If we were designing it now, I would have roi_size, min_roi_size and max_roi_size where you can specify the first one or the latter two. Ah well, looks good!

I'll approve but agree with @yiheng-wang-nv 's suggested changes.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented May 12, 2021

Hi @rijobro and @yiheng-wang-nv ,

Thanks for your review, I will try to update the PR to address all the comments.

@Nic-Ma Nic-Ma enabled auto-merge (squash) May 12, 2021 12:38
@Nic-Ma Nic-Ma merged commit 89e3ff3 into Project-MONAI:dev May 12, 2021
yanielc pushed a commit to yanielc/MONAI that referenced this pull request May 13, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
Signed-off-by: Yaniel Cabrera <[email protected]>
yanielc pushed a commit to yanielc/MONAI that referenced this pull request May 13, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
Signed-off-by: Yaniel Cabrera <[email protected]>
wyli pushed a commit that referenced this pull request May 26, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
wyli pushed a commit that referenced this pull request May 26, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
wyli pushed a commit that referenced this pull request May 26, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
wyli pushed a commit that referenced this pull request May 27, 2021
* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] add max_roi_size

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] optimize logic

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <[email protected]>
@Nic-Ma Nic-Ma deleted the 2177-add-max-roi branch July 2, 2021 23:36
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.

Add max_roi_size support in RandSpatialCrop
3 participants