Exemple #1
0
def glob_matfiles(pattern, subject_getter, ignore=None, restrict=None):
    if ignore is None:
        ignore = []
    i = 1
    doc = {}
    for mat_file in sorted(glob.glob(pattern)):
        sid = parse_path(mat_file, subject_id=subject_getter)['subject_id']
        if (restrict is None and sid not in ignore) or (
                restrict is not None and sid in restrict):
            doc.setdefault('mat_files', []).append(mat_file)
            doc.setdefault('subjects', []).append('sub%03i' % i)
            doc.setdefault('original_subjects', []).append(sid)
            i += 1
        else:
            doc.setdefault('ignored_subjects', []).append(sid)

    return doc
Exemple #2
0
def glob_matfiles(pattern, subject_getter, ignore=None, restrict=None):
    if ignore is None:
        ignore = []
    i = 1
    doc = {}
    for mat_file in sorted(glob.glob(pattern)):
        sid = parse_path(mat_file, subject_id=subject_getter)['subject_id']
        if (restrict is None and sid not in ignore) or (restrict is not None
                                                        and sid in restrict):
            doc.setdefault('mat_files', []).append(mat_file)
            doc.setdefault('subjects', []).append('sub%03i' % i)
            doc.setdefault('original_subjects', []).append(sid)
            i += 1
        else:
            doc.setdefault('ignored_subjects', []).append(sid)

    return doc
Exemple #3
0
def load_intra(mat_file, memory=Memory(None), **kwargs):
    doc = {}
    mat_file = os.path.realpath(mat_file)
    doc.update(parse_path(mat_file, **kwargs))

    work_dir = os.path.split(mat_file)[0]
    mat_file = memory.cache(load_matfile)(mat_file)
    mat = mat_file['SPM']

    doc.update(get_intra_infos(mat_file, memory))

    doc['mask'] = check_path(os.path.join(work_dir, str(mat.VM.fname)))
    doc['onsets'], doc['conditions'] = get_intra_onsets(mat_file, memory)
    doc.update(get_intra_preproc(mat_file, work_dir, doc['n_scans'], memory))
    doc.update(get_intra_images(mat_file, work_dir, memory))
    doc.update(get_intra_design(
        mat_file, doc['n_scans'], doc['contrasts'], memory))

    return doc
Exemple #4
0
def load_intra(mat_file, memory=Memory(None), **kwargs):
    doc = {}
    mat_file = os.path.realpath(mat_file)
    doc.update(parse_path(mat_file, **kwargs))

    work_dir = os.path.split(mat_file)[0]
    mat_file = memory.cache(load_matfile)(mat_file)
    mat = mat_file['SPM']

    doc.update(get_intra_infos(mat_file, memory))

    doc['mask'] = check_path(os.path.join(work_dir, str(mat.VM.fname)))
    doc['onsets'], doc['conditions'] = get_intra_onsets(mat_file, memory)
    doc.update(get_intra_preproc(mat_file, work_dir, doc['n_scans'], memory))
    doc.update(get_intra_images(mat_file, work_dir, memory))
    doc.update(
        get_intra_design(mat_file, doc['n_scans'], doc['contrasts'], memory))

    return doc
Exemple #5
0
def load_preproc(mat_file, memory=Memory(None), **kwargs):
    doc = {}
    mat_file = os.path.realpath(mat_file)
    doc.update(parse_path(mat_file, **kwargs))

    work_dir = os.path.split(mat_file)[0]
    mat_file = memory.cache(load_matfile)(mat_file)
    if 'jobs' in mat_file:
        mat = mat_file['jobs']
    elif 'matlabbatch' in mat_file:
        mat = mat_file['matlabbatch']
    else:
        raise Exception("mat_file type not known.")

    if not hasattr(mat, '__iter__'):
        return doc

    for step in mat:
        if hasattr(step, 'spm'):
            step = step.spm
            doc.update(parse_spm8_preproc(work_dir, step))
        else:
            doc.update(parse_spm5_preproc(work_dir, step))
    return doc
Exemple #6
0
def load_preproc(mat_file, memory=Memory(None), **kwargs):
    doc = {}
    mat_file = os.path.realpath(mat_file)
    doc.update(parse_path(mat_file, **kwargs))

    work_dir = os.path.split(mat_file)[0]
    mat_file = memory.cache(load_matfile)(mat_file)
    if 'jobs' in mat_file:
        mat = mat_file['jobs']
    elif 'matlabbatch' in mat_file:
        mat = mat_file['matlabbatch']
    else:
        raise Exception("mat_file type not known.")

    if not hasattr(mat, '__iter__'):
        return doc

    for step in mat:
        if hasattr(step, 'spm'):
            step = step.spm
            doc.update(parse_spm8_preproc(work_dir, step))
        else:
            doc.update(parse_spm5_preproc(work_dir, step))
    return doc