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

Class Rand3DElastic

monai/transforms/spatial/array.py:2821–2987  ·  view source on GitHub ↗

Random elastic deformation and affine in 3D. A tutorial is available: https://github.com/Project-MONAI/tutorials/blob/0.6.0/modules/transforms_demo_2d.ipynb.

Source from the content-addressed store, hash-verified

2819
2820
2821class Rand3DElastic(RandomizableTransform):
2822 """
2823 Random elastic deformation and affine in 3D.
2824 A tutorial is available: https://github.com/Project-MONAI/tutorials/blob/0.6.0/modules/transforms_demo_2d.ipynb.
2825
2826 """
2827
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

Callers 2

__init__Method · 0.90
test_rand_3d_elasticMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_rand_3d_elasticMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…