dosma.read

dosma.read(path: Union[str, Path, PathLike], data_format: Optional[ImageDataFormat] = None, unpack: bool = False, **kwargs) Union[MedicalVolume, List[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 True and 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)