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


Python Brain.set_surf方法代码示例

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


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

示例1: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [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_label

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [as 别名]
def test_label():
    """Test plotting of label."""
    _set_backend()
    subject_id = "fsaverage"
    hemi = "lh"
    surf = "inflated"
    brain = Brain(subject_id, hemi, surf)
    brain.add_label("BA1")
    brain.add_label("BA1", color="blue", scalar_thresh=.5)
    subj_dir = utils._get_subjects_dir()
    label_file = pjoin(subj_dir, subject_id,
                       "label", "%s.MT.label" % hemi)
    brain.add_label(label_file)
    brain.add_label("BA44", borders=True)
    brain.add_label("BA6", alpha=.7)
    brain.show_view("medial")
    brain.add_label("V1", color="steelblue", alpha=.6)
    brain.add_label("V2", color="#FF6347", alpha=.6)
    brain.add_label("entorhinal", color=(.2, 1, .5), alpha=.6)
    brain.set_surf('white')

    # remove labels
    brain.remove_labels('V1')
    assert_in('V2', brain.labels_dict)
    assert_not_in('V1', brain.labels_dict)
    brain.remove_labels()
    assert_not_in('V2', brain.labels_dict)

    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:31,代码来源:test_viz.py

示例3: test_label

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [as 别名]
def test_label():
    """Test plotting of label."""
    _set_backend()
    subject_id = "fsaverage"
    hemi = "lh"
    surf = "inflated"
    brain = Brain(subject_id, hemi, surf)
    view = get_view(brain)

    extra, subj_dir = _get_extra()
    brain.add_label("BA1" + extra)
    check_view(brain, view)
    brain.add_label("BA1" + extra, color="blue", scalar_thresh=.5)
    label_file = pjoin(subj_dir, subject_id,
                       "label", "%s.MT%s.label" % (hemi, extra))
    brain.add_label(label_file)
    brain.add_label("BA44" + extra, borders=True)
    brain.add_label("BA6" + extra, alpha=.7)
    brain.show_view("medial")
    brain.add_label("V1" + extra, color="steelblue", alpha=.6)
    brain.add_label("V2" + extra, color="#FF6347", alpha=.6)
    brain.add_label("entorhinal" + extra, color=(.2, 1, .5), alpha=.6)
    brain.set_surf('white')
    brain.show_view(dict(elevation=40, distance=430), distance=430)
    with pytest.raises(ValueError, match='!='):
        brain.show_view(dict(elevation=40, distance=430), distance=431)

    # remove labels
    brain.remove_labels('V1' + extra)
    assert 'V2' + extra in brain.labels_dict
    assert 'V1' + extra not in brain.labels_dict
    brain.remove_labels()
    assert 'V2' + extra not in brain.labels_dict

    brain.close()
开发者ID:nipy,项目名称:PySurfer,代码行数:37,代码来源:test_viz.py

示例4: test_data

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [as 别名]
def test_data():
    """Test plotting of data."""
    _set_backend()
    brain = Brain(*std_args)
    mri_file = pjoin(data_dir, 'resting_corr.nii.gz')
    reg_file = pjoin(data_dir, 'register.dat')
    surf_data = io.project_volume_data(mri_file, "lh", reg_file)
    brain.add_data(surf_data, -.7, .7, colormap="jet", alpha=.7)
    brain.set_surf('white')
    brain.add_data([], vertices=np.array([], int))
    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:13,代码来源:test_viz.py

示例5: test_annot

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [as 别名]
def test_annot():
    """Test plotting of annot."""
    _set_backend()
    annots = ['aparc', 'aparc.a2005s']
    borders = [True, False, 2]
    alphas = [1, 0.5]
    brain = Brain(*std_args)
    for a, b, p in zip(annots, borders, alphas):
        brain.add_annotation(a, b, p)
    brain.set_surf('white')
    assert_raises(ValueError, brain.add_annotation, 'aparc', borders=-1)

    subj_dir = utils._get_subjects_dir()
    annot_path = pjoin(subj_dir, subject_id, 'label', 'lh.aparc.a2009s.annot')
    labels, ctab, names = nib.freesurfer.read_annot(annot_path)
    brain.add_annotation((labels, ctab))

    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:20,代码来源:test_viz.py

示例6: test_overlay

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import set_surf [as 别名]
def test_overlay():
    """Test plotting of overlay."""
    _set_backend()
    # basic overlay support
    overlay_file = pjoin(data_dir, "lh.sig.nii.gz")
    brain = Brain(*std_args)
    brain.add_overlay(overlay_file)
    brain.overlays["sig"].remove()
    brain.add_overlay(overlay_file, min=5, max=20, sign="pos")
    sig1 = io.read_scalar_data(pjoin(data_dir, "lh.sig.nii.gz"))
    sig2 = io.read_scalar_data(pjoin(data_dir, "lh.alt_sig.nii.gz"))

    # two-sided overlay
    brain.add_overlay(sig1, 4, 30, name="two-sided")
    overlay = brain.overlays_dict.pop('two-sided')[0]
    assert_array_equal(overlay.pos_bar.data_range, [4, 30])
    assert_array_equal(overlay.neg_bar.data_range, [-30, -4])
    assert_equal(overlay.pos_bar.reverse_lut, True)
    assert_equal(overlay.neg_bar.reverse_lut, False)
    overlay.remove()

    thresh = 4
    sig1[sig1 < thresh] = 0
    sig2[sig2 < thresh] = 0

    conjunct = np.min(np.vstack((sig1, sig2)), axis=0)
    brain.add_overlay(sig1, 4, 30, name="sig1")
    brain.overlays["sig1"].pos_bar.lut_mode = "Reds"
    brain.overlays["sig1"].pos_bar.visible = False

    brain.add_overlay(sig2, 4, 30, name="sig2")
    brain.overlays["sig2"].pos_bar.lut_mode = "Blues"
    brain.overlays["sig2"].pos_bar.visible = False

    brain.add_overlay(conjunct, 4, 30, name="conjunct")
    brain.overlays["conjunct"].pos_bar.lut_mode = "Purples"
    brain.overlays["conjunct"].pos_bar.visible = False

    brain.set_surf('white')

    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:43,代码来源:test_viz.py


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