Resample input image into the specified `pixdim`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information.
| 339 | |
| 340 | |
| 341 | class Spacing(InvertibleTransform, LazyTransform): |
| 342 | """ |
| 343 | Resample input image into the specified `pixdim`. |
| 344 | |
| 345 | This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>` |
| 346 | for more information. |
| 347 | """ |
| 348 | |
| 349 | backend = SpatialResample.backend |
| 350 | |
| 351 | def __init__( |
| 352 | self, |
| 353 | pixdim: Sequence[float] | float | np.ndarray, |
| 354 | diagonal: bool = False, |
| 355 | mode: str | int = GridSampleMode.BILINEAR, |
| 356 | padding_mode: str = GridSamplePadMode.BORDER, |
| 357 | align_corners: bool = False, |
| 358 | dtype: DtypeLike = np.float64, |
| 359 | scale_extent: bool = False, |
| 360 | recompute_affine: bool = False, |
| 361 | min_pixdim: Sequence[float] | float | np.ndarray | None = None, |
| 362 | max_pixdim: Sequence[float] | float | np.ndarray | None = None, |
| 363 | lazy: bool = False, |
| 364 | ) -> None: |
| 365 | """ |
| 366 | Args: |
| 367 | pixdim: output voxel spacing. if providing a single number, will use it for the first dimension. |
| 368 | items of the pixdim sequence map to the spatial dimensions of input image, if length |
| 369 | of pixdim sequence is longer than image spatial dimensions, will ignore the longer part, |
| 370 | if shorter, will pad with the last value. For example, for 3D image if pixdim is [1.0, 2.0] it |
| 371 | will be padded to [1.0, 2.0, 2.0] |
| 372 | if the components of the `pixdim` are non-positive values, the transform will use the |
| 373 | corresponding components of the original pixdim, which is computed from the `affine` |
| 374 | matrix of input image. |
| 375 | diagonal: whether to resample the input to have a diagonal affine matrix. |
| 376 | If True, the input data is resampled to the following affine:: |
| 377 | |
| 378 | np.diag((pixdim_0, pixdim_1, ..., pixdim_n, 1)) |
| 379 | |
| 380 | This effectively resets the volume to the world coordinate system (RAS+ in nibabel). |
| 381 | The original orientation, rotation, shearing are not preserved. |
| 382 | |
| 383 | If False, this transform preserves the axes orientation, orthogonal rotation and |
| 384 | translation components from the original affine. This option will not flip/swap axes |
| 385 | of the original data. |
| 386 | mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers). |
| 387 | Interpolation mode to calculate output values. Defaults to ``"bilinear"``. |
| 388 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 389 | When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used |
| 390 | and the value represents the order of the spline interpolation. |
| 391 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
| 392 | padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} |
| 393 | Padding mode for outside grid values. Defaults to ``"border"``. |
| 394 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 395 | When `mode` is an integer, using numpy/cupy backends, this argument accepts |
| 396 | {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror', 'grid-wrap', 'wrap'}. |
| 397 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
| 398 | align_corners: Geometrically, we consider the pixels of the input as squares rather than points. |
no outgoing calls
searching dependent graphs…