Skip to content

allow ROIs bigger than image for RandCropByPosNegLabel and RandCropByLabelClasses#3129

Merged
wyli merged 2 commits intoProject-MONAI:devfrom
rijobro:allow_smaller_rand_crop
Oct 15, 2021
Merged

allow ROIs bigger than image for RandCropByPosNegLabel and RandCropByLabelClasses#3129
wyli merged 2 commits intoProject-MONAI:devfrom
rijobro:allow_smaller_rand_crop

Conversation

@rijobro
Copy link
Copy Markdown
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.

@rijobro rijobro requested review from Nic-Ma and wyli October 14, 2021 12:56
@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 15, 2021

/build

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.

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