from glob import glob


def get_subjectdcmdir(subjid, dcm_template):
    """Return the TrioTim directory for each subject

    Assumes that this directory is inside the subjects directory
    """
    dirlist = glob(dcm_template%subjid)
    if not dirlist:
        raise IOError('Directory %s does not exist'%(dcm_template%subjid))
    return dirlist[0]