本文整理汇总了Python中nilearn.plotting.img_plotting.plot_glass_brain函数的典型用法代码示例。如果您正苦于以下问题:Python plot_glass_brain函数的具体用法?Python plot_glass_brain怎么用?Python plot_glass_brain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot_glass_brain函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_plot_glass_brain_colorbar_having_nans
def test_plot_glass_brain_colorbar_having_nans():
img = _generate_img()
data = img.get_data()
data[6, 5, 2] = np.inf
img = nibabel.Nifti1Image(data, np.eye(4))
plot_glass_brain(img, colorbar=True)
plt.close()
示例2: test_plot_glass_brain
def test_plot_glass_brain():
img = _generate_img()
# test plot_glass_brain with colorbar
plot_glass_brain(img, colorbar=True)
# test plot_glass_brain with negative values
plot_glass_brain(img, colorbar=True, plot_abs=False)
示例3: test_plot_glass_brain
def test_plot_glass_brain():
mp.use('template', warn=False)
import matplotlib.pyplot as plt
plt.switch_backend('template')
img = _generate_img()
# test plot_glass_brain with colorbar
plot_glass_brain(img, colorbar=True)
示例4: test_plot_glass_brain
def test_plot_glass_brain():
img = _generate_img()
# test plot_glass_brain with colorbar
plot_glass_brain(img, colorbar=True)
# test plot_glass_brain with negative values
plot_glass_brain(img, colorbar=True, plot_abs=False)
# Save execution time and memory
plt.close()
示例5: test_plotting_functions_with_cmaps
def test_plotting_functions_with_cmaps():
img = load_mni152_template()
cmaps = ['Paired', 'Set1', 'Set2', 'Set3']
for cmap in cmaps:
plot_roi(img, cmap=cmap, colorbar=True)
plot_stat_map(img, cmap=cmap, colorbar=True)
plot_glass_brain(img, cmap=cmap, colorbar=True)
if LooseVersion(matplotlib.__version__) >= LooseVersion('2.0.0'):
plot_stat_map(img, cmap='viridis', colorbar=True)
plt.close()
示例6: test_plot_stat_map_with_nans
def test_plot_stat_map_with_nans():
img = _generate_img()
data = img.get_data()
data[6, 5, 1] = np.nan
data[1, 5, 2] = np.nan
data[1, 3, 2] = np.nan
data[6, 5, 2] = np.inf
img = nibabel.Nifti1Image(data, mni_affine)
plot_epi(img)
plot_stat_map(img)
plot_glass_brain(img)
示例7: test_plot_noncurrent_axes
def test_plot_noncurrent_axes():
"""Regression test for Issue #450"""
maps_img = nibabel.Nifti1Image(np.random.random((10, 10, 10)), np.eye(4))
fh1 = plt.figure()
fh2 = plt.figure()
ax1 = fh1.add_subplot(1, 1, 1)
assert_equal(plt.gcf(), fh2, "fh2 was the last plot created.")
# Since we gave ax1, the figure should be plotted in fh1.
# Before #451, it was plotted in fh2.
slicer = plot_glass_brain(maps_img, axes=ax1, title='test')
for ax_name, niax in slicer.axes.items():
ax_fh = niax.ax.get_figure()
assert_equal(ax_fh, fh1, 'New axis %s should be in fh1.' % ax_name)
示例8: test_plot_glass_brain_threshold_for_uint8
def test_plot_glass_brain_threshold_for_uint8():
# mask was applied in [-threshold, threshold] which is problematic
# for uint8 data. See https://github.com/nilearn/nilearn/issues/611
# for more details
data = 10 * np.ones((10, 10, 10), dtype="uint8")
# Having a zero minimum value is important to reproduce
# https://github.com/nilearn/nilearn/issues/762
data[0, 0] = 0
affine = np.eye(4)
img = nibabel.Nifti1Image(data, affine)
threshold = np.array(5, dtype="uint8")
display = plot_glass_brain(img, threshold=threshold, display_mode="z", colorbar=True)
# Next two lines retrieve the numpy array from the plot
ax = list(display.axes.values())[0].ax
plotted_array = ax.images[0].get_array()
# Make sure that there is one value masked
assert_equal(plotted_array.mask.sum(), 1)
# Make sure that the value masked is in the corner. Note that the
# axis orientation seem to be flipped, hence (0, 0) -> (-1, 0)
assert_true(plotted_array.mask[-1, 0])
示例9: test_plot_glass_brain
def test_plot_glass_brain():
img = _generate_img()
# test plot_glass_brain with colorbar
plot_glass_brain(img, colorbar=True)
# test plot_glass_brain with negative values
plot_glass_brain(img, colorbar=True, plot_abs=False)
# Save execution time and memory
plt.close()
# smoke-test for hemispheric glass brain
filename = tempfile.mktemp(suffix='.png')
plot_glass_brain(img, output_file=filename, display_mode='lzry')
plt.close()
示例10: test_add_markers_using_plot_glass_brain
def test_add_markers_using_plot_glass_brain():
fig = plot_glass_brain(None)
coords = [(-34, -39, -9)]
fig.add_markers(coords)
fig.close()
示例11: add_brain_schematics
"""The goal of this script is to align the glass brain SVGs on top of the
anatomy. This is only useful for internal purposes especially when the
SVG is modified.
"""
from nilearn import plotting
from nilearn.plotting import img_plotting, glass_brain, show
# plotting anat for coarse alignment
bg_img, _, _, _ = img_plotting._load_anat()
display = img_plotting.plot_glass_brain(bg_img, threshold=0, black_bg=True,
title='anat', alpha=1)
display = img_plotting.plot_glass_brain(bg_img, threshold=0,
title='anat', alpha=1)
# plotting slices for finer alignment
# e.g. parieto-occipital sulcus
def add_brain_schematics(display):
for axes in display.axes.values():
kwargs = {'alpha': 0.5, 'linewidth': 1, 'edgecolor': 'orange'}
object_bounds = glass_brain.plot_brain_schematics(axes.ax,
axes.direction,
**kwargs)
axes.add_object_bounds(object_bounds)
# side
display = plotting.plot_anat(display_mode='x', cut_coords=[-2])
示例12: test_plot_glass_brain
def test_plot_glass_brain():
img = _generate_img()
# test plot_glass_brain with colorbar
plot_glass_brain(img, colorbar=True)
示例13: add_brain_schematics
#!/usr/bin/env python
"""The goal of this script is to align the glass brain SVGs on top of the
anatomy. This is only useful for internal purposes especially when the
SVG is modified.
"""
from nilearn import plotting
from nilearn.plotting import img_plotting, glass_brain, show
if __name__ == '__main__':
# plotting anat for coarse alignment
bg_img, _, _, _ = img_plotting._load_anat()
display = img_plotting.plot_glass_brain(bg_img, threshold=0, black_bg=True,
title='anat', alpha=1)
display = img_plotting.plot_glass_brain(bg_img, threshold=0, black_bg=True,
title='anat', alpha=1,
display_mode='ortho')
display = img_plotting.plot_glass_brain(bg_img, threshold=0,
title='anat', alpha=1)
# checking hemispheres plotting
display = img_plotting.plot_glass_brain(bg_img, threshold=0, black_bg=True,
title='anat', alpha=1,
display_mode='lyrz')
# plotting slices for finer alignment
# e.g. parieto-occipital sulcus
def add_brain_schematics(display):
for axes in display.axes.values():