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

SpatialResample Gives Error When Attempting Spline Interpolation #6416

Closed
ellisdg opened this issue Apr 21, 2023 · 1 comment
Closed

SpatialResample Gives Error When Attempting Spline Interpolation #6416

ellisdg opened this issue Apr 21, 2023 · 1 comment

Comments

@ellisdg
Copy link

ellisdg commented Apr 21, 2023

Describe the bug
When I put an integer (0-5) for the mode for SpatialResample to perform spline interpolation, I get an error. The error seems to involve the padding method being set to 'border' which I never specified. The error goes away if I switch the interpolation mode to "bilinear" or "nearest".

To Reproduce

from monai.data import MetaTensor
import torch
from monai.transforms import SpatialResample
image = MetaTensor(x=torch.rand((1, 100, 100, 100)), affine=torch.diag(torch.ones(4)))
SpatialResample(mode=3)(img=image, dst_affine=image.affine, spatial_size=image.shape)
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3460, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-8-203f9d215858>", line 1, in <module>
    SpatialResample(mode=3)(img=image, dst_affine=image.affine, spatial_size=image.shape)
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/utils/deprecate_utils.py", line 221, in _wrapper
    return func(*args, **kwargs)
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/transforms/spatial/array.py", line 306, in __call__
    img = affine_xform(img, mode=mode, padding_mode=padding_mode)
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/transforms/spatial/array.py", line 2290, in __call__
    out = self.resampler(img, grid=grid, mode=_mode, padding_mode=_padding_mode)
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/transforms/spatial/array.py", line 2134, in __call__
    [
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/transforms/spatial/array.py", line 2135, in <listcomp>
    _map_coord(c, grid_np, order=int(_interp_mode), mode=look_up_option(_padding_mode, NdimageMode))
  File "/Users/david.ellis/miniconda3/envs/unet/lib/python3.10/site-packages/monai/utils/module.py", line 133, in look_up_option
    raise ValueError(f"Unsupported option '{opt_str}', " + supported_msg)
ValueError: Unsupported option 'border', Available options are {'mirror', 'reflect', 'grid-constant', 'grid-wrap', 'grid-mirror', 'wrap', 'constant', 'nearest'}.

Expected behavior
Not raising an error when I specify spline interpolation.

@wyli
Copy link
Contributor

wyli commented Apr 22, 2023

Thanks for reporting, let's track this problem with #6222

@wyli wyli closed this as completed Apr 22, 2023
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

No branches or pull requests

2 participants