from pathlib import Path


def _getsourcetype(infiles):
    """
    Determine the type of fieldmap estimation strategy.

    Example
    -------
    >>> _getsourcetype(["path/some_epi.nii.gz"])
    'epi'

    >>> _getsourcetype(["path/some_notepi.nii.gz"])
    'magnitude'

    """

    fname = Path(infiles[0]).name
    return "epi" if fname.endswith(("_epi.nii.gz", "_epi.nii")) else "magnitude"