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

Add sample_std parameter to RandGaussianNoise. #7492

Merged
merged 4 commits into from
Feb 26, 2024
Merged

Conversation

bakert1
Copy link
Contributor

@bakert1 bakert1 commented Feb 26, 2024

Fixes issue #7425

Description

Add a sample_std parameter to RandGaussianNoise and RandGaussianNoised. When True, the Gaussian's standard deviation is sampled uniformly from 0 to std (i.e., what is currently done). When False, the noise's standard deviation is non-random and set to std. The default for sample_std would be True for backwards compatibility.

Changes were based on RandRicianNoise which already has a sample_std parameter and is similar to RandGaussianNoise in concept and implementation.

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 --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@bakert1
Copy link
Contributor Author

bakert1 commented Feb 26, 2024

Question: I added the new sample_std parameter to the end of the RandGaussianNoise and RandGaussianNoised __init__ functions as to not break existing code that passed parameters by position. However, it seems weird that allow_missing_keys is not the last parameter of RandGaussianNoised. What is the correct trade-off between code consistency and backwards compatibility?

I, Timothy Baker <bakertim@umich.edu>, hereby add my Signed-off-by to this commit: 420a2d1
I, Timothy Baker <bakertim@umich.edu>, hereby add my Signed-off-by to this commit: 7574aa0

Signed-off-by: Timothy Baker <bakertim@umich.edu>
@KumoLiu
Copy link
Contributor

KumoLiu commented Feb 26, 2024

I added the new sample_std parameter to the end of the RandGaussianNoise and RandGaussianNoised init functions as to not break existing code that passed parameters by position

This way should be ok.

@bakert1
Copy link
Contributor Author

bakert1 commented Feb 26, 2024

Cool thanks. Also, I am running tests locally and the tests/test_integration_classification_2d.py test seems to be running slow. I think it's because I am running on Mac silicon (i.e., no CUDA device) - is there anyway around this?

Not sure the integration tests are necessary for such a small change, but I may work on other MONAI features in the future.

@KumoLiu
Copy link
Contributor

KumoLiu commented Feb 26, 2024

Not sure the integration tests are necessary for such a small change, but I may work on other MONAI features in the future.

It would be great if the tests in the relevant part could be tested. Of course, I will do more tests before merging.

@bakert1
Copy link
Contributor Author

bakert1 commented Feb 26, 2024

Not sure the integration tests are necessary for such a small change, but I may work on other MONAI features in the future.

It would be great if the tests in the relevant part could be tested. Of course, I will do more tests before merging.

Yeah I added a test for the new sample_std parameter and ran the tests related to RandGaussianNoise as well the quick tests. Everything passed locally.

@KumoLiu
Copy link
Contributor

KumoLiu commented Feb 26, 2024

/build

@bakert1 bakert1 marked this pull request as ready for review February 26, 2024 12:42
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.

Looks good to me, I don't think these changes will affect compatibility anywhere.

@KumoLiu
Copy link
Contributor

KumoLiu commented Feb 26, 2024

/build

@KumoLiu KumoLiu enabled auto-merge (squash) February 26, 2024 15:40
@KumoLiu KumoLiu merged commit 7cfa2c9 into Project-MONAI:dev Feb 26, 2024
28 checks passed
@YanxuanLiu
Copy link
Collaborator

/build

6 similar comments
@YanxuanLiu
Copy link
Collaborator

/build

@YanxuanLiu
Copy link
Collaborator

/build

@YanxuanLiu
Copy link
Collaborator

/build

@YanxuanLiu
Copy link
Collaborator

/build

@YanxuanLiu
Copy link
Collaborator

/build

@YanxuanLiu
Copy link
Collaborator

/build

juampatronics pushed a commit to juampatronics/MONAI that referenced this pull request Mar 25, 2024
Fixes issue Project-MONAI#7425

### Description

Add a `sample_std` parameter to `RandGaussianNoise` and
`RandGaussianNoised`. When True, the Gaussian's standard deviation is
sampled uniformly from 0 to std (i.e., what is currently done). When
False, the noise's standard deviation is non-random and set to std. The
default for sample_std would be True for backwards compatibility.

Changes were based on RandRicianNoise which already has a `sample_std`
parameter and is similar to RandGaussianNoise in concept and
implementation.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Timothy Baker <bakertim@umich.edu>
Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this pull request Apr 11, 2024
Fixes issue Project-MONAI#7425

### Description

Add a `sample_std` parameter to `RandGaussianNoise` and
`RandGaussianNoised`. When True, the Gaussian's standard deviation is
sampled uniformly from 0 to std (i.e., what is currently done). When
False, the noise's standard deviation is non-random and set to std. The
default for sample_std would be True for backwards compatibility.

Changes were based on RandRicianNoise which already has a `sample_std`
parameter and is similar to RandGaussianNoise in concept and
implementation.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Timothy Baker <bakertim@umich.edu>
Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
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.

4 participants