import re


def parse_bids_subject(filename):
    """Get subject and session information form a BIDS filename."""
    matching = re.match("sub-([A-Za-z0-9]*)_ses-([A-Z]*)", filename)
    if matching:
        return matching.group(1), matching.group(2)
    else:
        raise ValueError("Invalid file name. Is the input in BIDS?")