def __init__( self, keys: KeysCollection, 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` dtype: if not None convert the loaded image to this data type. meta_key_postfix: use `key_{postfix}` to to store meta data 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. """ super().__init__(keys) self.loader = LoadPNG(False, dtype) if not isinstance(meta_key_postfix, str): raise ValueError("meta_key_postfix must be a string.") self.meta_key_postfix = meta_key_postfix self.overwriting = overwriting
def __init__(self, keys, dtype=np.float32, meta_key_format="{}.{}"): """ Args: keys (hashable items): keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` 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 loaded image. it must contain 2 fields for the key of this image and the key of every meta data item. """ super().__init__(keys) self.loader = LoadPNG(False, dtype) self.meta_key_format = meta_key_format
def __init__( self, keys: KeysCollection, 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` 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 PNG image, default is `meta_dict`. The meta data is a dictionary object. For example, load PNG 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. """ loader = LoadPNG(False, dtype) super().__init__(keys, loader, meta_key_postfix, overwriting)