示例#1
0
def get_flip(label, vertno, inv):
    nvert = [len(vn) for vn in vertno]
    if label.hemi == 'both':
        sub_labels = [label.lh, label.rh]
    else:
        sub_labels = [label]
    this_vertidx = list()
    for slabel in sub_labels:
        if slabel.hemi == 'lh':
            this_vertno = np.intersect1d(vertno[0], slabel.vertices)
            vertidx = np.searchsorted(vertno[0], this_vertno)
        elif slabel.hemi == 'rh':
            this_vertno = np.intersect1d(vertno[1], slabel.vertices)
            vertidx = nvert[0] + np.searchsorted(vertno[1], this_vertno)
        else:
            raise ValueError('label %s has invalid hemi' % label.name)
        this_vertidx.append(vertidx)
    vertidx = np.concatenate(this_vertidx)
    from mne.source_estimate import _get_label_flip
    label_flip = _get_label_flip([label], [vertidx], inv['src'][:2])
    label_flip = np.array(label_flip).flatten()
    return label_flip
示例#2
0
def get_flip(label, vertno, inv):
    nvert = [len(vn) for vn in vertno]
    if label.hemi == 'both':
        sub_labels = [label.lh, label.rh]
    else:
        sub_labels = [label]
    this_vertidx = list()
    for slabel in sub_labels:
        if slabel.hemi == 'lh':
            this_vertno = np.intersect1d(vertno[0], slabel.vertices)
            vertidx = np.searchsorted(vertno[0], this_vertno)
        elif slabel.hemi == 'rh':
            this_vertno = np.intersect1d(vertno[1], slabel.vertices)
            vertidx = nvert[0] + np.searchsorted(vertno[1], this_vertno)
        else:
            raise ValueError('label %s has invalid hemi' % label.name)
        this_vertidx.append(vertidx)
    vertidx = np.concatenate(this_vertidx)
    from mne.source_estimate import _get_label_flip
    label_flip = _get_label_flip([label], [vertidx], inv['src'][:2])
    label_flip = np.array(label_flip).flatten()
    return label_flip
示例#3
0
    sub_labels = [label]
this_vertidx = list()
for slabel in sub_labels:
    if roi_label.hemi == 'lh':
        this_vertno = np.intersect1d(vertno[0], roi_label.vertices)
        vertidx = np.searchsorted(vertno[0], this_vertno)
    elif roi_label.hemi == 'rh':
        this_vertno = np.intersect1d(vertno[1], roi_label.vertices)
        vertidx = nvert[0] + np.searchsorted(vertno[1], this_vertno)
    else:
        raise ValueError('label %s has invalid hemi' % label.name)
    this_vertidx.append(vertidx)
vertidx = np.concatenate(this_vertidx)
from mne.source_estimate import _get_label_flip

label_flip = _get_label_flip([roi_label], [vertidx], inv['src'][:2])
label_flip = np.array(label_flip).flatten()

# get mean
mean_flip = np.dot(label_flip / len(label_flip), sol)
plt.plot(mean_flip, 'g')

w = np.dot(noise_norm.flatten() * label_flip / len(label_flip), K)

plt.plot(np.dot(w, data), 'k--')
plt.figure()
from pynfb.widgets.helpers import ch_names_to_2d_pos

mne.viz.plot_topomap(w, info)

# back engineering flip
示例#4
0
        else:
            sub_labels = [label]
        this_vertidx = list()
        for slabel in sub_labels:
            if roi_label.hemi == 'lh':
                this_vertno = np.intersect1d(vertno[0], roi_label.vertices)
                vertidx = np.searchsorted(vertno[0], this_vertno)
            elif roi_label.hemi == 'rh':
                this_vertno = np.intersect1d(vertno[1], roi_label.vertices)
                vertidx = nvert[0] + np.searchsorted(vertno[1], this_vertno)
            else:
                raise ValueError('label %s has invalid hemi' % label.name)
            this_vertidx.append(vertidx)
        vertidx = np.concatenate(this_vertidx)
        from mne.source_estimate import _get_label_flip
        label_flip = _get_label_flip([roi_label], [vertidx], inv['src'][:2])
        label_flip = np.array(label_flip).flatten()

        # get mean
        mean_flip = np.dot(label_flip/len(label_flip),  sol)
        #plt.plot(mean_flip, 'g')

        w = np.dot(noise_norm.flatten()*label_flip/len(label_flip), K)

        #plt.plot(np.dot(w, data), 'k--')
        #plt.figure()
        from pynfb.widgets.helpers import ch_names_to_2d_pos
        mne.viz.plot_topomap(w, info, axes=axes[k, j], show=False,contours=0)
        axes[0, j].set_title(str(lambda2))