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

allow ROIs bigger than image for RandCropByPosNegLabel and RandCropByLabelClasses #3129

Merged
merged 2 commits into from
Oct 15, 2021

Conversation

rijobro
Copy link
Contributor

@rijobro rijobro commented Oct 14, 2021

Currently, if an image is already bigger than the requested padded ROI, by default we leave the image unchanged in that dimension.

Conversely, if an image is smaller than the requested ROI for RandCropByPosNegLabel and RandCropByLabelClasses, we throw an error. This is inconvenient for datasets of inhomogeneous shapes. For example, I might say "if an image is bigger than (100,100,100), then crop to this size. If it's smaller, then leave it as-is".

Currently, this is not possible in MONAI, so this PR adds allow_smaller. If True, any dimension smaller than the requested crop size won't be cropped, instead of raising an exception.

Default is set to False to keep backwards compatibility.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • 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.

…gLabel

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro requested review from wyli and Nic-Ma October 14, 2021 12:56
@wyli
Copy link
Contributor

wyli commented Oct 15, 2021

/build

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.

Thanks, this is a non-breaking usability improvement, looks good to me.

@wyli wyli merged commit 6155724 into Project-MONAI:dev Oct 15, 2021
@rijobro rijobro deleted the allow_smaller_rand_crop branch October 15, 2021 14:31
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