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

Method __init__

monai/transforms/spatial/dictionary.py:1217–1304  ·  view source on GitHub ↗

Args: keys: keys of the corresponding items to be transformed. spacing: distance in between the control points. magnitude_range: 2 int numbers, the random offsets will be generated from ``uniform[magnitude[0], magnitude[1])``.

(
        self,
        keys: KeysCollection,
        spacing: tuple[float, float] | float,
        magnitude_range: tuple[float, float],
        spatial_size: tuple[int, 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,
        device: torch.device | None = None,
        allow_missing_keys: bool = False,
    )

Source from the content-addressed store, hash-verified

1215 backend = Rand2DElastic.backend
1216
1217 def __init__(
1218 self,
1219 keys: KeysCollection,
1220 spacing: tuple[float, float] | float,
1221 magnitude_range: tuple[float, float],
1222 spatial_size: tuple[int, int] | int | None = None,
1223 prob: float = 0.1,
1224 rotate_range: Sequence[tuple[float, float] | float] | float | None = None,
1225 shear_range: Sequence[tuple[float, float] | float] | float | None = None,
1226 translate_range: Sequence[tuple[float, float] | float] | float | None = None,
1227 scale_range: Sequence[tuple[float, float] | float] | float | None = None,
1228 mode: SequenceStr = GridSampleMode.BILINEAR,
1229 padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
1230 device: torch.device | None = None,
1231 allow_missing_keys: bool = False,
1232 ) -> None:
1233 """
1234 Args:
1235 keys: keys of the corresponding items to be transformed.
1236 spacing: distance in between the control points.
1237 magnitude_range: 2 int numbers, the random offsets will be generated from
1238 ``uniform[magnitude[0], magnitude[1])``.
1239 spatial_size: specifying output image spatial size [h, w].
1240 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
1241 the transform will use the spatial size of `img`.
1242 if some components of the `spatial_size` are non-positive values, the transform will use the
1243 corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted
1244 to `(32, 64)` if the second spatial dimension size of img is `64`.
1245 prob: probability of returning a randomized affine grid.
1246 defaults to 0.1, with 10% chance returns a randomized grid,
1247 otherwise returns a ``spatial_size`` centered area extracted from the input image.
1248 rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
1249 `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
1250 for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
1251 This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
1252 in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
1253 for dim0 and nothing for the remaining dimensions.
1254 shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select
1255 shearing factors(a tuple of 2 floats for 2D) for affine matrix, take a 2D affine as example::
1256
1257 [
1258 [1.0, params[0], 0.0],
1259 [params[1], 1.0, 0.0],
1260 [0.0, 0.0, 1.0],
1261 ]
1262
1263 translate_range: translate range with format matching `rotate_range`, it defines the range to randomly
1264 select pixel to translate for every spatial dims.
1265 scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select
1266 the scale factor to translate for every spatial dims. A value of 1.0 is added to the result.
1267 This allows 0 to correspond to no change (i.e., a scaling of 1.0).
1268 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
1269 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
1270 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
1271 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
1272 and the value represents the order of the spline interpolation.
1273 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html
1274 It also can be a sequence, each element corresponds to a key in ``keys``.

Callers

nothing calls this directly

Calls 3

Rand2DElasticClass · 0.90
ensure_tuple_repFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected