Skip to content

3087 enhance usage of intensity RandomizableTransform#3094

Merged
wyli merged 18 commits intoProject-MONAI:devfrom
Nic-Ma:3087-enhance-array-transform
Oct 12, 2021
Merged

3087 enhance usage of intensity RandomizableTransform#3094
wyli merged 18 commits intoProject-MONAI:devfrom
Nic-Ma:3087-enhance-array-transform

Conversation

@Nic-Ma
Copy link
Copy Markdown
Contributor

@Nic-Ma Nic-Ma commented Oct 9, 2021

Fixes #3087 .

Description

This PR implemented the proposal in #3087 to leverage array transform in the dict transform, it truly reduced much redundant code and made the logic more clear.

Status

Ready

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

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 9, 2021

/black

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 9, 2021

Hi @rijobro @wyli ,

I have updated half of the intensity transforms in this PR based on the proposal in #3087 , could you please help review it first?
I also fixed several minor issues in the intensity transforms in this PR.
If you guys have no concerns, I will try to complete all the other RandomizableTransform ASAP.

Thanks in advance.

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

Hi @rijobro ,

After offline discussion with @wyli , I will update this PR to align with your proposal(adding a randomize arg).

Thanks.

@rijobro
Copy link
Copy Markdown
Contributor

rijobro commented Oct 11, 2021

Ok @Nic-Ma, sounds good. For what it's worth, I wonder if splitting the methods into randomize and compute might be better than my suggestion. I'm not sure. Why did you decide that my way might be better? CC @wyli

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

Hi @rijobro ,

@wyli thinks that changing to compute() may be too big a modification, I will update this PR to minimize it.
We can consider compute() later if necessary.

Thanks.

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 11, 2021

Yes @rijobro, because we think having separate compute and __call__ may introduce additional API concepts and add unnecessary complexity for the current use case. We discussed that the simple flag method can already achieve the feature requested.

@rijobro
Copy link
Copy Markdown
Contributor

rijobro commented Oct 11, 2021

Ok sounds good. Thanks for the info

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

Hi @rijobro @wyli ,

In the latest commit, I updated RandGaussianNoise as example to show the proposal:

  1. In both randomize() and __call__(), only execute computation when do_transform=True.
  2. In __call__(), add a flag randomize to control whether to call self.randomize() function.
  3. In dict transform, set prob=1.0 for the array transform in it to make sure always execute.
  4. If possible, make sure all the keys of dict transform share the same random factors.

Could you please help review this proposal before I continue to update all the others?

Thanks in advance.

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 11, 2021

Thanks @Nic-Ma, RandGaussianNoise looks good to me.

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

Hi @rijobro ,

Do you have any more comments? If not, I will try to update others ASAP.

Thanks.

@rijobro
Copy link
Copy Markdown
Contributor

rijobro commented Oct 11, 2021

RandGaussianNoise and RandGaussianNoised look great to me, thanks.

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

/black

@Nic-Ma Nic-Ma requested review from rijobro and wyli October 11, 2021 17:09
@Nic-Ma Nic-Ma changed the title [WIP] 3087 enhance array version RandomizableTransform 3087 enhance usage of intensity RandomizableTransform Oct 11, 2021
@Nic-Ma Nic-Ma marked this pull request as ready for review October 11, 2021 17:11
@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

Hi @rijobro @wyli ,

I have updated all the intensity transforms in this PR.
I think this PR is already very big, could you please help review it first?
Then I will try to update other transform categories in another PR soon.

Thanks in advance.

Signed-off-by: Nic Ma <[email protected]>
@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 11, 2021

/black

@Nic-Ma
Copy link
Copy Markdown
Contributor Author

Nic-Ma commented Oct 12, 2021

/black

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 12, 2021

/integration-test

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 12, 2021

/build

1 similar comment
@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 12, 2021

/build

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Oct 12, 2021

/integration-test

Copy link
Copy Markdown
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.

Thanks, it looks good to me.

@wyli wyli merged commit e0f84f2 into Project-MONAI:dev Oct 12, 2021
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.

Reduce code duplication -- Random dictionary transforms that can't call their array version

3 participants