• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python surfer.Brain类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_text

def test_text():
    """Test plotting of text
    """
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    brain.add_text(0.1, 0.1, 'Hello', 'blah')
    brain.close()
开发者ID:bpinsard,项目名称:PySurfer,代码行数:7,代码来源:test_viz.py


示例2: test_offscreen

def test_offscreen():
    """Test offscreen rendering
    """
    mlab.options.backend = 'auto'
    brain = Brain(*std_args, offscreen=True)
    shot = brain.screenshot()
    assert_array_equal(shot.shape, (800, 800, 3))
开发者ID:arokem,项目名称:PySurfer,代码行数:7,代码来源:test_viz.py


示例3: test_data_limits

def test_data_limits():
    """Test handling of data limits."""
    _set_backend()
    brain = Brain(*std_args)
    surf_data = np.zeros(163842)
    pytest.raises(ValueError, brain.add_data, surf_data, 0, 0)
    brain.add_data(surf_data, 0, 1)
    brain.close()
开发者ID:nipy,项目名称:PySurfer,代码行数:8,代码来源:test_viz.py


示例4: main

def main(subid, overlay):
    _, fname = os.path.split(overlay)
    
    hemi = fname[:2]
    brain = Brain(subid, hemi, "pial",
                  config_opts=dict(cortex="low_contrast"))
    brain.add_overlay(overlay, min=0.4, max=4, sign="pos")
    brain.show_view('m')
开发者ID:cindeem,项目名称:PetProcessing,代码行数:8,代码来源:simple_pysurfer.py


示例5: test_offscreen

def test_offscreen():
    """Test offscreen rendering."""
    _set_backend()
    brain = Brain(*std_args, offscreen=True)
    shot = brain.screenshot()
    assert_array_less((400, 400, 2), shot.shape)
    assert_array_less(shot.shape, (801, 801, 4))
    brain.close()
开发者ID:nipy,项目名称:PySurfer,代码行数:8,代码来源:test_viz.py


示例6: test_data

def test_data():
    """Test plotting of data
    """
    mlab.options.backend = 'test'
    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)
开发者ID:joewalter,项目名称:PySurfer,代码行数:9,代码来源:test_viz.py


示例7: make_brain

 def make_brain(subject_id,image_path):
     from surfer import Brain
     hemi = 'lh'
     surface = 'inflated'
     brain = Brain(subject_id, hemi, surface)
     brain.add_overlay(image_path,min=thr)
     outpath = os.path.join(os.getcwd(),os.path.split(image_path)[1]+'_surf.png')
     brain.save_montage(outpath)
     return outpath
开发者ID:INCF,项目名称:BrainImagingPipelines,代码行数:9,代码来源:QA_utils.py


示例8: test_annot

def test_annot():
    """Test plotting of annot
    """
    mlab.options.backend = 'test'
    annots = ['aparc', 'aparc.a2005s']
    borders = [True, False]
    alphas = [1, 0.5]
    brain = Brain(*std_args)
    for a, b, p in zip(annots, borders, alphas):
        brain.add_annotation(a, b, p)
开发者ID:joewalter,项目名称:PySurfer,代码行数:10,代码来源:test_viz.py


示例9: get_hemi_data

def get_hemi_data(subject, hemi, source, surf_name="pial", name=None, sign="abs", min=None, max=None):
    brain = Brain(subject, hemi, surf_name, curv=False)
    hemi = brain._check_hemi(hemi)
    # load data here
    scalar_data, name = brain._read_scalar_data(source, hemi, name=name)
    min, max = brain._get_display_range(scalar_data, min, max, sign)
    if sign not in ["abs", "pos", "neg"]:
        raise ValueError("Overlay sign must be 'abs', 'pos', or 'neg'")
    old = viz.OverlayData(scalar_data, brain.geo[hemi], min, max, sign)
    return old.mlab_data, brain
开发者ID:pelednoam,项目名称:mmvt,代码行数:10,代码来源:show_fmri.py


示例10: curvature_normalization

def curvature_normalization(data_dir, subj, close=True):
    """Normalize the curvature map and plot contour over fsaverage."""
    surf_dir = op.join(data_dir, subj, "surf")
    snap_dir = op.join(data_dir, subj, "snapshots")
    for hemi in ["lh", "rh"]:

        cmd = ["mri_surf2surf",
               "--srcsubject", subj,
               "--trgsubject", "fsaverage",
               "--hemi", hemi,
               "--sval", op.join(surf_dir, "%s.curv" % hemi),
               "--tval", op.join(surf_dir, "%s.curv.fsaverage.mgz" % hemi)]

        sub.check_output(cmd)

        b = Brain("fsaverage", hemi, "inflated",
                  config_opts=dict(background="white",
                                   width=700, height=500))
        curv = nib.load(op.join(surf_dir, "%s.curv.fsaverage.mgz" % hemi))
        curv = (curv.get_data() > 0).squeeze()
        b.add_contour_overlay(curv, min=0, max=1.5, n_contours=2, line_width=4)
        b.contour["colorbar"].visible = False
        for view in ["lat", "med"]:
            b.show_view(view)
            mlab.view(distance=330)
            png = op.join(snap_dir, "%s.surf_warp_%s.png" % (hemi, view))
            b.save_image(png)

        if close:
            b.close()
开发者ID:boydmeredith,项目名称:lyman,代码行数:30,代码来源:anatomy_snapshots.py


示例11: plot_group

def plot_group(hub,num_nodes,hemi='lh'):
    from surfer import Brain, io
    brain = Brain("fsaverage", "%s" %(hemi), "pial",config_opts=dict(background="white"))
    if hub == 'pc' or hub =='wmd':
        image = io.project_volume_data('/home/despo/mb3152/random_nodes/%s/group_%s.nii'%(num_nodes,hub),hemi, subject_id="fsaverage", projsum = 'max', smooth_fwhm = 20)
        brain.add_data(image,colormap = "Reds", colorbar= True)
    else:
        pc_image = io.project_volume_data('/home/despo/mb3152/random_nodes/%s/group_pc.nii'%(num_nodes),hemi, subject_id="fsaverage", projsum = 'max', smooth_fwhm = 20)
        wmd_image = io.project_volume_data('/home/despo/mb3152/random_nodes/%s/group_wmd.nii'%(num_nodes),hemi, subject_id="fsaverage", projsum = 'max', smooth_fwhm = 20) 
        wmd_thresh = np.nanmean(wmd_image[wmd_image>0])
        pc_thresh = np.nanmean(pc_image[pc_image >0])
        #find connetor hub activity
        connector_hub_image = pc_image.copy()
        connector_hub_image[pc_image < pc_thresh] = 0.
        connector_hub_image[wmd_image < wmd_thresh] = 0.
        #find sattelite connector activty
        satellite_image = pc_image.copy()
        satellite_image[pc_image < pc_thresh] = 0.
        satellite_image[wmd_image > wmd_thresh] = 0.
        # find provincial hub activity
        provincial_hub_image = wmd_image.copy()
        provincial_hub_image[pc_image > pc_thresh] = 0.
        provincial_hub_image[wmd_image < wmd_thresh] = 0.

        node_image = pc_image.copy()
        node_image[provincial_hub_image > 0] = 0
        node_image[connector_hub_image > 0] = 0
        node_image[satellite_image > 0] = 0
        node_image[node_image > 0] = 1

        # brain.add_data(node_image,thresh= 0, max = 2, colormap = 'gray',hemi=hemi,smoothing_steps = 0)
        brain.add_data(connector_hub_image,thresh= np.nanmin(pc_image),max=pc_thresh + np.std(pc_image), colormap = 'Reds',hemi=hemi,smoothing_steps = 0)
        brain.add_data(satellite_image,thresh= np.nanmin(pc_image),max=pc_thresh + np.std(pc_image),colormap = 'autumn',hemi=hemi,smoothing_steps = 0)
        brain.add_data(provincial_hub_image,thresh=np.nanmin(wmd_image),max=wmd_thresh +np.std(wmd_image),colormap = 'Blues',hemi=hemi,smoothing_steps = 0)
开发者ID:jrcohen02,项目名称:random_nodes,代码行数:34,代码来源:random_parcellate_avg_multi.py


示例12: test_contour

def test_contour():
    """Test plotting of contour overlay
    """
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    overlay_file = pjoin(data_dir, "lh.sig.nii.gz")
    brain.add_contour_overlay(overlay_file)
    brain.add_contour_overlay(overlay_file, max=20, n_contours=9,
                              line_width=2)
    brain.contour['surface'].actor.property.line_width = 1
    brain.contour['surface'].contour.number_of_contours = 10
开发者ID:joewalter,项目名称:PySurfer,代码行数:11,代码来源:test_viz.py


示例13: test_morphometry

def test_morphometry():
    """Test plotting of morphometry."""
    _set_backend()
    brain = Brain(*std_args)
    brain.add_morphometry("curv")
    brain.add_morphometry("sulc", grayscale=True)
    brain.add_morphometry("thickness")
    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:8,代码来源:test_viz.py


示例14: get_hemi_data

def get_hemi_data(subject, hemi, source, surf_name="pial", name=None, sign="abs", min=None, max=None):
    brain = Brain(subject, hemi, surf_name, curv=False, offscreen=True)
    print("Brain {} verts: {}".format(hemi, brain.geo[hemi].coords.shape[0]))
    hemi = brain._check_hemi(hemi)
    # load data here
    scalar_data, name = brain._read_scalar_data(source, hemi, name=name)
    print("fMRI constrast map vertices: {}".format(len(scalar_data)))
    min, max = brain._get_display_range(scalar_data, min, max, sign)
    if sign not in ["abs", "pos", "neg"]:
        raise ValueError("Overlay sign must be 'abs', 'pos', or 'neg'")
    old = viz.OverlayData(scalar_data, brain.geo[hemi], min, max, sign)
    return old, brain
开发者ID:pelednoam,项目名称:mmvt,代码行数:12,代码来源:spm_to_surf.py


示例15: test_image

def test_image():
    """Test image saving
    """
    mlab.options.backend = 'auto'
    brain = Brain(*std_args, config_opts=small_brain)
    tmp_name = mktemp() + '.png'
    brain.save_image(tmp_name)
    brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
    brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
    brain.screenshot()
开发者ID:joewalter,项目名称:PySurfer,代码行数:10,代码来源:test_viz.py


示例16: test_animate

def test_animate(tmpdir):
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = str(tmpdir.join('test.avi'))
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    pytest.raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
开发者ID:nipy,项目名称:PySurfer,代码行数:11,代码来源:test_viz.py


示例17: test_animate

def test_animate():
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:11,代码来源:test_viz.py


示例18: test_data

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,代码行数:11,代码来源:test_viz.py


示例19: curvature_normalization

def curvature_normalization(data_dir, subj):
    """Normalize the curvature map and plot contour over fsaverage."""
    surf_dir = op.join(data_dir, subj, "surf")
    snap_dir = op.join(data_dir, subj, "snapshots")
    panels = []
    for hemi in ["lh", "rh"]:

        # Load the curv values and apply registration to fsaverage
        curv_fname = op.join(surf_dir, "{}.curv".format(hemi))
        curv_vals = nib.freesurfer.read_morph_data(curv_fname)
        subj_curv_vals = apply_surface_warp(data_dir, subj,
                                            hemi, curv_vals)
        subj_curv_binary = (subj_curv_vals > 0)

        # Load the template curvature
        norm_fname = op.join(data_dir, "fsaverage", "surf",
                             "{}.curv".format(hemi))
        norm_curv_vals = nib.freesurfer.read_morph_data(norm_fname)
        norm_curv_binary = (norm_curv_vals > 0)

        # Compute the curvature overlap image
        curv_overlap = np.zeros_like(norm_curv_binary, np.int)
        curv_overlap[norm_curv_binary & subj_curv_binary] = 1
        curv_overlap[norm_curv_binary ^ subj_curv_binary] = 2

        # Mask out the medial wall
        cortex_fname = op.join(data_dir, "fsaverage", "label",
                               "{}.cortex.label".format(hemi))
        cortex = nib.freesurfer.read_label(cortex_fname)
        medial_wall = ~np.in1d(np.arange(curv_overlap.size), cortex)
        curv_overlap[medial_wall] = 1

        # Plot the curvature overlap image
        try:
            b = Brain("fsaverage", hemi, "inflated", background="white")
        except TypeError:
            # PySurfer <= 0.5
            b = Brain("fsaverage", hemi, "inflated",
                      config_opts=dict(background="white"))

        b.add_data(curv_overlap, min=0, max=2,
                   colormap=[".9", ".45", "indianred"], colorbar=False)

        for view in ["lat", "med", "ven"]:
            b.show_view(view, distance="auto")
            panels.append(crop(b.screenshot()))
        b.close()

    # Make and save a figure
    f = multi_panel_brain_figure(panels)
    fname = op.join(snap_dir, "surface_registration.png")
    f.savefig(fname, bbox_inches="tight")
    plt.close(f)
开发者ID:kellyhennigan,项目名称:lyman,代码行数:53,代码来源:anatomy_snapshots.py


示例20: test_animate

def test_animate():
    """Test animation
    """
    mlab.options.backend = 'auto'
    brain = Brain(*std_args, config_opts=small_brain)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
开发者ID:arokem,项目名称:PySurfer,代码行数:12,代码来源:test_viz.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dj.surl函数代码示例发布时间:2022-05-27
下一篇:
Python surface.Surface类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap