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

6717 fixes current_mode check in convert_applied_interp_mode #6719

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions monai/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,10 @@ def convert_applied_interp_mode(trans_info, mode: str = "nearest", align_corners
trans_info = dict(trans_info)
if "mode" in trans_info:
current_mode = trans_info["mode"]
if current_mode[0] in _interp_modes:
trans_info["mode"] = [mode for _ in range(len(mode))]
elif current_mode in _interp_modes:
if isinstance(current_mode, int) or current_mode in _interp_modes:
trans_info["mode"] = mode
elif isinstance(current_mode[0], int) or current_mode[0] in _interp_modes:
trans_info["mode"] = [mode for _ in range(len(mode))]
if "align_corners" in trans_info:
_align_corners = TraceKeys.NONE if align_corners is None else align_corners
current_value = trans_info["align_corners"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_invert.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_invert(self):
LoadImage(image_only=True),
EnsureChannelFirst(),
Orientation("RPS"),
Spacing(pixdim=(1.2, 1.01, 0.9), mode="bilinear", dtype=np.float32),
Spacing(pixdim=(1.2, 1.01, 0.9), mode=1, dtype=np.float32),
RandFlip(prob=0.5, spatial_axis=[1, 2]),
RandAxisFlip(prob=0.5),
RandRotate90(prob=0, spatial_axes=(1, 2)),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_invertd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_invert(self):
RandRotate90d(KEYS, prob=0, spatial_axes=(1, 2)),
RandZoomd(KEYS, prob=0.5, min_zoom=0.5, max_zoom=1.1, keep_size=True),
RandRotated(KEYS, prob=0.5, range_x=np.pi, mode="bilinear", align_corners=True, dtype=np.float64),
RandAffined(KEYS, prob=0.5, rotate_range=np.pi, mode="nearest"),
RandAffined(KEYS, prob=0.5, rotate_range=np.pi, mode=["nearest", 0]),
ResizeWithPadOrCropd(KEYS, 100),
CastToTyped(KEYS, dtype=[torch.uint8, np.uint8]),
CopyItemsd("label", times=2, names=["label_inverted", "label_inverted1"]),
Expand Down