Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/plot_meg_inverse_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
create Brain object for visualization
"""
brain = Brain(subject_id, hemi, surf, size=(400, 400),
interaction='terrain')
interaction='terrain', cortex='bone')

"""
label for time annotation in milliseconds
Expand Down
26 changes: 19 additions & 7 deletions examples/plot_resting_correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,27 @@
"""
We want to use an appropriate color map for these data: a divergent map that
is centered on 0, which is a meaningful transition-point as it marks the change
from negative correlations to positive correlations.
from negative correlations to positive correlations. By providing the 'center'
argument the add_data function automatically chooses a divergent colormap.
"""
brain.add_data(surf_data_lh, 0, .7, center=0, hemi='lh')
brain.add_data(surf_data_rh, 0, .7, center=0, hemi='rh')

We'll also plot the map with some transparency so that we can see through to
the underlying anatomy.
"""
brain.add_data(surf_data_lh, -.7, .7, colormap="vlag", alpha=.75,
hemi='lh')
brain.add_data(surf_data_rh, -.7, .7, colormap="vlag", alpha=.75,
hemi='rh')
You can tune the data display by shifting the colormap around interesting
regions. For example, you can ignore small correlation up to a magnitude of 0.2
and let colors become gradually less transparent from 0.2 to 0.5 by re-scaling
the colormap as follows. For more information see the help string of this
function.
"""
brain.scale_data_colormap(.2, .5, .7, transparent=True, center=0)

"""
You can also set the overall opacity of the displayed data while maintaining
the transparency of the small values.
"""
brain.scale_data_colormap(0, .35, .7, transparent=True, center=0,
alpha=0.75)

"""
This overlay represents resting-state correlations with a
Expand Down
17 changes: 16 additions & 1 deletion surfer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def mesh_edges(faces):
return edges


def create_color_lut(cmap, n_colors=256):
def create_color_lut(cmap, n_colors=256, center=None):
"""Return a colormap suitable for setting as a Mayavi LUT.

Parameters
Expand All @@ -473,9 +473,16 @@ def create_color_lut(cmap, n_colors=256):
Input colormap definition. This can be the name of a matplotlib
colormap, a list of valid matplotlib colors, or a suitable
mayavi LUT (possibly missing the alpha channel).

if value is "auto", a default sequential or divergent colormap is
returned
n_colors : int, optional
Number of colors in the resulting LUT. This is ignored if cmap
is a 2d array.
center : double, optional
indicates whether desired colormap should be for divergent values,
currently only used to select default colormap for cmap='auto'

Returns
-------
lut : n_colors x 4 integer array
Expand All @@ -493,6 +500,14 @@ def create_color_lut(cmap, n_colors=256):

return lut

# choose default colormaps (REMEMBER to change doc, e.g., in
# Brain.add_data, when changing these defaults)
if isinstance(cmap, string_types) and cmap == "auto":
if center is None:
cmap = "rocket"
else:
cmap = "icefire"

surfer_cmaps = ["rocket", "mako", "icefire", "vlag"]
surfer_cmaps += [name + "_r" for name in surfer_cmaps]

Expand Down
Loading