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

Method __init__

monai/transforms/spatial/array.py:2830–2919  ·  view source on GitHub ↗

Args: 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: the random offsets on the grid will be generated from

(
        self,
        sigma_range: tuple[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] | 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

2828 backend = Resample.backend
2829
2830 def __init__(
2831 self,
2832 sigma_range: tuple[float, float],
2833 magnitude_range: tuple[float, float],
2834 prob: float = 0.1,
2835 rotate_range: RandRange = None,
2836 shear_range: RandRange = None,
2837 translate_range: RandRange = None,
2838 scale_range: RandRange = None,
2839 spatial_size: tuple[int, int, int] | int | None = None,
2840 mode: str | int = GridSampleMode.BILINEAR,
2841 padding_mode: str = GridSamplePadMode.REFLECTION,
2842 device: torch.device | None = None,
2843 ) -> None:
2844 """
2845 Args:
2846 sigma_range: a Gaussian kernel with standard deviation sampled from
2847 ``uniform[sigma_range[0], sigma_range[1])`` will be used to smooth the random offset grid.
2848 magnitude_range: the random offsets on the grid will be generated from
2849 ``uniform[magnitude[0], magnitude[1])``.
2850 prob: probability of returning a randomized elastic transform.
2851 defaults to 0.1, with 10% chance returns a randomized elastic transform,
2852 otherwise returns a ``spatial_size`` centered area extracted from the input image.
2853 rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
2854 `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
2855 for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
2856 This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
2857 in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
2858 for dim0 and nothing for the remaining dimensions.
2859 shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select
2860 shearing factors(a tuple of 6 floats for 3D) for affine matrix, take a 3D affine as example::
2861
2862 [
2863 [1.0, params[0], params[1], 0.0],
2864 [params[2], 1.0, params[3], 0.0],
2865 [params[4], params[5], 1.0, 0.0],
2866 [0.0, 0.0, 0.0, 1.0],
2867 ]
2868
2869 translate_range: translate range with format matching `rotate_range`, it defines the range to randomly
2870 select voxel to translate for every spatial dims.
2871 scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select
2872 the scale factor to translate for every spatial dims. A value of 1.0 is added to the result.
2873 This allows 0 to correspond to no change (i.e., a scaling of 1.0).
2874 spatial_size: specifying output image spatial size [h, w, d].
2875 if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,
2876 the transform will use the spatial size of `img`.
2877 if some components of the `spatial_size` are non-positive values, the transform will use the
2878 corresponding components of img size. For example, `spatial_size=(32, 32, -1)` will be adapted
2879 to `(32, 32, 64)` if the third spatial dimension size of img is `64`.
2880 mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers).
2881 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
2882 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
2883 When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used
2884 and the value represents the order of the spline interpolation.
2885 See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html
2886 padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
2887 Padding mode for outside grid values. Defaults to ``"reflection"``.

Callers

nothing calls this directly

Calls 3

RandAffineGridClass · 0.85
ResampleClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected