dosma.read
- dosma.read(path: Union[str, pathlib.Path, os.PathLike], data_format: Optional[dosma.core.io.format_io.ImageDataFormat] = None, unpack: bool = False, **kwargs) Union[dosma.core.med_volume.MedicalVolume, List[dosma.core.med_volume.MedicalVolume]][source]
Read MedicalVolume(s) from file.
- Parameters
path (str) – File/directory path.
data_format (ImageDataFormat, optional) – Data format (e.g.
'dicom','nifti', etc.). Use this is disambiguate between different data formats. If this function is not working, try using this argument. If not provided, dosma will try to infer data format from file extension.unpack (bool, optional) – If
Trueand only 1 volume is loaded, return a single volume instead of a list of volumes. This only applied to dicom loading.**kwargs – Additional keyword arguments passed to the data format reader.
- Returns
Volume(s) loaded.
- Return type
MedicalVolume | List[MedicalVolume]
Examples
>>> dm.read("/path/to/multi-echo/dicom/folder", group_by="EchoNumbers") >>> dm.read("/path/to/ct/dicom/folder") >>> dm.read("/path/to/ct/nifti/file.nii.gz", mmap=True)