Skip to content

3844 flexible min/max_pixdim options for Spacing#5212

Merged
wyli merged 4 commits intoProject-MONAI:devfrom
wyli:3844-flexible-spacing
Sep 27, 2022
Merged

3844 flexible min/max_pixdim options for Spacing#5212
wyli merged 4 commits intoProject-MONAI:devfrom
wyli:3844-flexible-spacing

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Sep 26, 2022

Signed-off-by: Wenqi Li [email protected]

Fixes #3844

Description

adding the flexibility for skipping the transform if the pixdim is in the specified range

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.

@wyli wyli marked this pull request as ready for review September 26, 2022 14:54
Copy link
Copy Markdown
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.

It looks good to me. Added two small suggestions, please ignore them if I have misunderstood them.

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Sep 27, 2022

Hi @wyli ,

Actually, to make the feature easier to understand, I suggest to only support: (1) Both min and max are None, (2) Both min and max are NOT None.
What do you think?

Thanks.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Sep 27, 2022

/build

thanks @Nic-Ma @KumoLiu, I've updated to use pixdim as the default when min/max are None, I think these are good default values and the user can

  • provide both min/max to avoid the defaults
  • provide min=0.0 max=np.inf to achieve the use case I was previously thinking

@wyli wyli merged commit ba670c9 into Project-MONAI:dev Sep 27, 2022
@wyli wyli deleted the 3844-flexible-spacing branch September 27, 2022 11:43
mx = target if np.isnan(mx) else max(mx, target)
if mn > mx:
raise ValueError(f"min_pixdim is larger than max_pixdim at dim {idx}: min {mn} max {mx} out {target}.")
out_d[idx] = _d if (mn - AFFINE_TOL) <= _d <= (mx + AFFINE_TOL) else target
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. if we define min and max pixdim, why do we need additional affine_tol here?
  2. if the resolution is withing the min / max, we simply want to skip the resampling completely. In this code, it seems all it does is records the original resolution and still does resampling in the next step (which will incur additional compute load and possible artifacts)

wyli added a commit that referenced this pull request Oct 10, 2022
Signed-off-by: Wenqi Li <[email protected]>

Fixes #3844

### Description
adding the flexibility for skipping the transform if the pixdim is in
the specified range

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [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: Wenqi Li <[email protected]>
KumoLiu pushed a commit that referenced this pull request Nov 2, 2022
Signed-off-by: Wenqi Li <[email protected]>

Fixes #3844

### Description
adding the flexibility for skipping the transform if the pixdim is in
the specified range

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [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: Wenqi Li <[email protected]>
Signed-off-by: KumoLiu <[email protected]>
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.

Resampling / Spacing enhancements

4 participants