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

Method __init__

monai/transforms/io/dictionary.py:74–149  ·  view source on GitHub ↗

Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` reader: reader to load image file and metadata - if `reader` is None, a default set of `SUPPORTED_READERS` will

(
        self,
        keys: KeysCollection,
        reader: type[ImageReader] | str | None = None,
        dtype: DtypeLike = np.float32,
        meta_keys: KeysCollection | None = None,
        meta_key_postfix: str = DEFAULT_POST_FIX,
        overwriting: bool = False,
        image_only: bool = True,
        ensure_channel_first: bool = False,
        simple_keys: bool = False,
        prune_meta_pattern: str | None = None,
        prune_meta_sep: str = ".",
        allow_missing_keys: bool = False,
        expanduser: bool = True,
        *args,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

72 """
73
74 def __init__(
75 self,
76 keys: KeysCollection,
77 reader: type[ImageReader] | str | None = None,
78 dtype: DtypeLike = np.float32,
79 meta_keys: KeysCollection | None = None,
80 meta_key_postfix: str = DEFAULT_POST_FIX,
81 overwriting: bool = False,
82 image_only: bool = True,
83 ensure_channel_first: bool = False,
84 simple_keys: bool = False,
85 prune_meta_pattern: str | None = None,
86 prune_meta_sep: str = ".",
87 allow_missing_keys: bool = False,
88 expanduser: bool = True,
89 *args,
90 **kwargs,
91 ) -> None:
92 """
93 Args:
94 keys: keys of the corresponding items to be transformed.
95 See also: :py:class:`monai.transforms.compose.MapTransform`
96 reader: reader to load image file and metadata
97 - if `reader` is None, a default set of `SUPPORTED_READERS` will be used.
98 - if `reader` is a string, it's treated as a class name or dotted path
99 (such as ``"monai.data.ITKReader"``), the supported built-in reader classes are
100 ``"ITKReader"``, ``"NibabelReader"``, ``"NumpyReader"``.
101 a reader instance will be constructed with the `*args` and `**kwargs` parameters.
102 - if `reader` is a reader class/instance, it will be registered to this loader accordingly.
103 dtype: if not None, convert the loaded image data to this data type.
104 meta_keys: explicitly indicate the key to store the corresponding metadata dictionary.
105 the metadata is a dictionary object which contains: filename, original_shape, etc.
106 it can be a sequence of string, map to the `keys`.
107 if None, will try to construct meta_keys by `key_{meta_key_postfix}`.
108 meta_key_postfix: if meta_keys is None, use `key_{postfix}` to store the metadata of the nifti image,
109 default is `meta_dict`. The metadata is a dictionary object.
110 For example, load nifti file for `image`, store the metadata into `image_meta_dict`.
111 overwriting: whether allow overwriting existing metadata of same key.
112 default is False, which will raise exception if encountering existing key.
113 image_only: if True return dictionary containing just only the image volumes, otherwise return
114 dictionary containing image data array and header dict per input key.
115 ensure_channel_first: if `True` and loaded both image array and metadata, automatically convert
116 the image array shape to `channel first`. default to `False`.
117 simple_keys: whether to remove redundant metadata keys, default to False for backward compatibility.
118 prune_meta_pattern: combined with `prune_meta_sep`, a regular expression used to match and prune keys
119 in the metadata (nested dictionary), default to None, no key deletion.
120 prune_meta_sep: combined with `prune_meta_pattern`, used to match and prune keys
121 in the metadata (nested dictionary). default is ".", see also :py:class:`monai.transforms.DeleteItemsd`.
122 e.g. ``prune_meta_pattern=".*_code$", prune_meta_sep=" "`` removes meta keys that ends with ``"_code"``.
123 allow_missing_keys: don't raise exception if key is missing.
124 expanduser: if True cast filename to Path and call .expanduser on it, otherwise keep filename as is.
125 args: additional parameters for reader if providing a reader name.
126 kwargs: additional parameters for reader if providing a reader name.
127 """
128 super().__init__(keys, allow_missing_keys)
129 self._loader = LoadImage(
130 reader,
131 image_only,

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 3

LoadImageClass · 0.90
ensure_tuple_repFunction · 0.90
ensure_tupleFunction · 0.90

Tested by

no test coverage detected