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

Class Orientation

monai/transforms/spatial/array.py:553–703  ·  view source on GitHub ↗

Change the input image's orientation into the specified based on `axcodes`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information.

Source from the content-addressed store, hash-verified

551
552
553class Orientation(InvertibleTransform, LazyTransform):
554 """
555 Change the input image's orientation into the specified based on `axcodes`.
556
557 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
558 for more information.
559 """
560
561 backend = [TransformBackends.NUMPY, TransformBackends.TORCH]
562
563 @deprecated_arg_default(
564 name="labels",
565 old_default=(("L", "R"), ("P", "A"), ("I", "S")),
566 new_default=None,
567 msg_suffix=(
568 "Default value changed to None meaning that the transform now uses the 'space' of a "
569 "meta-tensor, if applicable, to determine appropriate axis labels."
570 ),
571 )
572 def __init__(
573 self,
574 axcodes: str | None = None,
575 as_closest_canonical: bool = False,
576 labels: Sequence[tuple[str, str]] | None = None,
577 lazy: bool = False,
578 ) -> None:
579 """
580 Args:
581 axcodes: N elements sequence for spatial ND input&#x27;s orientation.
582 e.g. axcodes='RAS' represents 3D orientation:
583 (Left, Right), (Posterior, Anterior), (Inferior, Superior).
584 default orientation labels options are: 'L' and 'R' for the first dimension,
585 'P' and 'A' for the second, 'I' and 'S' for the third.
586 as_closest_canonical: if True, load the image as closest to canonical axis format.
587 labels: optional, None or sequence of (2,) sequences
588 (2,) sequences are labels for (beginning, end) of output axis.
589 If ``None``, an appropriate value is chosen depending on the
590 value of the ``"space"`` metadata item of a metatensor: if
591 ``"space"`` is ``"LPS"``, the value used is ``(('R', 'L'),
592 ('A', 'P'), ('I', 'S'))``, if ``"space"`` is ``"RPS"`` or the
593 input is not a meta-tensor or has no ``"space"`` item, the
594 value ``(('L', 'R'), ('P', 'A'), ('I', 'S'))`` is used. If not
595 ``None``, the provided value is always used and the ``"space"``
596 metadata item (if any) of the input is ignored.
597 lazy: a flag to indicate whether this transform should execute lazily or not.
598 Defaults to False
599
600 Raises:
601 ValueError: When ``axcodes=None`` and ``as_closest_canonical=True``. Incompatible values.
602
603 See Also: `nibabel.orientations.ornt2axcodes`.
604
605 """
606 LazyTransform.__init__(self, lazy=lazy)
607 if axcodes is None and not as_closest_canonical:
608 raise ValueError("Incompatible values: axcodes=None and as_closest_canonical=True.")
609 if axcodes is not None and as_closest_canonical:
610 warnings.warn("using as_closest_canonical=True, axcodes ignored.")

Callers 11

__init__Method · 0.90
test_consistencyMethod · 0.90
test_ornt_metaMethod · 0.90
test_ornt_torchMethod · 0.90
test_bad_paramsMethod · 0.90
test_inverseMethod · 0.90
test_invertMethod · 0.90
test_inverse_arrayMethod · 0.90
inverseMethod · 0.85

Calls

no outgoing calls

Tested by 8

test_consistencyMethod · 0.72
test_ornt_metaMethod · 0.72
test_ornt_torchMethod · 0.72
test_bad_paramsMethod · 0.72
test_inverseMethod · 0.72
test_invertMethod · 0.72
test_inverse_arrayMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…