本文整理汇总了Python中surfer.Brain.screenshot方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.screenshot方法的具体用法?Python Brain.screenshot怎么用?Python Brain.screenshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surfer.Brain
的用法示例。
在下文中一共展示了Brain.screenshot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_image
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
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()
示例2: test_offscreen
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
def test_offscreen():
"""Test offscreen rendering."""
if sys.platform == 'darwin' and os.getenv('TRAVIS', 'false') == 'true':
raise SkipTest('Offscreen Travis tests fail on OSX')
_set_backend()
brain = Brain(*std_args, offscreen=True)
# Sometimes the first screenshot is rendered with a different
# resolution on OS X
brain.screenshot()
shot = brain.screenshot()
assert_array_equal(shot.shape, (800, 800, 3))
brain.close()
示例3: test_offscreen
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
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))
示例4: test_offscreen
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
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()
示例5: test_image
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
def test_image():
"""Test image saving
"""
tmp_name = mktemp() + '.png'
mlab.options.backend = 'auto'
subject_id, _, surf = std_args
brain = Brain(subject_id, 'both', surf=surf, size=100)
brain.add_overlay(overlay_fname, hemi='lh', min=5, max=20, sign="pos")
brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
brain = Brain(*std_args, size=100)
brain.save_image(tmp_name)
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
brain.save_montage(tmp_name, [['l', 'v'], ['m', 'f']])
brain.screenshot()
brain.close()
示例6: curvature_normalization
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [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)
示例7: contrast_loop
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [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)
示例8: test_image
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [as 别名]
def test_image(tmpdir):
"""Test image saving."""
tmp_name = tmpdir.join('temp.png')
tmp_name = str(tmp_name) # coerce to str to avoid PIL error
_set_backend()
subject_id, _, surf = std_args
brain = Brain(subject_id, 'both', surf=surf, size=100)
brain.add_overlay(overlay_fname, hemi='lh', min=5, max=20, sign="pos")
brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
brain.close()
brain = Brain(*std_args, size=100)
brain.save_image(tmp_name)
brain.save_image(tmp_name, 'rgba', True)
brain.screenshot()
if os.getenv('TRAVIS', '') != 'true':
# for some reason these fail on Travis sometimes
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
brain.save_montage(tmp_name, [['l', 'v'], ['m', 'f']])
brain.close()
示例9: surface_images
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import screenshot [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)