MetaTensor(meta_tensor.py) is atorch.Tensorsubclass carrying image metadata, affine information, and the record of applied transforms used by inverse transforms and lazy resampling. Code that silently converts it to a plain tensor (for example throughnp.asarrayround trips) loses that information; preserve the type unless dropping it is the point.- Datasets live in
dataset.py:Dataset,CacheDataset,SmartCacheDataset,PersistentDataset, and friends. Readers and writers are registered inimage_reader.pyandimage_writer.py.
CacheDatasetcaches the deterministic part of the pipeline. Itscopy_cache=Truedefault deep-copies cached items before the random transforms run; turning it off for speed reuses the cached tensors and can corrupt the cache for the next epoch.- Optional formats (nibabel, pydicom, PIL, and others) are loaded through
monai.utils.optional_importinside the readers. A reader must still import cleanly when its backend package is missing. monai.data.DataLoaderextends the PyTorch loader with MONAI defaults; check it before reaching fortorch.utils.data.DataLoaderin MONAI code.- Test images and other binary data do not belong in this repository. Tests
fetch data through
tests.utilshelpers from the MONAI-extra-test-data releases; seetests/AGENTS.md.