Exemplo n.º 1
0
def test_plot_empty_slice():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_img(img, display_mode='y', threshold=1)
Exemplo n.º 2
0
def test_plot_with_axes_or_figure():
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)
Exemplo n.º 3
0
def test_plot_empty_slice():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_img(img, display_mode='y', threshold=1)
Exemplo n.º 4
0
def test_plot_with_axes_or_figure():
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)
Exemplo n.º 5
0
def test_plot_img_with_auto_cut_coords():
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in "xyz":
        plot_img(img, cut_coords=None, display_mode=display_mode, black_bg=True)
Exemplo n.º 6
0
def test_plot_img_with_auto_cut_coords():
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in 'xyz':
        plot_img(img, cut_coords=None, display_mode=display_mode,
                 black_bg=True)
Exemplo n.º 7
0
def test_plot_empty_slice():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_img(img, display_mode='y', threshold=1)
Exemplo n.º 8
0
def test_plot_with_axes_or_figure():
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)
Exemplo n.º 9
0
def test_plot_empty_slice():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_img(img, display_mode='y', threshold=1)
Exemplo n.º 10
0
def test_plot_with_axes_or_figure():
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)

    # Save execution time and memory
    plt.close()
Exemplo n.º 11
0
def test_plot_with_axes_or_figure():
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)

    # Save execution time and memory
    plt.close()
Exemplo n.º 12
0
def test_plot_img_with_auto_cut_coords():
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in 'xyz':
        plot_img(img,
                 cut_coords=None,
                 display_mode=display_mode,
                 black_bg=True)
Exemplo n.º 13
0
def test_plot_with_axes_or_figure():
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    img = _generate_img()
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)
Exemplo n.º 14
0
def test_plot_with_axes_or_figure(testdata_3d):
    img = testdata_3d['img']
    figure = plt.figure()
    plot_img(img, figure=figure)

    ax = plt.subplot(111)
    plot_img(img, axes=ax)

    # Save execution time and memory
    plt.close()
Exemplo n.º 15
0
def test_plot_img_with_auto_cut_coords(testdata_3d):
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in 'xyz':
        plot_img(img, cut_coords=None, display_mode=display_mode,
                 black_bg=True)

        # Save execution time and memory
        plt.close()
Exemplo n.º 16
0
def test_plot_img_with_auto_cut_coords():
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in 'xyz':
        plot_img(img, cut_coords=None, display_mode=display_mode,
                 black_bg=True)

        # Save execution time and memory
        plt.close()
Exemplo n.º 17
0
def test_plot_img_with_auto_cut_coords():
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for display_mode in 'xyz':
        plot_img(img,
                 cut_coords=None,
                 display_mode=display_mode,
                 black_bg=True)
Exemplo n.º 18
0
def test_display_methods():
    img = _generate_img()

    display = plot_img(img)
    display.add_overlay(img, threshold=0)
    display.add_edges(img, color="c")
    display.add_contours(img, contours=2, linewidth=4, colors=["limegreen", "yellow"])
Exemplo n.º 19
0
def test_display_methods_with_display_mode_tiled():
    img = _generate_img()
    display = plot_img(img, display_mode='tiled')
    display.add_overlay(img, threshold=0)
    display.add_edges(img, color='c')
    display.add_contours(img, contours=2, linewidth=4,
                         colors=['limegreen', 'yellow'])
Exemplo n.º 20
0
def test_plot_img_with_resampling():
    data = _generate_img().get_data()
    affine = np.array([[1.0, -1.0, 0.0, 0.0], [1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
    display.add_contours(img, contours=2, linewidth=4, colors=["limegreen", "yellow"])
    display.add_edges(img, color="c")
Exemplo n.º 21
0
def test_display_methods(testdata_3d):
    img = testdata_3d['img']

    display = plot_img(img)
    display.add_overlay(img, threshold=0)
    display.add_edges(img, color='c')
    display.add_contours(img, contours=2, linewidth=4,
                         colors=['limegreen', 'yellow'])
Exemplo n.º 22
0
def test_plot_img_with_resampling():
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = _generate_img().get_data()
    affine = np.array([[1., -1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 0.],
                       [0., 0., 0., 1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
Exemplo n.º 23
0
def test_plot_img_with_resampling():
    import pylab as pl
    pl.switch_backend('template')
    data = MNI152TEMPLATE.get_data()[:5, :5, :5]
    affine = np.array([[1., -1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 0.],
                       [0., 0., 0., 1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
Exemplo n.º 24
0
def test_plot_img_with_resampling():
    data = _generate_img().get_data()
    affine = np.array([[1., -1.,  0.,  0.],
                       [1.,  1.,  0.,  0.],
                       [0.,  0.,  1.,  0.],
                       [0.,  0.,  0.,  1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
Exemplo n.º 25
0
def test_plot_img_with_resampling():
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    data = _generate_img().get_data()
    affine = np.array([[1., -1.,  0.,  0.],
                       [1.,  1.,  0.,  0.],
                       [0.,  0.,  1.,  0.],
                       [0.,  0.,  0.,  1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
Exemplo n.º 26
0
def test_display_methods():
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    img = _generate_img()

    display = plot_img(img)
    display.add_overlay(img, threshold=0)
    display.add_edges(img, color='c')
    display.add_contours(img, contours=2, linewidth=4,
                         colors=['limegreen', 'yellow'])
Exemplo n.º 27
0
def test_plot_img_with_resampling():
    data = _generate_img().get_data()
    affine = np.array([[1., -1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 0.],
                       [0., 0., 0., 1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
    display.add_contours(img,
                         contours=2,
                         linewidth=4,
                         colors=['limegreen', 'yellow'])
    display.add_edges(img, color='c')
Exemplo n.º 28
0
def test_display_methods():
    mp.use('template', warn=False)
    import matplotlib.pyplot as plt
    plt.switch_backend('template')
    img = _generate_img()

    display = plot_img(img)
    display.add_overlay(img, threshold=0)
    display.add_edges(img, color='c')
    display.add_contours(img,
                         contours=2,
                         linewidth=4,
                         colors=['limegreen', 'yellow'])
Exemplo n.º 29
0
def test_plot_img_empty():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    mp.use('template', warn=False)
    import pylab as pl
    pl.switch_backend('template')
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_anat(img)
    slicer = plot_img(img, display_mode='y', threshold=1)
    slicer.close()
    pl.close('all')
Exemplo n.º 30
0
def test_plot_img_with_resampling():
    data = _generate_img().get_data()
    affine = np.array([[1., -1.,  0.,  0.],
                       [1.,  1.,  0.,  0.],
                       [0.,  0.,  1.,  0.],
                       [0.,  0.,  0.,  1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
    display.add_contours(img, contours=2, linewidth=4,
                         colors=['limegreen', 'yellow'])
    display.add_edges(img, color='c')

    # Save execution time and memory
    plt.close()
Exemplo n.º 31
0
def test_plot_img_with_resampling(testdata_3d):
    data = get_data(testdata_3d['img'])
    affine = np.array([[1., -1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 0.],
                       [0., 0., 0., 1.]])
    img = nibabel.Nifti1Image(data, affine)
    display = plot_img(img)
    display.add_overlay(img)
    display.add_contours(img,
                         contours=2,
                         linewidth=4,
                         colors=['limegreen', 'yellow'])
    display.add_edges(img, color='c')

    # Save execution time and memory
    plt.close()
Exemplo n.º 32
0
def test_plotting_functions_with_display_mode_tiled(testdata_3d):
    img = testdata_3d['img']
    plot_stat_map(img, display_mode='tiled')
    plot_anat(display_mode='tiled')
    plot_img(img, display_mode='tiled')
    plt.close()
Exemplo n.º 33
0
def test_plotting_functions_with_display_mode_tiled():
    img = _generate_img()
    plot_stat_map(img, display_mode='tiled')
    plot_anat(display_mode='tiled')
    plot_img(img, display_mode='tiled')
    plt.close()