Generate randomised affine grid. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information.
| 1828 | |
| 1829 | |
| 1830 | class RandAffineGrid(Randomizable, LazyTransform): |
| 1831 | """ |
| 1832 | Generate randomised affine grid. |
| 1833 | |
| 1834 | This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>` |
| 1835 | for more information. |
| 1836 | """ |
| 1837 | |
| 1838 | backend = AffineGrid.backend |
| 1839 | |
| 1840 | def __init__( |
| 1841 | self, |
| 1842 | rotate_range: RandRange = None, |
| 1843 | shear_range: RandRange = None, |
| 1844 | translate_range: RandRange = None, |
| 1845 | scale_range: RandRange = None, |
| 1846 | device: torch.device | None = None, |
| 1847 | dtype: DtypeLike = np.float32, |
| 1848 | lazy: bool = False, |
| 1849 | ) -> None: |
| 1850 | """ |
| 1851 | Args: |
| 1852 | rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then |
| 1853 | `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter |
| 1854 | for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used. |
| 1855 | This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be |
| 1856 | in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]` |
| 1857 | for dim0 and nothing for the remaining dimensions. |
| 1858 | shear_range: shear range with format matching `rotate_range`, it defines the range to randomly select |
| 1859 | shearing factors(a tuple of 2 floats for 2D, a tuple of 6 floats for 3D) for affine matrix, |
| 1860 | take a 3D affine as example:: |
| 1861 | |
| 1862 | [ |
| 1863 | [1.0, params[0], params[1], 0.0], |
| 1864 | [params[2], 1.0, params[3], 0.0], |
| 1865 | [params[4], params[5], 1.0, 0.0], |
| 1866 | [0.0, 0.0, 0.0, 1.0], |
| 1867 | ] |
| 1868 | |
| 1869 | translate_range: translate range with format matching `rotate_range`, it defines the range to randomly |
| 1870 | select voxels to translate for every spatial dims. |
| 1871 | scale_range: scaling range with format matching `rotate_range`. it defines the range to randomly select |
| 1872 | the scale factor to translate for every spatial dims. A value of 1.0 is added to the result. |
| 1873 | This allows 0 to correspond to no change (i.e., a scaling of 1.0). |
| 1874 | device: device to store the output grid data. |
| 1875 | dtype: data type for the grid computation. Defaults to ``np.float32``. |
| 1876 | If ``None``, use the data type of input data (if `grid` is provided). |
| 1877 | lazy: a flag to indicate whether this transform should execute lazily or not. |
| 1878 | Defaults to False |
| 1879 | |
| 1880 | See also: |
| 1881 | - :py:meth:`monai.transforms.utils.create_rotate` |
| 1882 | - :py:meth:`monai.transforms.utils.create_shear` |
| 1883 | - :py:meth:`monai.transforms.utils.create_translate` |
| 1884 | - :py:meth:`monai.transforms.utils.create_scale` |
| 1885 | |
| 1886 | """ |
| 1887 | LazyTransform.__init__(self, lazy=lazy) |
no outgoing calls
searching dependent graphs…