本文整理汇总了Python中surfer.Brain.set_time方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.set_time方法的具体用法?Python Brain.set_time怎么用?Python Brain.set_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surfer.Brain
的用法示例。
在下文中一共展示了Brain.set_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_meg_inverse
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_time [as 别名]
def test_meg_inverse():
"""Test plotting of MEG inverse solution."""
_set_backend()
brain = Brain(*std_args)
stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
stc = io.read_stc(stc_fname)
vertices = stc['vertices']
colormap = 'hot'
data = stc['data']
data_full = (brain.geo['lh'].nn[vertices][..., np.newaxis] *
data[:, np.newaxis])
time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
data.shape[1], endpoint=False)
def time_label(t):
return 'time=%0.2f ms' % (1e3 * t)
for use_data in (data, data_full):
brain.add_data(use_data, colormap=colormap, vertices=vertices,
smoothing_steps=1, time=time, time_label=time_label)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
assert_equal(brain.data_dict['lh']['time_idx'], 0)
brain.set_time(.1)
assert_equal(brain.data_dict['lh']['time_idx'], 2)
# viewer = TimeViewer(brain)
# multiple data layers
assert_raises(ValueError, brain.add_data, data, vertices=vertices,
time=time[:-1])
brain.add_data(data, colormap=colormap, vertices=vertices,
smoothing_steps=1, time=time, time_label=time_label,
initial_time=.09)
assert_equal(brain.data_dict['lh']['time_idx'], 1)
data_dicts = brain._data_dicts['lh']
assert_equal(len(data_dicts), 3)
assert_equal(data_dicts[0]['time_idx'], 1)
assert_equal(data_dicts[1]['time_idx'], 1)
# shift time in both layers
brain.set_data_time_index(0)
assert_equal(data_dicts[0]['time_idx'], 0)
assert_equal(data_dicts[1]['time_idx'], 0)
brain.set_data_smoothing_steps(2)
# add second data-layer without time axis
brain.add_data(data[:, 1], colormap=colormap, vertices=vertices,
smoothing_steps=2)
brain.set_data_time_index(2)
assert_equal(len(data_dicts), 4)
# change surface
brain.set_surf('white')
# remove all layers
brain.remove_data()
assert_equal(brain._data_dicts['lh'], [])
brain.close()
示例2: test_meg_inverse
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_time [as 别名]
def test_meg_inverse():
"""Test plotting of MEG inverse solution
"""
mlab.options.backend = 'test'
brain = Brain(*std_args)
stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
stc = io.read_stc(stc_fname)
data = stc['data']
vertices = stc['vertices']
time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
data.shape[1], endpoint=False)
colormap = 'hot'
def time_label(t):
return 'time=%0.2f ms' % (1e3 * t)
brain.add_data(data, colormap=colormap, vertices=vertices,
smoothing_steps=10, time=time, time_label=time_label)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
assert_equal(brain.data_dict['lh']['time_idx'], 0)
brain.set_time(.1)
assert_equal(brain.data_dict['lh']['time_idx'], 2)
# viewer = TimeViewer(brain)
brain.add_data(data, colormap=colormap, vertices=vertices,
smoothing_steps=10, time=time, time_label=time_label,
initial_time=.09, remove_existing=True)
assert_equal(brain.data_dict['lh']['time_idx'], 1)
brain.close()
示例3: plot_source_estimates
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_time [as 别名]
#.........这里部分代码省略.........
if surfer_version < v06:
raise ImportError("This function requires PySurfer 0.6 (you are "
"running version %s). You can update PySurfer "
"using:\n\n $ pip install -U pysurfer" %
surfer.__version__)
if initial_time is not None and surfer_version > v06:
kwargs = {'initial_time': initial_time}
initial_time = None # don't set it twice
else:
kwargs = {}
if time_unit is None:
warn("The time_unit parameter default will change from 'ms' to 's' "
"in MNE 0.14. To avoid this warning specify the parameter "
"explicitly.", DeprecationWarning)
time_unit = 'ms'
elif time_unit not in ('s', 'ms'):
raise ValueError("time_unit needs to be 's' or 'ms', got %r" %
(time_unit,))
if time_label == 'auto':
if time_unit == 'ms':
time_label = 'time=%0.2f ms'
else:
def time_label(t):
return 'time=%0.2f ms' % (t * 1e3)
if not isinstance(stc, SourceEstimate):
raise ValueError('stc has to be a surface source estimate')
if hemi not in ['lh', 'rh', 'split', 'both']:
raise ValueError('hemi has to be either "lh", "rh", "split", '
'or "both"')
# check `figure` parameter (This will be performed by PySurfer > 0.6)
if figure is not None:
if isinstance(figure, int):
# use figure with specified id
size_ = size if isinstance(size, (tuple, list)) else (size, size)
figure = [mayavi.mlab.figure(figure, size=size_)]
elif not isinstance(figure, (list, tuple)):
figure = [figure]
if not all(isinstance(f, mayavi.core.scene.Scene) for f in figure):
raise TypeError('figure must be a mayavi scene or list of scenes')
# convert control points to locations in colormap
ctrl_pts, colormap = _limits_to_control_points(clim, stc.data, colormap)
# Construct cmap manually if 'mne' and get cmap bounds
# and triage transparent argument
if colormap in ('mne', 'mne_analyze'):
colormap = mne_analyze_colormap(ctrl_pts)
scale_pts = [-1 * ctrl_pts[-1], 0, ctrl_pts[-1]]
transparent = False if transparent is None else transparent
else:
scale_pts = ctrl_pts
transparent = True if transparent is None else transparent
subjects_dir = get_subjects_dir(subjects_dir=subjects_dir,
raise_error=True)
subject = _check_subject(stc.subject, subject, True)
if hemi in ['both', 'split']:
hemis = ['lh', 'rh']
else:
hemis = [hemi]
title = subject if len(hemis) > 1 else '%s - %s' % (subject, hemis[0])
with warnings.catch_warnings(record=True): # traits warnings
brain = Brain(subject, hemi, surface, True, title, cortex, size,
background, foreground, figure, subjects_dir, views,
config_opts=config_opts)
if time_unit == 's':
times = stc.times
else: # time_unit == 'ms'
times = 1e3 * stc.times
for hemi in hemis:
hemi_idx = 0 if hemi == 'lh' else 1
if hemi_idx == 0:
data = stc.data[:len(stc.vertices[0])]
else:
data = stc.data[len(stc.vertices[0]):]
vertices = stc.vertices[hemi_idx]
with warnings.catch_warnings(record=True): # traits warnings
brain.add_data(data, colormap=colormap, vertices=vertices,
smoothing_steps=smoothing_steps, time=times,
time_label=time_label, alpha=alpha, hemi=hemi,
colorbar=colorbar, **kwargs)
# scale colormap and set time (index) to display
brain.scale_data_colormap(fmin=scale_pts[0], fmid=scale_pts[1],
fmax=scale_pts[2], transparent=transparent)
if initial_time is not None:
brain.set_time(initial_time)
if time_viewer:
TimeViewer(brain)
return brain