Commit aac74b4f authored by Michael Waskom's avatar Michael Waskom

ENH increased flexibility in foci colors

parent 5bdd94db
......@@ -33,13 +33,6 @@ coords = [[-36, 18, -3],
[-43, 25, 24],
[-48, 26, -2]]
"""
We can control the color of the sphereoids with
an rgb triplet where values range from 0 to 1.
(They are white by default.)
"""
rgb = (1, .63, .49)
"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
......@@ -50,7 +43,7 @@ While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.
"""
brain.add_foci(coords, map_surface="white", color=rgb)
brain.add_foci(coords, map_surface="white", color="gold")
"""
You can also plot foci with a set of surface vertex ids.
......@@ -77,11 +70,11 @@ You can also control the size of the spheroids.
We'll make these a little bit bigger than our
other foci.
"""
scale_factor = 1.3
scale_factor = 2
"""
Finally, plot the foci using the coords_as_verts option to
center each sphereoid at its vertex id.
"""
brain.add_foci(coords, coords_as_verts=True,
scale_factor=scale_factor, color=(.46, .7, .87))
scale_factor=scale_factor, color="#A52A2A")
......@@ -11,21 +11,32 @@ print __doc__
from surfer import Brain, io
# Bring up the visualization
"""Bring up the visualization"""
brain = Brain("fsaverage", "lh", "inflated",
config_opts=dict(background="white"))
# Project the volume file and return as an array
"""Project the volume file and return as an array"""
mri_file = "auto_examples/data/resting_corr.nii.gz"
reg_file = "auto_examples/data/register.dat"
surf_data = io.project_volume_data(mri_file, "lh", reg_file)
# You can pass this array to the add_overlay method for
# a typical activation overlay (with thresholding, etc.)
"""
You can pass this array to the add_overlay method for
a typical activation overlay (with thresholding, etc.)
"""
brain.add_overlay(surf_data, min=.3, max=.7, name="ang_corr")
# You can also pass it to add_data for more control
# over the visualzation. Here we'll plot the whole
# range of correlations
"""
You can also pass it to add_data for more control
over the visualzation. Here we'll plot the whole
range of correlations
"""
brain.overlays["ang_corr"].remove()
brain.add_data(surf_data, -.7, .7, "jet", alpha=.7)
"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white", scale_factor=2)
......@@ -630,7 +630,7 @@ class Brain(object):
self._f.scene.disable_render = False
def add_foci(self, coords, coords_as_verts=False, map_surface=None,
scale_factor=1, color=(1, 1, 1), name=None):
scale_factor=1, color="white", alpha=1, name=None):
"""Add spherical foci, possibly mapping to displayed surf.
The foci spheres can be displayed at the coordinates given, or
......@@ -649,8 +649,10 @@ class Brain(object):
surface to map coordinates through, or None to use raw coords
scale_factor : int
controls the size of the foci spheres
color : 3-tuple
RGB color code for foci spheres
color : matplotlib color code
HTML name, RBG tuple, or hex code
alpha : float in [0, 1]
opacity of focus gylphs
name : str
internal name to use
......@@ -678,6 +680,9 @@ class Brain(object):
if name is None:
name = "foci_%d" % (len(self.foci) + 1)
# Convert the color code
color = colorConverter.to_rgb(color)
# Create the visualization
self._f.scene.disable_render = True
view = mlab.view()
......@@ -685,8 +690,8 @@ class Brain(object):
foci_coords[:, 1],
foci_coords[:, 2],
np.ones(foci_coords.shape[0]),
scale_factor=(5. * scale_factor),
color=color, name=name)
scale_factor=(6. * scale_factor),
color=color, opacity=alpha, name=name)
self.foci[name] = points
mlab.view(*view)
self._f.scene.disable_render = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment