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

Class RandRotate90d

monai/transforms/spatial/dictionary.py:700–783  ·  view source on GitHub ↗

Dictionary-based version :py:class:`monai.transforms.RandRotate90`. With probability `prob`, input arrays are rotated by 90 degrees in the plane specified by `spatial_axes`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for m

Source from the content-addressed store, hash-verified

698
699
700class RandRotate90d(RandomizableTransform, MapTransform, InvertibleTransform, LazyTransform):
701 """
702 Dictionary-based version :py:class:`monai.transforms.RandRotate90`.
703 With probability `prob`, input arrays are rotated by 90 degrees
704 in the plane specified by `spatial_axes`.
705
706 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
707 for more information.
708 """
709
710 backend = Rotate90.backend
711
712 def __init__(
713 self,
714 keys: KeysCollection,
715 prob: float = 0.1,
716 max_k: int = 3,
717 spatial_axes: tuple[int, int] = (0, 1),
718 allow_missing_keys: bool = False,
719 lazy: bool = False,
720 ) -> None:
721 """
722 Args:
723 keys: keys of the corresponding items to be transformed.
724 See also: :py:class:`monai.transforms.compose.MapTransform`
725 prob: probability of rotating.
726 (Default 0.1, with 10% probability it returns a rotated array.)
727 max_k: number of rotations will be sampled from `np.random.randint(max_k) + 1`.
728 (Default 3)
729 spatial_axes: 2 int numbers, defines the plane to rotate with 2 spatial axes.
730 Default: (0, 1), this is the first two axis in spatial dimensions.
731 allow_missing_keys: don&#x27;t raise exception if key is missing.
732 lazy: a flag to indicate whether this transform should execute lazily or not.
733 Defaults to False
734 """
735 MapTransform.__init__(self, keys, allow_missing_keys)
736 RandomizableTransform.__init__(self, prob)
737 LazyTransform.__init__(self, lazy=lazy)
738
739 self.max_k = max_k
740 self.spatial_axes = spatial_axes
741
742 self._rand_k = 0
743
744 def randomize(self, data: Any | None = None) -> None:
745 self._rand_k = self.R.randint(self.max_k) + 1
746 super().randomize(None)
747
748 def __call__(
749 self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None
750 ) -> Mapping[Hashable, torch.Tensor]:
751 """
752 Args:
753 data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
754 in this dictionary must be tensor like arrays that are channel first and have at most
755 three spatial dimensions
756 lazy: a flag to indicate whether this transform should execute lazily or not
757 during this call. Setting this to False or True overrides the ``lazy`` flag set

Callers 13

test_train_timingMethod · 0.90
run_training_testFunction · 0.90
run_training_testFunction · 0.90
test_decollate.pyFile · 0.90
test_defaultMethod · 0.90
test_kMethod · 0.90
test_spatial_axesMethod · 0.90
test_no_keyMethod · 0.90
test_inverse.pyFile · 0.90

Calls

no outgoing calls

Tested by 9

test_train_timingMethod · 0.72
run_training_testFunction · 0.72
run_training_testFunction · 0.72
test_defaultMethod · 0.72
test_kMethod · 0.72
test_spatial_axesMethod · 0.72
test_no_keyMethod · 0.72
test_invertMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…