Args: keys: keys of the corresponding items to be transformed. key_dst: key of image to resample to match. mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers). Interpolation mode to calculate output values. D
(
self,
keys: KeysCollection,
key_dst: str,
mode: SequenceStr = GridSampleMode.BILINEAR,
padding_mode: SequenceStr = GridSamplePadMode.BORDER,
align_corners: Sequence[bool] | bool = False,
dtype: Sequence[DtypeLike] | DtypeLike = np.float64,
allow_missing_keys: bool = False,
lazy: bool = False,
)
| 275 | backend = ResampleToMatch.backend |
| 276 | |
| 277 | def __init__( |
| 278 | self, |
| 279 | keys: KeysCollection, |
| 280 | key_dst: str, |
| 281 | mode: SequenceStr = GridSampleMode.BILINEAR, |
| 282 | padding_mode: SequenceStr = GridSamplePadMode.BORDER, |
| 283 | align_corners: Sequence[bool] | bool = False, |
| 284 | dtype: Sequence[DtypeLike] | DtypeLike = np.float64, |
| 285 | allow_missing_keys: bool = False, |
| 286 | lazy: bool = False, |
| 287 | ): |
| 288 | """ |
| 289 | Args: |
| 290 | keys: keys of the corresponding items to be transformed. |
| 291 | key_dst: key of image to resample to match. |
| 292 | mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers). |
| 293 | Interpolation mode to calculate output values. Defaults to ``"bilinear"``. |
| 294 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 295 | When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used |
| 296 | and the value represents the order of the spline interpolation. |
| 297 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
| 298 | It also can be a sequence, each element corresponds to a key in ``keys``. |
| 299 | padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} |
| 300 | Padding mode for outside grid values. Defaults to ``"border"``. |
| 301 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 302 | When `mode` is an integer, using numpy/cupy backends, this argument accepts |
| 303 | {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror', 'grid-wrap', 'wrap'}. |
| 304 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
| 305 | It also can be a sequence, each element corresponds to a key in ``keys``. |
| 306 | align_corners: Geometrically, we consider the pixels of the input as squares rather than points. |
| 307 | See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample |
| 308 | It also can be a sequence of bool, each element corresponds to a key in ``keys``. |
| 309 | dtype: data type for resampling computation. Defaults to ``float64`` for best precision. |
| 310 | If None, use the data type of input data. To be compatible with other modules, |
| 311 | the output data type is always ``float32``. |
| 312 | It also can be a sequence of dtypes, each element corresponds to a key in ``keys``. |
| 313 | allow_missing_keys: don't raise exception if key is missing. |
| 314 | lazy: a flag to indicate whether this transform should execute lazily or not. |
| 315 | Defaults to False |
| 316 | """ |
| 317 | MapTransform.__init__(self, keys, allow_missing_keys) |
| 318 | LazyTransform.__init__(self, lazy=lazy) |
| 319 | self.key_dst = key_dst |
| 320 | self.mode = ensure_tuple_rep(mode, len(self.keys)) |
| 321 | self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys)) |
| 322 | self.align_corners = ensure_tuple_rep(align_corners, len(self.keys)) |
| 323 | self.dtype = ensure_tuple_rep(dtype, len(self.keys)) |
| 324 | self.resampler = ResampleToMatch(lazy=lazy) |
| 325 | |
| 326 | @LazyTransform.lazy.setter # type: ignore |
| 327 | def lazy(self, val: bool) -> None: |
nothing calls this directly
no test coverage detected