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

Added (Rand)ScaleScaleIntensityFixedMean(d) and modified (Rand)AdjustContrast(d) #6542

Merged
merged 20 commits into from
Jun 8, 2023

Conversation

aaronkujawa
Copy link
Contributor

@aaronkujawa aaronkujawa commented May 23, 2023

Description

This PR adds the intensity transform ScaleIntensityFixedMean (including its random and random dictionary version) and modifies the intensity transform AdjustContrast and its dictionary version. It adds functionality available in the corresponding nnU-Net transforms ContrastAugmentationTransform and GammaTransform.

Specifically, ScaleIntensityFixedMean scales the intensity of the input image by a factor v = v * (1 + factor) (same as the existing ScaleIntensity transform when used with the factor argument). The added functionality is provided by two arguments:

  1. fixed_mean: subtract the mean intensity before scaling with factor, then add the same value after scaling to ensure that the output has the same mean intensity as the input.

  2. preserve_range: clips the output array/tensor to the range of the input array/tensor

AdjustContrast was modified by adding two arguments:

  1. invert_image: multiplies all intensity values by -1 before gamma transform and again after gamma transform

  2. retain_stats: applies a scaling factor and an offset to all intensity values after the gamma transform to ensure that the output intensity distribution has the same mean and standard deviation as the intensity distribution of the input

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.

aaronkujawa and others added 7 commits May 22, 2023 13:26
I, Aaron Kujawa <askujawa@gmail.com>, hereby add my Signed-off-by to this commit: dce66d0
I, Aaron Kujawa <askujawa@gmail.com>, hereby add my Signed-off-by to this commit: b9b07bf

Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
@aaronkujawa aaronkujawa marked this pull request as ready for review May 24, 2023 07:47
@wyli
Copy link
Contributor

wyli commented May 24, 2023

/build

@Nic-Ma
Copy link
Contributor

Nic-Ma commented May 25, 2023

Hi @KumoLiu ,

Could you please help review this PR?

Thanks in advance.

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 PR, few comments inline.

monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/array.py Outdated Show resolved Hide resolved
monai/transforms/intensity/dictionary.py Outdated Show resolved Hide resolved
KumoLiu

This comment was marked as duplicate.

aaronkujawa and others added 9 commits May 30, 2023 09:07
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
Signed-off-by: Aaron Kujawa <askujawa@gmail.com>
aaronkujawa and others added 2 commits May 30, 2023 13:30
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.

Many thanks @aaronkujawa, I'm merging this after tagging v1.2.

@aaronkujawa
Copy link
Contributor Author

Thank you @ericspod, @KumoLiu, and @wyli for the reviewing!

@wyli
Copy link
Contributor

wyli commented Jun 8, 2023

/build

@wyli wyli enabled auto-merge (squash) June 8, 2023 17:29
@wyli wyli merged commit 52b3ed2 into Project-MONAI:dev Jun 8, 2023
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.

5 participants