def remove_end_from_pathname(filen, end='.image'):
    """
    Retrieve the file name excluding an ending extension or terminating string.

    Parameters
    ----------
    filen : str
    end : str
        End to file name to remove. If an extension, include the period, e.g.
        ".image".
    """
    if not filen.endswith(end):
        raise ValueError('Path does not end in "{0}": {1}'.format(end, filen))
    assert len(filen) > len(end)
    stem = filen[:-len(end)]
    return stem