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

Method __init__

monai/transforms/spatial/dictionary.py:904–993  ·  view source on GitHub ↗

Args: keys: keys of the corresponding items to be transformed. rotate_params: a rotation angle in radians, a scalar for 2D image, a tuple of 3 floats for 3D. Defaults to no rotation. shear_params: shearing factors for affine matrix, take a

(
        self,
        keys: KeysCollection,
        rotate_params: Sequence[float] | float | None = None,
        shear_params: Sequence[float] | float | None = None,
        translate_params: Sequence[float] | float | None = None,
        scale_params: Sequence[float] | float | None = None,
        affine: NdarrayOrTensor | None = None,
        spatial_size: Sequence[int] | int | None = None,
        mode: SequenceStr = GridSampleMode.BILINEAR,
        padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
        device: torch.device | None = None,
        dtype: DtypeLike | torch.dtype = np.float32,
        align_corners: bool = False,
        allow_missing_keys: bool = False,
        lazy: bool = False,
    )

Source from the content-addressed store, hash-verified

902 backend = Affine.backend
903
904 def __init__(
905 self,
906 keys: KeysCollection,
907 rotate_params: Sequence[float] | float | None = None,
908 shear_params: Sequence[float] | float | None = None,
909 translate_params: Sequence[float] | float | None = None,
910 scale_params: Sequence[float] | float | None = None,
911 affine: NdarrayOrTensor | None = None,
912 spatial_size: Sequence[int] | int | None = None,
913 mode: SequenceStr = GridSampleMode.BILINEAR,
914 padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
915 device: torch.device | None = None,
916 dtype: DtypeLike | torch.dtype = np.float32,
917 align_corners: bool = False,
918 allow_missing_keys: bool = False,
919 lazy: bool = False,
920 ) -> None:
921 """
922 Args:
923 keys: keys of the corresponding items to be transformed.
924 rotate_params: a rotation angle in radians, a scalar for 2D image, a tuple of 3 floats for 3D.
925 Defaults to no rotation.
926 shear_params: shearing factors for affine matrix, take a 3D affine as example::
927
928 [
929 [1.0, params[0], params[1], 0.0],
930 [params[2], 1.0, params[3], 0.0],
931 [params[4], params[5], 1.0, 0.0],
932 [0.0, 0.0, 0.0, 1.0],
933 ]
934
935 a tuple of 2 floats for 2D, a tuple of 6 floats for 3D. Defaults to no shearing.
936 translate_params: a tuple of 2 floats for 2D, a tuple of 3 floats for 3D. Translation is in
937 pixel/voxel relative to the center of the input image. Defaults to no translation.
938 scale_params: scale factor for every spatial dims. a tuple of 2 floats for 2D,
939 a tuple of 3 floats for 3D. Defaults to `1.0`.
940 affine: if applied, ignore the params (`rotate_params`, etc.) and use the
941 supplied matrix. Should be square with each side = num of image spatial
942 dimensions + 1.
943 spatial_size: output image spatial size.
944 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
945 the transform will use the spatial size of `img`.
946 if some components of the `spatial_size` are non-positive values, the transform will use the
947 corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted
948 to `(32, 64)` if the second spatial dimension size of img is `64`.
949 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
950 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
951 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
952 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
953 and the value represents the order of the spline interpolation.
954 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html
955 It also can be a sequence, each element corresponds to a key in ``keys``.
956 padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
957 Padding mode for outside grid values. Defaults to ``"reflection"``.
958 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
959 When `mode` is an integer, using numpy/cupy backends, this argument accepts
960 {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror', 'grid-wrap', 'wrap'}.
961 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html

Callers

nothing calls this directly

Calls 3

AffineClass · 0.90
ensure_tuple_repFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected