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

Class RandFlipd

monai/transforms/spatial/dictionary.py:1565–1641  ·  view source on GitHub ↗

Dictionary-based version :py:class:`monai.transforms.RandFlip`. See `numpy.flip` for additional details. https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for

Source from the content-addressed store, hash-verified

1563
1564
1565class RandFlipd(RandomizableTransform, MapTransform, InvertibleTransform, LazyTransform):
1566 """
1567 Dictionary-based version :py:class:`monai.transforms.RandFlip`.
1568
1569 See `numpy.flip` for additional details.
1570 https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html
1571
1572 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
1573 for more information.
1574
1575 Args:
1576 keys: Keys to pick data for transformation.
1577 prob: Probability of flipping.
1578 spatial_axis: Spatial axes along which to flip over. Default is None.
1579 allow_missing_keys: don&#x27;t raise exception if key is missing.
1580 lazy: a flag to indicate whether this transform should execute lazily or not.
1581 Defaults to False
1582 """
1583
1584 backend = Flip.backend
1585
1586 def __init__(
1587 self,
1588 keys: KeysCollection,
1589 prob: float = 0.1,
1590 spatial_axis: Sequence[int] | int | None = None,
1591 allow_missing_keys: bool = False,
1592 lazy: bool = False,
1593 ) -> None:
1594 MapTransform.__init__(self, keys, allow_missing_keys)
1595 RandomizableTransform.__init__(self, prob)
1596 LazyTransform.__init__(self, lazy=lazy)
1597 self.flipper = Flip(spatial_axis=spatial_axis, lazy=lazy)
1598
1599 @LazyTransform.lazy.setter # type: ignore
1600 def lazy(self, val: bool):
1601 self.flipper.lazy = val
1602 self._lazy = val
1603
1604 def set_random_state(self, seed: int | None = None, state: np.random.RandomState | None = None) -> RandFlipd:
1605 super().set_random_state(seed, state)
1606 return self
1607
1608 def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None) -> dict[Hashable, torch.Tensor]:
1609 """
1610 Args:
1611 data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
1612 in this dictionary must be tensor like arrays that are channel first and have at most
1613 three spatial dimensions
1614 lazy: a flag to indicate whether this transform should execute lazily or not
1615 during this call. Setting this to False or True overrides the ``lazy`` flag set
1616 during initialization for this call. Defaults to None.
1617
1618 Returns:
1619 a dictionary containing the transformed data, as well as any other data present in the dictionary
1620 """
1621 d = dict(data)
1622 self.randomize(None)

Callers 12

run_training_testFunction · 0.90
test_single_transformMethod · 0.90
test_image_no_labelMethod · 0.90
test_train_timingMethod · 0.90
run_training_testFunction · 0.90
test_decollate.pyFile · 0.90
test_correct_resultsMethod · 0.90
test_inverse.pyFile · 0.90
test_invertMethod · 0.90

Calls

no outgoing calls

Tested by 9

run_training_testFunction · 0.72
test_single_transformMethod · 0.72
test_image_no_labelMethod · 0.72
test_train_timingMethod · 0.72
run_training_testFunction · 0.72
test_correct_resultsMethod · 0.72
test_invertMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…