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

Method __init__

monai/transforms/spatial/array.py:572–613  ·  view source on GitHub ↗

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' fo

(
        self,
        axcodes: str | None = None,
        as_closest_canonical: bool = False,
        labels: Sequence[tuple[str, str]] | None = None,
        lazy: bool = False,
    )

Source from the content-addressed store, hash-verified

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'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.")
611 self.axcodes = axcodes
612 self.as_closest_canonical = as_closest_canonical
613 self.labels = labels
614
615 def __call__(self, data_array: torch.Tensor, lazy: bool | None = None) -> torch.Tensor:
616 """

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected