Exemplo n.º 1
0
def test_animate(tmpdir):
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = str(tmpdir.join('test.avi'))
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    pytest.raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 2
0
def test_animate():
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 3
0
def test_animate(tmpdir):
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = str(tmpdir.join('test.avi'))
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    pytest.raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 4
0
def test_animate():
    """Test animation."""
    _set_backend('auto')
    brain = Brain(*std_args, size=100)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 5
0
def test_animate():
    """Test animation
    """
    mlab.options.backend = 'auto'
    brain = Brain(*std_args, config_opts=small_brain)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 6
0
def test_animate():
    """Test animation
    """
    mlab.options.backend = 'auto'
    brain = Brain(*std_args, config_opts=small_brain)
    brain.add_morphometry('curv')
    tmp_name = mktemp() + '.avi'
    brain.animate(["m"] * 3, n_steps=2)
    brain.animate(['l', 'l'], n_steps=2, fname=tmp_name)
    # can't rotate in axial plane
    assert_raises(ValueError, brain.animate, ['l', 'd'])
    brain.close()
Exemplo n.º 7
0
def visMorph(pathToSurface, overlay, outputPath, hemi):
    '''
    Display anything morphometric
    '''
    # check the overlay
    if (not overlay == 'sulc' and not overlay == 'thickness'
        and not overlay == 'curv'):
        message = ('You specified %s as overlay, this doesn\'t make sense'
                     % (overlay))
        raise Exception(message)

    brain = Brain(pathToSurface, hemi, 'white')
    brain.add_morphometry(overlay)
    brain.save_montage(outputPath, ['l', 'm'], orientation='v')
    brain.close()
Exemplo n.º 8
0
def test_morphometry():
    """Test plotting of morphometry."""
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    brain.add_morphometry("curv")
    brain.add_morphometry("sulc", grayscale=True)
    brain.add_morphometry("thickness")
    brain.close()
Exemplo n.º 9
0
def test_morphometry():
    """Test plotting of morphometry."""
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    brain.add_morphometry("curv")
    brain.add_morphometry("sulc", grayscale=True)
    brain.add_morphometry("thickness")
    brain.close()
Exemplo n.º 10
0
def test_morphometry():
    """Test plotting of morphometry."""
    _set_backend()
    brain = Brain(*std_args)
    brain.add_morphometry("curv")
    brain.add_morphometry("sulc", grayscale=True)
    brain.add_morphometry("thickness")
    brain.close()
Exemplo n.º 11
0
def test_morphometry():
    """Test plotting of morphometry."""
    _set_backend()
    brain = Brain(*std_args)
    brain.add_morphometry("curv")
    brain.add_morphometry("sulc", grayscale=True)
    brain.add_morphometry("thickness")
    brain.close()
Exemplo n.º 12
0
def plot_brains(axes, palette):

    lat_ax, med_ax = axes
    lat_color, med_color = palette

    b = Brain("fsaverage", "lh", "pial",
              background="white", size=(1200, 1200))

    b.add_morphometry("curv", grayscale=True, min=-.5, max=.5,
                      colormap="Greys", colorbar=False)

    b.add_label("roi_labels/lh.ifs.label", alpha=.9, color="#feb308")
    b.add_label("roi_labels/lh.mfc.label", alpha=.9, color="#cf6275")

    mlab.view(160, 70)
    lat_ax.imshow(crop(b.screenshot()), rasterized=True)

    mlab.view(15, 90)
    med_ax.imshow(crop(b.screenshot()),  rasterized=True)

    b.close()

    for ax in axes:
        ax.set_axis_off()
Exemplo n.º 13
0
from surfer._commandline import parser

args = parser.parse_args(sys.argv[1].split())

# Get a dict of config override options
confkeys = ["size", "background", "cortex"]
argdict = args.__dict__
config_opts = dict([(k, v) for k, v in argdict.items() if k in confkeys and v])

# Load  up the figure and underlying brain object
b = Brain(args.subject_id, args.hemi, args.surf, args.curv,
          args.title, config_opts=config_opts)

# Maybe load some morphometry
if args.morphometry is not None:
    b.add_morphometry(args.morphometry)

# Maybe load an overlay
if args.overlay is not None:
    if args.range is not None:
        args.min, args.max = args.range

    b.add_overlay(args.overlay, args.min, args.max, args.sign)

# Maybe load an annot
if args.annotation is not None:
    if not args.borders:
        args.borders = any([args.overlay, args.morphometry])
    b.add_annotation(args.annotation, args.borders)

# Maybe load a label
Exemplo n.º 14
0
brain = Brain("fsaverage", "both", "pial",
              background="dimgray")

if not brain.patch_mode:
    brain.show_view("frontal")

"""
Because the morphometry files generated by
recon-all live in a predicatble location,
all you need to call the add_morphometry
method with is the name of the measure you want.
Here, we'll look at cortical curvatuve values,
and plot them for both hemispheres.
"""
brain.add_morphometry("curv")

"""
Each of the possible values is displayed in an
appropriate full-color map, but you can also
display in grayscale. Here we only plot the
left hemisphere.
"""
brain.add_morphometry("sulc", hemi='lh', grayscale=True)

"""
You can also use a custom colormap and tweak its range.
"""
brain.add_morphometry("thickness",
                      colormap="PuBuGn", min=1, max=4)
Exemplo n.º 15
0
print __doc__

from surfer import Brain

brain = Brain("fsaverage", "both", "pial", views="frontal",
              config_opts=dict(background="dimgray"))

"""
Because the morphometry files generated by
recon-all live in a predicatble location,
all you need to call the add_morphometry
method with is the name of the measure you want.
Here, we'll look at cortical curvatuve values,
and plot them for both hemispheres.
"""
brain.add_morphometry("curv")

"""
Each of the possible values is displayed in an
appropriate full-color map, but you can also
display in grayscale. Here we only plot the
left hemisphere.
"""
brain.add_morphometry("sulc", hemi='lh', grayscale=True)

"""
The Brain object can only hold one morphometry
overlay at a time, so adding a new one removes
any existing overlays.
"""
brain.add_morphometry("thickness")
Exemplo n.º 16
0
from surfer import Brain

print(__doc__)

brain = Brain("fsaverage", "both", "pial", views="frontal",
              background="dimgray")

"""
Because the morphometry files generated by
recon-all live in a predicatble location,
all you need to call the add_morphometry
method with is the name of the measure you want.
Here, we'll look at cortical curvatuve values,
and plot them for both hemispheres.
"""
brain.add_morphometry("curv")

"""
Each of the possible values is displayed in an
appropriate full-color map, but you can also
display in grayscale. Here we only plot the
left hemisphere.
"""
brain.add_morphometry("sulc", hemi='lh', grayscale=True)

"""
You can also use a custom colormap and tweak its range.
"""
brain.add_morphometry("thickness",
                      colormap="PuBuGn", min=1, max=4)
Exemplo n.º 17
0
"""
from os import environ
from os.path import join
import numpy as np
from surfer import Brain
from nibabel.freesurfer import read_label

print(__doc__)

brain = Brain("fsaverage", "lh", "inflated")
"""
Show the morphometry with a continuous grayscale colormap.
"""
brain.add_morphometry("curv",
                      colormap="binary",
                      min=-.8,
                      max=.8,
                      colorbar=False)
"""
The easiest way to label any vertex that could be in the region is with
add_label.
"""
brain.add_label("BA1", color="#A6BDDB")
"""
You can also threshold based on the probability of that region being at each
vertex.
"""
brain.add_label("BA1", color="#2B8CBE", scalar_thresh=.5)
"""
It's also possible to plot just the label boundary, in case you wanted to
overlay the label on an activation plot to asses whether it falls within that
Exemplo n.º 18
0
from surfer import Brain

brain = Brain("fsaverage",
              "both",
              "pial",
              views="frontal",
              config_opts=dict(background="dimgray"))
"""
Because the morphometry files generated by
recon-all live in a predicatble location,
all you need to call the add_morphometry
method with is the name of the measure you want.
Here, we'll look at cortical curvatuve values,
and plot them for both hemispheres.
"""
brain.add_morphometry("curv")
"""
Each of the possible values is displayed in an
appropriate full-color map, but you can also
display in grayscale. Here we only plot the
left hemisphere.
"""
brain.add_morphometry("sulc", hemi='lh', grayscale=True)
"""
The Brain object can only hold one morphometry
overlay at a time, so adding a new one removes
any existing overlays.
"""
brain.add_morphometry("thickness")
Exemplo n.º 19
0
from surfer import Brain

print(__doc__)

brain = Brain("fsaverage", "both", "inflated", views="lateral",
              background="white")
"""
You can also use a custom colormap and tweak its range.
"""

brain.add_morphometry("thickness",
                      colormap="Blues", min=1, max=4,
                      colorbar=False)

brain.save_image('./figures/elements_fig_concept_anatomy.png')

Exemplo n.º 20
0
"""
from os import environ
from os.path import join
import numpy as np
from surfer import Brain
from nibabel.freesurfer import read_label

print(__doc__)

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

"""
Show the morphometry with a continuous grayscale colormap.
"""
brain.add_morphometry("curv", colormap="binary",
                      min=-.8, max=.8, colorbar=False)

"""
The easiest way to label any vertex that could be in the region is with
add_label.
"""
brain.add_label("BA1_exvivo", color="#A6BDDB")

"""
You can also threshold based on the probability of that region being at each
vertex.
"""
brain.add_label("BA1_exvivo", color="#2B8CBE", scalar_thresh=.5)

"""
It's also possible to plot just the label boundary, in case you wanted to