Skip to content

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

Merged
wyli merged 20 commits into
Project-MONAI:devfrom
aaronkujawa:intensity_transforms
Jun 8, 2023
Merged

wyli merged 20 commits into
Project-MONAI:devfrom
aaronkujawa:intensity_transforms

Conversation

@aaronkujawa

@aaronkujawa aaronkujawa commented May 23, 2023 •

Copy link
Copy Markdown
Contributor

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

wyli commented May 24, 2023

Copy link
Copy Markdown
Contributor

/build

Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
@Nic-Ma

Nic-Ma commented May 25, 2023

Copy link
Copy Markdown
Contributor

Hi @KumoLiu ,

Could you please help review this PR?

Thanks in advance.

@KumoLiu KumoLiu left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/array.py Outdated
Comment thread monai/transforms/intensity/dictionary.py Outdated
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>
Comment thread monai/transforms/intensity/array.py Outdated
aaronkujawa and others added 2 commits May 30, 2023 13:30

@wyli wyli left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@wyli

wyli commented Jun 8, 2023

Copy link
Copy Markdown
Contributor

/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