Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1509.
Description
When only
in_minorin_maxis specified,Normalizecurrently discards it and infers both bounds. Sample each explicit bound once and combine it with the per-image percentile range so the supplied endpoint is retained.The six original regression cases cover either endpoint,
Choiceinputs, masked percentiles for multiple images, and inverse restoration of clipped values. They fail on the unchanged base.Additional parameterized checks cover 96 combinations of bound modes, dtypes, 2D/3D multichannel shapes, masks, and subject/batch inputs against an independent NumPy reference; 18 random-bound cases; four empty-mask/zero-range cases; and six CPU/CUDA comparisons. Of these 124 additional cases, 70 fail and 54 pass on the unchanged base. All 163 tests (130 added and 33 existing) pass with this change, including the six CUDA cases on the local GPU.
Validation
python -m pytest tests/test_normalize.py -q— 163 passed.ruff check src/torchio/transforms/intensity/normalize.py tests/test_normalize.py— passed.ruff format --check src/torchio/transforms/intensity/normalize.py tests/test_normalize.py— passed.ty check src/torchio/transforms/intensity/normalize.py tests/test_normalize.py— passed.Checklist