Skip to content

with allow_missing_keys_mode#1714

Merged
rijobro merged 4 commits intoProject-MONAI:masterfrom
rijobro:with_allow_missing_keys_mode
Mar 8, 2021
Merged

with allow_missing_keys_mode#1714
rijobro merged 4 commits intoProject-MONAI:masterfrom
rijobro:with_allow_missing_keys_mode

Conversation

@rijobro
Copy link
Copy Markdown
Contributor

@rijobro rijobro commented Mar 8, 2021

Allows keys to be temporarily be missing from map transform using with:

data = {"image": np.arange(16, dtype=float).reshape(1, 4, 4)}
t = SpatialPadd(["image", "label"], 10, allow_missing_keys=False)
_ = t(data)  # would raise exception
with allow_missing_keys_mode(t):
    _ = t(data)  # OK!

This will be useful for doing the inverse of a segmented volume, since you probably won't need to do the inverse of the image key, only the label key.

Required apply_transform to be moved into transform.py to avoid circular import.

Status

Ready

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 --codeformat --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

rijobro added 2 commits March 8, 2021 10:48
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
@rijobro rijobro requested review from Nic-Ma and wyli and removed request for Nic-Ma March 8, 2021 11:03
Signed-off-by: Richard Brown <[email protected]>
Copy link
Copy Markdown
Contributor

@Nic-Ma Nic-Ma 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.
Thanks.

@rijobro rijobro enabled auto-merge (squash) March 8, 2021 12:06
@rijobro rijobro merged commit 08af0cc into Project-MONAI:master Mar 8, 2021
@rijobro rijobro deleted the with_allow_missing_keys_mode branch March 8, 2021 14:48
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.

2 participants