from pathlib import Path


def guess_format(path):
    """Guess file format identifier from it's suffix. Default to DICOM."""
    path = Path(path)
    if path.is_file():
        suffixes = [x.lower() for x in path.suffixes]
        if suffixes[-1] in ['.h5', '.txt', '.zip']:
            return suffixes[-1][1:]
        if suffixes[-1] == '.nii' or path.suffixes[-2:] == ['.nii', '.gz']:
            return 'nifti'
    return 'dicom'