Beispiel #1
0
    def __init__(
        self,
        keys: KeysCollection,
        as_closest_canonical: bool = False,
        dtype: Optional[np.dtype] = np.float32,
        meta_key_postfix: str = "meta_dict",
        overwriting: bool = False,
    ) -> None:
        """
        Args:
            keys: keys of the corresponding items to be transformed.
                See also: :py:class:`monai.transforms.compose.MapTransform`
            as_closest_canonical: if True, load the image as closest to canonical axis format.
            dtype: if not None convert the loaded image data to this data type.
            meta_key_postfix: use `key_{postfix}` to store the metadata of the nifti image,
                default is `meta_dict`. The meta data is a dictionary object.
                For example, load nifti file for `image`, store the metadata into `image_meta_dict`.
            overwriting: whether allow to overwrite existing meta data of same key.
                default is False, which will raise exception if encountering existing key.

        Raises:
            ValueError: meta_key_postfix must be a string.

        """
        loader = LoadNifti(as_closest_canonical, False, dtype)
        super().__init__(keys, loader, meta_key_postfix, overwriting)
Beispiel #2
0
 def __init__(self,
              keys,
              as_closest_canonical=False,
              dtype=np.float32,
              meta_key_format="{}.{}",
              overwriting_keys=False):
     """
     Args:
         keys (hashable items): keys of the corresponding items to be transformed.
             See also: :py:class:`monai.transforms.compose.MapTransform`
         as_closest_canonical (bool): if True, load the image as closest to canonical axis format.
         dtype (np.dtype, optional): if not None convert the loaded image to this data type.
         meta_key_format (str): key format to store meta data of the nifti image.
             it must contain 2 fields for the key of this image and the key of every meta data item.
         overwriting_keys (bool): whether allow to overwrite existing keys of meta data.
             default is False, which will raise exception if encountering existing key.
     """
     super().__init__(keys)
     self.loader = LoadNifti(as_closest_canonical, False, dtype)
     self.meta_key_format = meta_key_format
     self.overwriting_keys = overwriting_keys