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

Method __init__

monai/transforms/spatial/dictionary.py:1036–1134  ·  view source on GitHub ↗

Args: keys: keys of the corresponding items to be transformed. spatial_size: output image spatial size. if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1, the transform will use the spatial size of `img`.

(
        self,
        keys: KeysCollection,
        spatial_size: Sequence[int] | int | None = None,
        prob: float = 0.1,
        rotate_range: Sequence[tuple[float, float] | float] | float | None = None,
        shear_range: Sequence[tuple[float, float] | float] | float | None = None,
        translate_range: Sequence[tuple[float, float] | float] | float | None = None,
        scale_range: Sequence[tuple[float, float] | float] | float | None = None,
        mode: SequenceStr = GridSampleMode.BILINEAR,
        padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
        cache_grid: bool = False,
        device: torch.device | None = None,
        allow_missing_keys: bool = False,
        lazy: bool = False,
    )

Source from the content-addressed store, hash-verified

1034 backend = RandAffine.backend
1035
1036 def __init__(
1037 self,
1038 keys: KeysCollection,
1039 spatial_size: Sequence[int] | int | None = None,
1040 prob: float = 0.1,
1041 rotate_range: Sequence[tuple[float, float] | float] | float | None = None,
1042 shear_range: Sequence[tuple[float, float] | float] | float | None = None,
1043 translate_range: Sequence[tuple[float, float] | float] | float | None = None,
1044 scale_range: Sequence[tuple[float, float] | float] | float | None = None,
1045 mode: SequenceStr = GridSampleMode.BILINEAR,
1046 padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
1047 cache_grid: bool = False,
1048 device: torch.device | None = None,
1049 allow_missing_keys: bool = False,
1050 lazy: bool = False,
1051 ) -> None:
1052 """
1053 Args:
1054 keys: keys of the corresponding items to be transformed.
1055 spatial_size: output image spatial size.
1056 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
1057 the transform will use the spatial size of `img`.
1058 if some components of the `spatial_size` are non-positive values, the transform will use the
1059 corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted
1060 to `(32, 64)` if the second spatial dimension size of img is `64`.
1061 prob: probability of returning a randomized affine grid.
1062 defaults to 0.1, with 10% chance returns a randomized grid.
1063 rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
1064 `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
1065 for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
1066 This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
1067 in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
1068 for dim0 and nothing for the remaining dimensions.
1069 shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select
1070 shearing factors(a tuple of 2 floats for 2D, a tuple of 6 floats for 3D) for affine matrix,
1071 take a 3D affine as example::
1072
1073 [
1074 [1.0, params[0], params[1], 0.0],
1075 [params[2], 1.0, params[3], 0.0],
1076 [params[4], params[5], 1.0, 0.0],
1077 [0.0, 0.0, 0.0, 1.0],
1078 ]
1079
1080 translate_range: translate range with format matching `rotate_range`, it defines the range to randomly
1081 select pixel/voxel to translate for every spatial dims.
1082 scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select
1083 the scale factor to translate for every spatial dims. A value of 1.0 is added to the result.
1084 This allows 0 to correspond to no change (i.e., a scaling of 1.0).
1085 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
1086 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
1087 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
1088 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
1089 and the value represents the order of the spline interpolation.
1090 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html
1091 It also can be a sequence, each element corresponds to a key in ``keys``.
1092 padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
1093 Padding mode for outside grid values. Defaults to ``"reflection"``.

Callers

nothing calls this directly

Calls 3

RandAffineClass · 0.90
ensure_tuple_repFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected