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


Python Brain.show_view方法代码示例

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


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

示例1: drawROI

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def drawROI():
	for hemi in ["lh"]:
		# load data
		roivol = io.project_volume_data(roifile,
						             hemi,
						             subject_id=surfsubj,
						             smooth_fwhm=4.0,
						             projmeth="dist",
						             projsum="avg",
						             projarg=[0,6,0.1],
						             surf="white")
		# create label
		roivol = abs(roivol)
		roivol[roivol < 0.33] = 0
		#if max(roivol) < 1:
		#	brain.close()
		#	continue
		#else:
		write_label(np.asarray(np.nonzero(roivol)),"/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label")

		# load brain
		my_fig = mlab.figure(figure="new_fig1", size=(800,800))
		brain = Brain("fsaverage",hemi,"inflated",curv=True,size=[800,800],background="white",cortex=(("gist_yarg",-1.5,3.5,False)),figure=my_fig)
		set_mylights(my_fig,lights[hemi])

		#add label
		brain.add_label("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label",borders=False,color="#ffff00",alpha=1)
		brain.add_label("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label",borders=1,color="black",alpha=0.5)

		brain.show_view('lat')
		brain.save_image("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.tiff")
		brain.close()
开发者ID:zhenghanQ,项目名称:bps,代码行数:34,代码来源:plot_roi.py

示例2: curvature_normalization

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
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,代码行数:32,代码来源:anatomy_snapshots.py

示例3: vizify

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
 def vizify(self):
     for hemi in self.hemis:
         print "visualize %s" % hemi
         
         # Bring up the beauty (the underlay)
         brain = Brain(self.subject_id, hemi, self.surf, \
                       config_opts=self.config_opts, \
                       subjects_dir=self.subjects_dir)
         
         surf_data = io.read_scalar_data(self.overlay_surf[hemi])
         if (sum(abs(surf_data)) > 0):
             # Overlay another hopeful beauty (functional overlay)
             brain.add_overlay(self.overlay_surf[hemi], name=self.overlay_name, 
                               min=self.min, max=self.max, sign=self.sign)
         
             # Update colorbar
             #brain.overlays[self.overlay_name].pos_bar.lut_mode = self.colorbar
             tmp = brain.overlays[self.overlay_name]
             lut = tmp.pos_bar.lut.table.to_array()
             lut[:,0:3] = self.colorbar
             tmp.pos_bar.lut.table = lut
         
             # Refresh
             brain.show_view("lat")
             brain.hide_colorbar()
         
         # Save the beauts
         brain.save_imageset("%s_%s" % (self.outprefix, hemi), self.views, 
                             'jpg', colorbar=None)
         
         # End a great journey, till another life
         brain.close()
     return
开发者ID:czarrar,项目名称:cwas-paper,代码行数:35,代码来源:surfwrap.py

示例4: test_label

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

示例5: main

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
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,代码行数:10,代码来源:simple_pysurfer.py

示例6: curvature_normalization

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
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,代码行数:55,代码来源:anatomy_snapshots.py

示例7: contrast_loop

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def contrast_loop(subj, contrasts, stat_temp, mask_temp, png_temp,
                  args, z_thresh, sign):
    """Iterate over contrasts and make surface images."""
    for contrast in contrasts:

        # Calculate where the overlay should saturate
        z_max = calculate_sat_point(stat_temp, contrast, sign, subj)
        panels = []
        for hemi in ["lh", "rh"]:

            # Initialize the brain object
            b_subj = subj if args.regspace == "epi" else "fsaverage"

            try:
                b = Brain(b_subj, hemi, args.geometry, background="white")
            except TypeError:
                # PySurfer <= v0.5
                b = Brain(b_subj, hemi, args.geometry,
                          config_opts={"background": "white"})

            # Plot the mask
            mask_file = mask_temp.format(contrast=contrast,
                                         hemi=hemi, subj=subj)
            add_mask_overlay(b, mask_file)

            # Plot the overlay
            stat_file = stat_temp.format(contrast=contrast,
                                         hemi=hemi, subj=subj)
            add_stat_overlay(b, stat_file, z_thresh, z_max, sign,
                             sig_to_z=args.regspace == "fsaverage")

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

        # Make a single figure with all the panels
        f = multi_panel_brain_figure(panels)
        kwargs = {}
        if sign in ["pos", "abs"]:
            kwargs["pos_cmap"] = "Reds_r"
        if sign in ["neg", "abs"]:
            kwargs["neg_cmap"] = "Blues"
        add_colorbars(f, z_thresh, z_max, **kwargs)

        # Save the figure in both hemisphere outputs
        for hemi in ["lh", "rh"]:
            png_file = png_temp.format(hemi=hemi, contrast=contrast, subj=subj)
            f.savefig(png_file, bbox_inches="tight")
        plt.close(f)
开发者ID:kellyhennigan,项目名称:lyman,代码行数:54,代码来源:surface_snapshots.py

示例8: inflated_surfaces

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def inflated_surfaces(out_dir, subj, close=True):
    """Native inflated surfaces with cortical label."""
    for hemi in ["lh", "rh"]:
        b = Brain(subj, hemi, "inflated", curv=False,
                  config_opts=dict(background="white",
                                   width=800, height=500))
        b.add_label("cortex", color="#6B6B6B")

        for view in ["lat", "med"]:
            b.show_view(view)
            mlab.view(distance=400)
            png = op.join(out_dir, "%s.surface_%s.png" % (hemi, view))
            b.save_image(png)
        if close:
            b.close()
开发者ID:boydmeredith,项目名称:lyman,代码行数:17,代码来源:anatomy_snapshots.py

示例9: test_label

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

示例10: surface_images

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def surface_images(out_dir, subj):
    """Plot the white, pial, and inflated surfaces to look for defects."""
    for surf in ["white", "pial", "inflated"]:
        panels = []
        for hemi in ["lh", "rh"]:

            try:
                b = Brain(subj, hemi, surf, curv=False, background="white")
            except TypeError:
                # PySurfer <= 0.5
                b = Brain(subj, hemi, surf, curv=False,
                          config_opts=dict(background="white"))

            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(out_dir, "{}_surface.png".format(surf))
        f.savefig(fname, bbox_inches="tight")
        plt.close(f)
开发者ID:kellyhennigan,项目名称:lyman,代码行数:25,代码来源:anatomy_snapshots.py

示例11:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
"""
Now we plot the focus on the inflated surface at the vertex identified in the
previous step.
"""
brain.add_foci([coord], map_surface="white", color="mediumseagreen")

"""
We can also do this using a vertex index, perhaps defined as the peak
activation in a surface analysis. This will be more accurate than using a
volume-based focus.
"""
coord = 0

utils.coord_to_label(subject_id, coord, label='example_data/coord',
                     hemi='lh', n_steps=40, map_surface="white",
                     coord_as_vert=True)
brain.add_label('example_data/coord-lh.label', color='royalblue', alpha=.8)

"""
Now we plot the foci on the inflated surface. We will map the foci onto the
surface by finding the vertex on the "white" mesh that is closest to the
coordinate of the point we want to display.
"""
brain.add_foci([coord], map_surface="white", coords_as_verts=True,
               color="mediumblue")

"""
Set the camera position to show the extent of the labels.
"""
brain.show_view(dict(elevation=40, distance=0.430))
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:32,代码来源:plot_label_foci.py

示例12: space

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
Freesurfer's curvature-driven normalization to a common template.

We are going to plot the contour of the subject's curvature estimate after
transforming that map into the common space (this step is performed outside
of PySurfer using the Freesurfer program ``mri_surf2surf``).

With a perfect transformation, the contour lines should follow the light/dark
gray boundary on the fsaverage surface. Large deviations may reflect problems
with the underlying data that you should investigate.

"""
import nibabel as nib
from surfer import Brain

brain = Brain("fsaverage", "both", "inflated")

for hemi in ["lh", "rh"]:

    # This file was created with mri_surf2surf
    curv = nib.load("example_data/%s.curv.fsaverage.mgz" % hemi)

    # Binarize the curvature at 0
    curv_bin = (curv.get_data() > 0).squeeze()

    # Add the data as a contour overlay, but turn off the colorbar
    brain.add_contour_overlay(curv_bin, min=0, max=1.5, n_contours=2,
                              line_width=3, hemi=hemi)
    brain.contour_list[-1]["colorbar"].visible = False

brain.show_view("dorsal")
开发者ID:jwdegee,项目名称:PySurfer,代码行数:32,代码来源:plot_freesurfer_normalization.py

示例13: visOverlay

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def visOverlay(pathToSurface, overlay, outputPath, hemi, type='white'):
    brain = Brain(pathToSurface, hemi, type)
    brain.add_overlay(overlay, -1, 1)
    brain.show_view('lateral')
    brain.save_imageset(outputPath, ['med', 'lat'], 'png')
    brain.close()
开发者ID:NeuroanatomyAndConnectivity,项目名称:surfaceProcessing,代码行数:8,代码来源:visops.py

示例14: test_views

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
def test_views():
    """Test showing different views
    """
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    brain.show_view('lateral')
    brain.show_view('m')
    brain.show_view('rostral')
    brain.show_view('caudal')
    brain.show_view('ve')
    brain.show_view('frontal')
    brain.show_view('par')
    brain.show_view('dor')
    brain.show_view({'distance': 432})
    brain.show_view({'azimuth': 135, 'elevation': 79}, roll=107)
    brain.close()
开发者ID:bpinsard,项目名称:PySurfer,代码行数:18,代码来源:test_viz.py

示例15:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import show_view [as 别名]
# If the label lives in the normal place in the subjects directory,
# you can plot it by just using the name
brain.add_label("BA1")

# Some labels have an associated scalar value at each ID in the label.
# For example, they may be probabilistically defined. You can threshold
# what vertices show up in the label using this scalar data
brain.add_label("BA1", color="blue", scalar_thresh=.5)

# Or you can give a path to a label in an arbitrary location
subj_dir = os.environ["SUBJECTS_DIR"]
label_file = os.path.join(subj_dir, subject_id,
                          "label", "%s.MT.label" % hemi)
brain.add_label(label_file)

# By default the label is 'filled-in', but you can
# plot just the label boundaries
brain.add_label("BA44", borders=True)

# You can also control the opacity of the label color
brain.add_label("BA6", alpha=.7)

# Finally, you can plot the label in any color you want.
brain.show_view(dict(azimuth=-42, elevation=105, distance=225,
                     focalpoint=[-30, -20, 15]))

# Use any valid matplotlib color.
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)
开发者ID:aestrivex,项目名称:PySurfer,代码行数:32,代码来源:plot_label.py


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