Repository: Project-MONAI/MONAI
File: monai/transforms/spatial/dictionary.py (Python)

Code before:
        self,
        keys: KeysCollection,
        axcodes: str | None = None,
        as_closest_canonical: bool = False,
        labels: Sequence[tuple[str, str]] | None = None,
        allow_missing_keys: bool = False,
        lazy: bool = False,
    ) -> None:
        """
        Args:
            axcodes: N elements sequence for spatial ND input's orientation.
                e.g. axcodes='RAS' represents 3D orientation:
                (Left, Right), (Posterior, Anterior), (Inferior, Superior).
                default orientation labels options are: 'L' and 'R' for the first dimension,
                'P' and 'A' for the second, 'I' and 'S' for the third.
            as_closest_canonical: if True, load the image as closest to canonical axis format.
            labels: optional, None or sequence of (2,) sequences
                (2,) sequences are labels for (beginning, end) of output axis.
                If ``None``, an appropriate value is chosen depending on the
                value of the ``"space"`` metadata item of a metatensor: if
                ``"space"`` is ``"LPS"``, the value used is ``(('R', 'L'),
                ('A', 'P'), ('I', 'S'))``, if ``"space"`` is ``"RPS"`` or the
                input is not a meta-tensor or has no ``"space"`` item, the
                value ``(('L', 'R'), ('P', 'A'), ('I', 'S'))`` is used. If not
                ``None``, the provided value is always used and the ``"space"``
                metadata item (if any) of the intput is ignored.
            allow_missing_keys: don't raise exception if key is missing.
            lazy: a flag to indicate whether this transform should execute lazily or not.
                Defaults to False

        See Also:
            `nibabel.orientations.ornt2axcodes`.

        """
        MapTransform.__init__(self, keys, allow_missing_keys)
        LazyTransform.__init__(self, lazy=lazy)
        self.ornt_transform = Orientation(
            axcodes=axcodes, as_closest_canonical=as_closest_canonical, labels=labels, lazy=lazy
        )

    @LazyTransform.lazy.setter  # type: ignore
    def lazy(self, val: bool) -> None:
        self._lazy = val
        self.ornt_transform.lazy = val

    def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None) -> dict[Hashable, torch.Tensor]:
        """
        Args:
            data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
                in this dictionary must be tensor like arrays that are channel first and have at most
                three spatial dimensions

Review comment (suggestion):
```suggestion
                metadata item (if any) of the input is ignored.
```

Code after:
        self,
        keys: KeysCollection,
        axcodes: str | None = None,
        as_closest_canonical: bool = False,
        labels: Sequence[tuple[str, str]] | None = None,
        allow_missing_keys: bool = False,
        lazy: bool = False,
    ) -> None:
        """
        Args:
            axcodes: N elements sequence for spatial ND input's orientation.
                e.g. axcodes='RAS' represents 3D orientation:
                (Left, Right), (Posterior, Anterior), (Inferior, Superior).
                default orientation labels options are: 'L' and 'R' for the first dimension,
                'P' and 'A' for the second, 'I' and 'S' for the third.
            as_closest_canonical: if True, load the image as closest to canonical axis format.
            labels: optional, None or sequence of (2,) sequences
                (2,) sequences are labels for (beginning, end) of output axis.
                If ``None``, an appropriate value is chosen depending on the
                value of the ``"space"`` metadata item of a metatensor: if
                ``"space"`` is ``"LPS"``, the value used is ``(('R', 'L'),
                ('A', 'P'), ('I', 'S'))``, if ``"space"`` is ``"RPS"`` or the
                input is not a meta-tensor or has no ``"space"`` item, the
                value ``(('L', 'R'), ('P', 'A'), ('I', 'S'))`` is used. If not
                ``None``, the provided value is always used and the ``"space"``
                metadata item (if any) of the input is ignored.
            allow_missing_keys: don't raise exception if key is missing.
            lazy: a flag to indicate whether this transform should execute lazily or not.
                Defaults to False

        See Also:
            `nibabel.orientations.ornt2axcodes`.

        """
        MapTransform.__init__(self, keys, allow_missing_keys)
        LazyTransform.__init__(self, lazy=lazy)
        self.ornt_transform = Orientation(
            axcodes=axcodes, as_closest_canonical=as_closest_canonical, labels=labels, lazy=lazy
        )

    @LazyTransform.lazy.setter  # type: ignore
    def lazy(self, val: bool) -> None:
        self._lazy = val
        self.ornt_transform.lazy = val

    def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = None) -> dict[Hashable, torch.Tensor]:
        """
        Args:
            data: a dictionary containing the tensor-like data to be processed. The ``keys`` specified
                in this dictionary must be tensor like arrays that are channel first and have at most
                three spatial dimensions