예제 #1
0
    def __init__(
        self,
        keys: KeysCollection,
        axcodes=None,
        as_closest_canonical: bool = False,
        labels=tuple(zip("LPI", "RAS")),
        meta_key_postfix: str = "meta_dict",
    ):
        """
        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.
                Defaults to ``(('L', 'R'), ('P', 'A'), ('I', 'S'))``.
            meta_key_postfix: use `key_{postfix}` to to fetch the meta data according to the key data,
                default is `meta_dict`, the meta data is a dictionary object.
                For example, to handle key `image`,  read/write affine matrices from the
                metadata `image_meta_dict` dictionary's `affine` field.

        Raises:
            ValueError: meta_key_postfix must be a string.

        See Also:
            `nibabel.orientations.ornt2axcodes`.
        """
        super().__init__(keys)
        self.ornt_transform = Orientation(axcodes=axcodes, as_closest_canonical=as_closest_canonical, labels=labels)
        if not isinstance(meta_key_postfix, str):
            raise ValueError("meta_key_postfix must be a string.")
        self.meta_key_postfix = meta_key_postfix
예제 #2
0
    def __init__(self,
                 keys,
                 axcodes=None,
                 as_closest_canonical=False,
                 labels=tuple(zip('LPI', 'RAS')),
                 meta_key_format='{}.{}'):
        """
        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 (boo): 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.
                Defaults to ``(('L', 'R'), ('P', 'A'), ('I', 'S'))``.
            meta_key_format (str): key format to read/write affine matrices to the data dictionary.

        See Also:
            `nibabel.orientations.ornt2axcodes`.
        """
        super().__init__(keys)
        self.ornt_transform = Orientation(
            axcodes=axcodes,
            as_closest_canonical=as_closest_canonical,
            labels=labels)
        self.meta_key_format = meta_key_format