monailabel.transform.pre module

class monailabel.transform.pre.LoadImageExd(keys, reader=None, dtype=<class 'numpy.float32'>, meta_keys=None, meta_key_postfix='meta_dict', overwriting=False, image_only=True, ensure_channel_first=False, simple_keys=False, prune_meta_pattern=None, prune_meta_sep='.', allow_missing_keys=False, expanduser=True, *args, **kwargs)[source]


  • keys – keys of the corresponding items to be transformed. See also: monai.transforms.compose.MapTransform

  • reader – reader to load image file and metadata - if reader is None, a default set of SUPPORTED_READERS will be used. - if reader is a string, it’s treated as a class name or dotted path (such as ""), the supported built-in reader classes are "ITKReader", "NibabelReader", "NumpyReader". a reader instance will be constructed with the *args and **kwargs parameters. - if reader is a reader class/instance, it will be registered to this loader accordingly.

  • dtype – if not None, convert the loaded image data to this data type.

  • meta_keys – explicitly indicate the key to store the corresponding metadata dictionary. the metadata is a dictionary object which contains: filename, original_shape, etc. it can be a sequence of string, map to the keys. if None, will try to construct meta_keys by key_{meta_key_postfix}.

  • meta_key_postfix – if meta_keys is None, use key_{postfix} to store the metadata of the nifti image, default is meta_dict. The metadata is a dictionary object. For example, load nifti file for image, store the metadata into image_meta_dict.

  • overwriting – whether allow overwriting existing metadata of same key. default is False, which will raise exception if encountering existing key.

  • image_only – if True return dictionary containing just only the image volumes, otherwise return dictionary containing image data array and header dict per input key.

  • ensure_channel_first – if True and loaded both image array and metadata, automatically convert the image array shape to channel first. default to False.

  • simple_keys – whether to remove redundant metadata keys, default to False for backward compatibility.

  • prune_meta_pattern – combined with prune_meta_sep, a regular expression used to match and prune keys in the metadata (nested dictionary), default to None, no key deletion.

  • prune_meta_sep – combined with prune_meta_pattern, used to match and prune keys in the metadata (nested dictionary). default is “.”, see also monai.transforms.DeleteItemsd. e.g. prune_meta_pattern=".*_code$", prune_meta_sep=" " removes meta keys that ends with "_code".

  • allow_missing_keys – don’t raise exception if key is missing.

  • expanduser – if True cast filename to Path and call .expanduser on it, otherwise keep filename as is.

  • args – additional parameters for reader if providing a reader name.

  • kwargs – additional parameters for reader if providing a reader name.

class monailabel.transform.pre.LoadImageTensord(keys, allow_missing_keys=False, load_image_d=None)[source]

Bases: monai.transforms.transform.MapTransform

class monailabel.transform.pre.NormalizeLabeld(keys, allow_missing_keys=False, value=1)[source]

Bases: monai.transforms.transform.MapTransform