本文整理汇总了Python中mne.SourceEstimate.get_peak方法的典型用法代码示例。如果您正苦于以下问题:Python SourceEstimate.get_peak方法的具体用法?Python SourceEstimate.get_peak怎么用?Python SourceEstimate.get_peak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.SourceEstimate
的用法示例。
在下文中一共展示了SourceEstimate.get_peak方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_visualize_mft_sources
# 需要导入模块: from mne import SourceEstimate [as 别名]
# 或者: from mne.SourceEstimate import get_peak [as 别名]
def plot_visualize_mft_sources(fwdmag, stcdata, tmin, tstep,
subject, subjects_dir):
'''
Plot the MFT sources at time point of peak.
'''
print "##### Attempting to plot:"
# cf. decoding/plot_decoding_spatio_temporal_source.py
vertices = [s['vertno'] for s in fwdmag['src']]
if len(vertices) == 1:
vertices = [fwdmag['src'][0]['vertno'][fwdmag['src'][0]['rr'][fwdmag['src'][0]['vertno']][:, 0] <= -0.],
fwdmag['src'][0]['vertno'][fwdmag['src'][0]['rr'][fwdmag['src'][0]['vertno']][:, 0] > -0.]]
stc_feat = SourceEstimate(stcdata, vertices=vertices,
tmin=-0.2, tstep=tstep, subject=subject)
for hemi in ['lh', 'rh']:
brain = stc_feat.plot(surface='white', hemi=hemi, subjects_dir=subjects_dir,
transparent=True, clim='auto')
brain.show_view('lateral')
# use peak getter to move visualization to the time point of the peak
tmin = 0.095
tmax = 0.10
print "Restricting peak search to [%fs, %fs]" % (tmin, tmax)
if hemi == 'both':
vertno_max, time_idx = stc_feat.get_peak(hemi='rh', time_as_index=True,
tmin=tmin, tmax=tmax)
else:
vertno_max, time_idx = stc_feat.get_peak(hemi=hemi, time_as_index=True,
tmin=tmin, tmax=tmax)
if hemi == 'lh':
comax = fwdmag['src'][0]['rr'][vertno_max]
print "hemi=%s: vertno_max=%d, time_idx=%d fwdmag['src'][0]['rr'][vertno_max] = " %\
(hemi, vertno_max, time_idx), comax
elif len(fwdmag['src']) > 1:
comax = fwdmag['src'][1]['rr'][vertno_max]
print "hemi=%s: vertno_max=%d, time_idx=%d fwdmag['src'][1]['rr'][vertno_max] = " %\
(hemi, vertno_max, time_idx), comax
print "hemi=%s: setting time_idx=%d" % (hemi, time_idx)
brain.set_data_time_index(time_idx)
# draw marker at maximum peaking vertex
brain.add_foci(vertno_max, coords_as_verts=True, hemi=hemi, color='blue',
scale_factor=0.6)
offsets = np.append([0], [s['nuse'] for s in fwdmag['src']])
if hemi == 'lh':
ifoci = [np.nonzero([stcdata[0:offsets[1],time_idx]>=0.25*np.max(stcdata[:,time_idx])][0])]
vfoci = fwdmag['src'][0]['vertno'][ifoci[0][0]]
cfoci = fwdmag['src'][0]['rr'][vfoci]
print "Coords of %d sel. vfoci: " % cfoci.shape[0]
print cfoci
print "vfoci: "
print vfoci
print "brain.geo['lh'].coords[vfoci] : "
print brain.geo['lh'].coords[vfoci]
elif len(fwdmag['src']) > 1:
ifoci = [np.nonzero([stcdata[offsets[1]:,time_idx]>=0.25*np.max(stcdata[:,time_idx])][0])]
vfoci = fwdmag['src'][1]['vertno'][ifoci[0][0]]
cfoci = fwdmag['src'][1]['rr'][vfoci]
print "Coords of %d sel. vfoci: " % cfoci.shape[0]
print cfoci
print "vfoci: "
print vfoci
print "brain.geo['rh'].coords[vfoci] : "
print brain.geo['rh'].coords[vfoci]
mrfoci = np.zeros(cfoci.shape)
invmri_head_t = invert_transform(fwdmag['info']['mri_head_t'])
mrfoci = apply_trans(invmri_head_t['trans'],cfoci, move=True)
print "mrfoci: "
print mrfoci
# Just some blops:
bloblist = np.zeros((300,3))
for i in xrange(100):
bloblist[i,0] = float(i)
bloblist[i+100,1] = float(i)
bloblist[i+200,2] = float(i)
mrblobs = apply_trans(invmri_head_t['trans'], bloblist, move=True)
brain.save_image('testfig_map_%s.png' % hemi)
brain.close()