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
| 1501 | |
| 1502 | |
| 1503 | class 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'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): |
no outgoing calls
searching dependent graphs…