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

Method __init__

monai/transforms/spatial/array.py:2664–2745  ·  view source on GitHub ↗

Args: spacing : distance in between the control points. magnitude_range: the random offsets will be generated from ``uniform[magnitude[0], magnitude[1])``. prob: probability of returning a randomized elastic transform. defaults to 0.1, wit

(
        self,
        spacing: tuple[float, float] | float,
        magnitude_range: tuple[float, float],
        prob: float = 0.1,
        rotate_range: RandRange = None,
        shear_range: RandRange = None,
        translate_range: RandRange = None,
        scale_range: RandRange = None,
        spatial_size: tuple[int, int] | int | None = None,
        mode: str | int = GridSampleMode.BILINEAR,
        padding_mode: str = GridSamplePadMode.REFLECTION,
        device: torch.device | None = None,
    )

Source from the content-addressed store, hash-verified

2662 backend = Resample.backend
2663
2664 def __init__(
2665 self,
2666 spacing: tuple[float, float] | float,
2667 magnitude_range: tuple[float, float],
2668 prob: float = 0.1,
2669 rotate_range: RandRange = None,
2670 shear_range: RandRange = None,
2671 translate_range: RandRange = None,
2672 scale_range: RandRange = None,
2673 spatial_size: tuple[int, int] | int | None = None,
2674 mode: str | int = GridSampleMode.BILINEAR,
2675 padding_mode: str = GridSamplePadMode.REFLECTION,
2676 device: torch.device | None = None,
2677 ) -> None:
2678 """
2679 Args:
2680 spacing : distance in between the control points.
2681 magnitude_range: the random offsets will be generated from ``uniform[magnitude[0], magnitude[1])``.
2682 prob: probability of returning a randomized elastic transform.
2683 defaults to 0.1, with 10% chance returns a randomized elastic transform,
2684 otherwise returns a ``spatial_size`` centered area extracted from the input image.
2685 rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
2686 `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
2687 for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
2688 This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
2689 in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
2690 for dim0 and nothing for the remaining dimensions.
2691 shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select
2692 shearing factors(a tuple of 2 floats for 2D) for affine matrix, take a 2D affine as example::
2693
2694 [
2695 [1.0, params[0], 0.0],
2696 [params[1], 1.0, 0.0],
2697 [0.0, 0.0, 1.0],
2698 ]
2699
2700 translate_range: translate range with format matching `rotate_range`, it defines the range to randomly
2701 select pixel to translate for every spatial dims.
2702 scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select
2703 the scale factor to translate for every spatial dims. A value of 1.0 is added to the result.
2704 This allows 0 to correspond to no change (i.e., a scaling of 1.0).
2705 spatial_size: specifying output image spatial size [h, w].
2706 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
2707 the transform will use the spatial size of `img`.
2708 if some components of the `spatial_size` are non-positive values, the transform will use the
2709 corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted
2710 to `(32, 64)` if the second spatial dimension size of img is `64`.
2711 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
2712 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
2713 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
2714 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
2715 and the value represents the order of the spline interpolation.
2716 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html
2717 padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
2718 Padding mode for outside grid values. Defaults to ``"reflection"``.
2719 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
2720 When `mode` is an integer, using numpy/cupy backends, this argument accepts
2721 {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror', 'grid-wrap', 'wrap'}.

Callers

nothing calls this directly

Calls 4

RandDeformGridClass · 0.85
RandAffineGridClass · 0.85
ResampleClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected