MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/transforms/spatial/array.py:351–433  ·  view source on GitHub ↗

Args: pixdim: output voxel spacing. if providing a single number, will use it for the first dimension. items of the pixdim sequence map to the spatial dimensions of input image, if length of pixdim sequence is longer than image spatial dimensions,

(
        self,
        pixdim: Sequence[float] | float | np.ndarray,
        diagonal: bool = False,
        mode: str | int = GridSampleMode.BILINEAR,
        padding_mode: str = GridSamplePadMode.BORDER,
        align_corners: bool = False,
        dtype: DtypeLike = np.float64,
        scale_extent: bool = False,
        recompute_affine: bool = False,
        min_pixdim: Sequence[float] | float | np.ndarray | None = None,
        max_pixdim: Sequence[float] | float | np.ndarray | None = None,
        lazy: bool = False,
    )

Source from the content-addressed store, hash-verified

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.
399 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
400 dtype: data type for resampling computation. Defaults to ``float64`` for best precision.
401 If None, use the data type of input data. To be compatible with other modules,
402 the output data type is always ``float32``.
403 scale_extent: whether the scale is computed based on the spacing or the full extent of voxels,
404 default False. The option is ignored if output spatial size is specified when calling this transform.
405 See also: :py:func:`monai.data.utils.compute_shape_offset`. When this is True, `align_corners`
406 should be `True` because `compute_shape_offset` already provides the corner alignment shift/scaling.
407 recompute_affine: whether to recompute affine based on the output shape. The affine computed
408 analytically does not reflect the potential quantization errors in terms of the output shape.

Callers

nothing calls this directly

Calls 4

ensure_tupleFunction · 0.90
SpatialResampleClass · 0.85
arrayMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected