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

Fix RandomWeightedCrop for Integer Weightmap Handling #8097

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

Han123su
Copy link
Contributor

@Han123su Han123su commented Sep 19, 2024

Fixes #7949 .

Description

Regardless of the type of weight map, random numbers should be kept as floating-point numbers for calculating the sampling location. However, searchsorted requires matching data structures. I have modified convert_to_dst_type to control converting only the data structure while maintaining the original data type. Additionally, I have included an example with integer weight maps in the test file.

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.

monai/transforms/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Han123su <popsmall212@gmail.com>
Signed-off-by: Han123su <popsmall212@gmail.com>
Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

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

I think this is fine as it is now, thanks.

Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, LGTM.

@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 20, 2024

/build

2 similar comments
@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 20, 2024

/build

@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 20, 2024

/build

Signed-off-by: Han123su <107395380+Han123su@users.noreply.github.com>
@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 20, 2024

/build

@KumoLiu KumoLiu merged commit fa1c1af into Project-MONAI:dev Sep 20, 2024
28 checks passed
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.

RandomWeightedCrop doesn't randomly generate crops for a weightmap of integers
3 participants