Dictionary-based wrapper of :py:class:`monai.transforms.LoadImage`, It can load both image data and metadata. When loading a list of files in one key, the arrays will be stacked and a new dimension will be added as the first dimension In this case, the metadata of the first image wi
| 37 | |
| 38 | |
| 39 | class LoadImaged(MapTransform): |
| 40 | """ |
| 41 | Dictionary-based wrapper of :py:class:`monai.transforms.LoadImage`, |
| 42 | It can load both image data and metadata. When loading a list of files in one key, |
| 43 | the arrays will be stacked and a new dimension will be added as the first dimension |
| 44 | In this case, the metadata of the first image will be used to represent the stacked result. |
| 45 | The affine transform of all the stacked images should be same. |
| 46 | The output metadata field will be created as ``meta_keys`` or ``key_{meta_key_postfix}``. |
| 47 | |
| 48 | If reader is not specified, this class automatically chooses readers |
| 49 | based on the supported suffixes and in the following order: |
| 50 | |
| 51 | - User-specified reader at runtime when calling this loader. |
| 52 | - User-specified reader in the constructor of `LoadImage`. |
| 53 | - Readers from the last to the first in the registered list. |
| 54 | - Current default readers: (nii, nii.gz -> NibabelReader), (png, jpg, bmp -> PILReader), |
| 55 | (npz, npy -> NumpyReader), (dcm, DICOM series and others -> ITKReader). |
| 56 | |
| 57 | Please note that for png, jpg, bmp, and other 2D formats, readers by default swap axis 0 and 1 after |
| 58 | loading the array with ``reverse_indexing`` set to ``True`` because the spatial axes definition |
| 59 | for non-medical specific file formats is different from other common medical packages. |
| 60 | |
| 61 | Note: |
| 62 | |
| 63 | - If `reader` is specified, the loader will attempt to use the specified readers and the default supported |
| 64 | readers. This might introduce overheads when handling the exceptions of trying the incompatible loaders. |
| 65 | In this case, it is therefore recommended setting the most appropriate reader as |
| 66 | the last item of the `reader` parameter. |
| 67 | |
| 68 | See also: |
| 69 | |
| 70 | - tutorial: https://github.com/Project-MONAI/tutorials/blob/master/modules/load_medical_images.ipynb |
| 71 | |
| 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 |
no outgoing calls
searching dependent graphs…