本文整理汇总了Python中surfer.Brain.add_contour_overlay方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.add_contour_overlay方法的具体用法?Python Brain.add_contour_overlay怎么用?Python Brain.add_contour_overlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surfer.Brain
的用法示例。
在下文中一共展示了Brain.add_contour_overlay方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: curvature_normalization
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [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()
示例2: test_contour
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [as 别名]
def test_contour():
"""Test plotting of contour overlay."""
_set_backend()
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
brain.close()
示例3: Brain
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [as 别名]
brain = Brain("fsaverage", "lh", "inflated",
config_opts={"cortex": "low_contrast",
"background": "#151540"})
"""
Get a path to the overlay file
"""
overlay_file = op.join("example_data", "lh.sig.nii.gz")
"""
Add the contour overlay with the default display settings
Contours overlays only ever use the positive components of
your image, but they get threshold and colormap saturation
from your configuration settings just as normal overlays do.
"""
brain.add_contour_overlay(overlay_file)
"""
The Brain object can only display one contour overlay at a time,
So if we bring up another one, it will remove the original overlay
behind the scenes for us. Here let's specify a different number of
contours and use a different line width.
"""
brain.add_contour_overlay(overlay_file,
max=20,
n_contours=9,
line_width=2)
"""
At the moment, the Brain object itself does not expose an interface
to manipulate what the contour overlay looks like after it has been
示例4: space
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [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")
示例5:
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [as 别名]
brain.add_overlay(surf_data, name=name_overlay, hemi=hemi)
overlay_roi = brain.overlays[name_overlay]
lut = overlay_roi.pos_bar.lut.table.to_array()
# lut = np.zeros((255, 4))
# print lut.shape
lut[0:256, 0:3] = color_list[cpt_color]
# lut[0:255, 0:3] = [255, 255, 0]
lut_alpha = lut
lut_alpha[0:256, 3] = 100 # change opacity for the roi
overlay_roi.pos_bar.lut.table = lut
# Add topographic contours
brain.add_contour_overlay(surf_data,
min=0, max=10,
n_contours=10,
colormap = lut,
line_width=1,
remove_existing=False,
colorbar = False)
# Save in png
#brain.save_imageset(save_png, ['lat'], 'png', colorbar=None)
# Color cpt
cpt_color += 1
# If you just want one roi by one
# Remove for the next roi
# for overlay in brain.overlays_dict[name_overlay]:
# overlay.remove()
示例6: space
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_contour_overlay [as 别名]
This example shows how PySurfer can be used to examine the quality of
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, 0, 1.15, 2, 3, hemi=hemi)
brain.contour_list[-1]["colorbar"].visible = False
brain.show_view("dorsal")