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

Class Flipd

monai/transforms/spatial/dictionary.py:1503–1562  ·  view source on GitHub ↗

Dictionary-based wrapper of :py:class:`monai.transforms.Flip`. 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 m

Source from the content-addressed store, hash-verified

1501
1502
1503class Flipd(MapTransform, InvertibleTransform, LazyTransform):
1504 """
1505 Dictionary-based wrapper of :py:class:`monai.transforms.Flip`.
1506
1507 See `numpy.flip` for additional details.
1508 https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html
1509
1510 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
1511 for more information.
1512
1513 Args:
1514 keys: Keys to pick data for transformation.
1515 spatial_axis: Spatial axes along which to flip over. Default is None.
1516 allow_missing_keys: don&#x27;t raise exception if key is missing.
1517 lazy: a flag to indicate whether this transform should execute lazily or not.
1518 Defaults to False
1519 """
1520
1521 backend = Flip.backend
1522
1523 def __init__(
1524 self,
1525 keys: KeysCollection,
1526 spatial_axis: Sequence[int] | int | None = None,
1527 allow_missing_keys: bool = False,
1528 lazy: bool = False,
1529 ) -> None:
1530 MapTransform.__init__(self, keys, allow_missing_keys)
1531 LazyTransform.__init__(self, lazy=lazy)
1532 self.flipper = Flip(spatial_axis=spatial_axis)
1533
1534 @LazyTransform.lazy.setter # type: ignore
1535 def lazy(self, val: bool):
1536 self.flipper.lazy = val
1537 self._lazy = val
1538
1539 def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None) -> dict[Hashable, torch.Tensor]:
1540 """
1541 Args:
1542 data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
1543 in this dictionary must be tensor like arrays that are channel first and have at most
1544 three spatial dimensions
1545 lazy: a flag to indicate whether this transform should execute lazily or not
1546 during this call. Setting this to False or True overrides the ``lazy`` flag set
1547 during initialization for this call. Defaults to None.
1548
1549 Returns:
1550 a dictionary containing the transformed data, as well as any other data present in the dictionary
1551 """
1552 d = dict(data)
1553 lazy_ = self.lazy if lazy is None else lazy
1554 for key in self.key_iterator(d):
1555 d[key] = self.flipper(d[key], lazy=lazy_)
1556 return d
1557
1558 def inverse(self, data: Mapping[Hashable, torch.Tensor]) -> dict[Hashable, torch.Tensor]:
1559 d = dict(data)
1560 for key in self.key_iterator(d):

Callers 7

test_invalid_casesMethod · 0.90
test_correct_resultsMethod · 0.90
test_torchMethod · 0.90
test_meta_dictMethod · 0.90
test_tranform_dictMethod · 0.90
test_inverse.pyFile · 0.90

Calls

no outgoing calls

Tested by 5

test_invalid_casesMethod · 0.72
test_correct_resultsMethod · 0.72
test_torchMethod · 0.72
test_meta_dictMethod · 0.72
test_tranform_dictMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…