示例#1
0
def loadsurf_mne(fname, surftype, quiet=True):
    from dataset import SurfData
    sverts_lh, sfaces_lh = mne.surface.read_surface(
        parse.hemineutral(fname) % 'lh')
    sverts_rh, sfaces_rh = mne.surface.read_surface(
        parse.hemineutral(fname) % 'rh')
    return SurfData(sverts_lh, sfaces_lh, sverts_rh, sfaces_rh, surftype)
示例#2
0
def loadsurf_gifti(fname,surftype,quiet=True):
    from nibabel import gifti
    from dataset import SurfData
    fname = '%s.%sgii'%(fname,'%s')
    fname = match_gifti_intent(fname, 'surface')

    surf_lh = gifti.read(parse.hemineutral(fname)%'lh')
    surf_rh = gifti.read(parse.hemineutral(fname)%'rh')
    
    sverts_lh,sfaces_lh = surf_lh.darrays[0].data, surf_lh.darrays[1].data
    sverts_rh,sfaces_rh = surf_rh.darrays[0].data, surf_rh.darrays[1].data

    return SurfData(sverts_lh,sfaces_lh,sverts_rh,sfaces_rh,surftype)
示例#3
0
def loadsurf_gifti(fname, surftype, quiet=True):
    from nibabel import gifti
    from dataset import SurfData
    fname = '%s.%sgii' % (fname, '%s')
    fname = match_gifti_intent(fname, 'surface')

    surf_lh = gifti.read(parse.hemineutral(fname) % 'lh')
    surf_rh = gifti.read(parse.hemineutral(fname) % 'rh')

    sverts_lh, sfaces_lh = surf_lh.darrays[0].data, surf_lh.darrays[1].data
    sverts_rh, sfaces_rh = surf_rh.darrays[0].data, surf_rh.darrays[1].data

    return SurfData(sverts_lh, sfaces_lh, sverts_rh, sfaces_rh, surftype)
示例#4
0
def loadannot_gifti(parcname,
                    subject,
                    subjects_dir,
                    labnam=None,
                    surf_type='pial',
                    surf_struct=None,
                    quiet=False):

    import numpy as np
    from nibabel import gifti

    fname = os.path.join(subjects_dir, subject, 'label',
                         'lh.%s.%sgii' % (parcname, '%s'))
    fname = match_gifti_intent(fname, 'label')

    annot_lh = gifti.read(parse.hemineutral(fname) % 'lh')
    annot_rh = gifti.read(parse.hemineutral(fname) % 'rh')

    #unpack the annotation data
    labdict_lh = parse.appendhemis(annot_lh.labeltable.get_labels_as_dict(),
                                   "lh_")
    labv_lh = map(labdict_lh.get, annot_lh.darrays[0].data)

    labdict_rh = parse.appendhemis(annot_rh.labeltable.get_labels_as_dict(),
                                   "rh_")
    labv_rh = map(labdict_rh.get, annot_rh.darrays[0].data)

    labv = labv_lh + labv_rh

    #return labv
    #The objective is now to create MNE label files for these on the fly

    vertices = np.vstack((surf_struct.lh_verts, surf_struct.rh_verts))
    mne_labels = []

    for lab in labnam:
        cur_lab_verts = np.flatnonzero(np.array(labv) == lab)
        cur_lab_pos = vertices[cur_lab_verts]

        cur_lab = mne.Label(cur_lab_verts,
                            pos=cur_lab_pos / 1000,
                            hemi=lab[:2],
                            name=parse.demangle_hemi(lab))
        mne_labels.append(cur_lab)

    return mne_labels
示例#5
0
def loadannot_gifti(parcname, subject, subjects_dir, labnam=None, surf_type='pial',
        surf_struct=None, quiet=False):

    import numpy as np
    from nibabel import gifti

    fname = os.path.join(subjects_dir, subject, 'label', 'lh.%s.%sgii'%(parcname,'%s'))
    fname = match_gifti_intent(fname, 'label')

    annot_lh = gifti.read(parse.hemineutral(fname)%'lh')
    annot_rh = gifti.read(parse.hemineutral(fname)%'rh')
    
    #unpack the annotation data
    labdict_lh=parse.appendhemis(annot_lh.labeltable.get_labels_as_dict(),"lh_")
    labv_lh=map(labdict_lh.get,annot_lh.darrays[0].data)

    labdict_rh=parse.appendhemis(annot_rh.labeltable.get_labels_as_dict(),"rh_")
    labv_rh=map(labdict_rh.get,annot_rh.darrays[0].data)

    labv=labv_lh+labv_rh

    #return labv
    #The objective is now to create MNE label files for these on the fly

    vertices = np.vstack((surf_struct.lh_verts, surf_struct.rh_verts))
    mne_labels = []

    for lab in labnam:
        cur_lab_verts = np.flatnonzero(np.array(labv)==lab)
        cur_lab_pos = vertices[cur_lab_verts]

        cur_lab = mne.Label(cur_lab_verts, pos=cur_lab_pos/1000, hemi=lab[:2],
            name = parse.demangle_hemi(lab))
        mne_labels.append(cur_lab)
        
    return mne_labels	
示例#6
0
def loadsurf_mne(fname,surftype,quiet=True):
    from dataset import SurfData
    sverts_lh,sfaces_lh=mne.surface.read_surface(parse.hemineutral(fname)%'lh')
    sverts_rh,sfaces_rh=mne.surface.read_surface(parse.hemineutral(fname)%'rh')
    return SurfData(sverts_lh,sfaces_lh,sverts_rh,sfaces_rh,surftype)