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

Method __init__

monai/transforms/spatial/dictionary.py:1366–1455  ·  view source on GitHub ↗

Args: keys: keys of the corresponding items to be transformed. sigma_range: a Gaussian kernel with standard deviation sampled from ``uniform[sigma_range[0], sigma_range[1])`` will be used to smooth the random offset grid. magnitude_range:

(
        self,
        keys: KeysCollection,
        sigma_range: tuple[float, float],
        magnitude_range: tuple[float, float],
        spatial_size: tuple[int, 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

1364 backend = Rand3DElastic.backend
1365
1366 def __init__(
1367 self,
1368 keys: KeysCollection,
1369 sigma_range: tuple[float, float],
1370 magnitude_range: tuple[float, float],
1371 spatial_size: tuple[int, int, int] | int | None = None,
1372 prob: float = 0.1,
1373 rotate_range: Sequence[tuple[float, float] | float] | float | None = None,
1374 shear_range: Sequence[tuple[float, float] | float] | float | None = None,
1375 translate_range: Sequence[tuple[float, float] | float] | float | None = None,
1376 scale_range: Sequence[tuple[float, float] | float] | float | None = None,
1377 mode: SequenceStr = GridSampleMode.BILINEAR,
1378 padding_mode: SequenceStr = GridSamplePadMode.REFLECTION,
1379 device: torch.device | None = None,
1380 allow_missing_keys: bool = False,
1381 ) -> None:
1382 """
1383 Args:
1384 keys: keys of the corresponding items to be transformed.
1385 sigma_range: a Gaussian kernel with standard deviation sampled from
1386 ``uniform[sigma_range[0], sigma_range[1])`` will be used to smooth the random offset grid.
1387 magnitude_range: the random offsets on the grid will be generated from
1388 ``uniform[magnitude[0], magnitude[1])``.
1389 spatial_size: specifying output image spatial size [h, w, d].
1390 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
1391 the transform will use the spatial size of `img`.
1392 if some components of the `spatial_size` are non-positive values, the transform will use the
1393 corresponding components of img size. For example, `spatial_size=(32, 32, -1)` will be adapted
1394 to `(32, 32, 64)` if the third spatial dimension size of img is `64`.
1395 prob: probability of returning a randomized affine grid.
1396 defaults to 0.1, with 10% chance returns a randomized grid,
1397 otherwise returns a ``spatial_size`` centered area extracted from the input image.
1398 rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
1399 `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
1400 for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
1401 This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
1402 in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
1403 for dim0 and nothing for the remaining dimensions.
1404 shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select
1405 shearing factors(a tuple of 6 floats for 3D) for affine matrix, take a 3D affine as example::
1406
1407 [
1408 [1.0, params[0], params[1], 0.0],
1409 [params[2], 1.0, params[3], 0.0],
1410 [params[4], params[5], 1.0, 0.0],
1411 [0.0, 0.0, 0.0, 1.0],
1412 ]
1413
1414 translate_range: translate range with format matching `rotate_range`, it defines the range to randomly
1415 select voxel to translate for every spatial dims.
1416 scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select
1417 the scale factor to translate for every spatial dims. A value of 1.0 is added to the result.
1418 This allows 0 to correspond to no change (i.e., a scaling of 1.0).
1419 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
1420 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
1421 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
1422 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
1423 and the value represents the order of the spline interpolation.

Callers

nothing calls this directly

Calls 3

Rand3DElasticClass · 0.90
ensure_tuple_repFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected