当前位置: 首页>>代码示例>>Python>>正文


Python Brain.set_data_time_index方法代码示例

本文整理汇总了Python中surfer.Brain.set_data_time_index方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.set_data_time_index方法的具体用法?Python Brain.set_data_time_index怎么用?Python Brain.set_data_time_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surfer.Brain的用法示例。


在下文中一共展示了Brain.set_data_time_index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_data_time_index [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()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:62,代码来源:test_viz.py

示例2: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_data_time_index [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 = 1e3 * np.linspace(stc['tmin'],
                             stc['tmin'] + data.shape[1] * stc['tstep'],
                             data.shape[1])
    colormap = 'hot'
    time_label = 'time=%0.2f ms'
    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label)
    brain.set_data_time_index(2)
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
开发者ID:joewalter,项目名称:PySurfer,代码行数:20,代码来源:test_viz.py

示例3: time

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_data_time_index [as 别名]
    time points in milliseconds
    """
    time = 1e3 * np.linspace(stc['tmin'],
                             stc['tmin'] + data.shape[1] * stc['tstep'],
                             data.shape[1])
    """
    colormap to use
    """
    colormap = 'hot'

    """
    label for time annotation
    """
    time_label = 'time=%0.2f ms'

    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label,
                   hemi=hemi)

"""
scale colormap and set time (index) to display
"""
brain.set_data_time_index(2)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

"""
uncomment these lines to use the interactive TimeViewer GUI
"""
#from surfer import TimeViewer
#viewer = TimeViewer(brain)
开发者ID:vsteiger,项目名称:PySurfer,代码行数:32,代码来源:plot_meg_inverse_solution.py


注:本文中的surfer.Brain.set_data_time_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。