Skip to content

Commit

Permalink
Merge pull request #189 from mwaskom/fix_lut_update
Browse files Browse the repository at this point in the history
Use different interface for setting LUT
  • Loading branch information
larsoner committed Apr 25, 2017
2 parents 69e969b + 8515afa commit 80f64e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Michael Waskom <mwaskom@stanford.edu> mwaskom <mwaskom@stanford.edu> Michael Waskom <mwaskom@mit.edu>
Michael Waskom <mwaskom@stanford.edu> mwaskom <mwaskom@stanford.edu> Michael Waskom <mwaskom@mit.edu> Michael Waskom <mwaskom@nyu.edu>
19 changes: 12 additions & 7 deletions surfer/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, verbose=None):
if data is not None:
for surf in data['surfaces']:
cmap = surf.module_manager.scalar_lut_manager
cmap.lut.table = table_new
cmap.load_lut_from_list(table_new / 255.)
cmap.data_range = np.array([fmin, fmax])

# Update the data properties
Expand Down Expand Up @@ -2578,7 +2578,8 @@ def __init__(self, subject_id, hemi, surf, figure, geo, geo_curv,
self._geo_surf = mlab.pipeline.surface(
self._geo_mesh, figure=self._f, reset_zoom=True, **geo_kwargs)
if lut is not None:
self._geo_surf.module_manager.scalar_lut_manager.lut.table = lut
lut_manager = self._geo_surf.module_manager.scalar_lut_manager
lut_manager.load_lut_from_list(lut / 255.)
if geo_curv and geo_reverse:
curv_bar = mlab.scalarbar(self._geo_surf)
curv_bar.reverse_lut = True
Expand Down Expand Up @@ -2721,7 +2722,8 @@ def add_data(self, array, mlab_plot, vertices, smooth_mat, min, max,

# apply look up table if given
if lut is not None:
surf.module_manager.scalar_lut_manager.lut.table = lut
lut_manager = surf.module_manager.scalar_lut_manager
lut_manager.load_lut_from_list(lut / 255.)

# Get the original colormap table
orig_ctable = \
Expand Down Expand Up @@ -2750,7 +2752,8 @@ def add_annotation(self, annot, ids, cmap):
surf = mlab.pipeline.surface(mesh, name=annot, figure=self._f)

# Set the color table
surf.module_manager.scalar_lut_manager.lut.table = cmap
lut_manager = surf.module_manager.scalar_lut_manager
lut_manager.load_lut_from_list(cmap / 255.)

# Set the brain attributes
annot = dict(surface=surf, name=annot, colormap=cmap)
Expand All @@ -2767,8 +2770,9 @@ def add_label(self, label, label_name, color, alpha):
with warnings.catch_warnings(record=True):
surf = mlab.pipeline.surface(mesh, name=label_name, figure=self._f)
color = colorConverter.to_rgba(color, alpha)
cmap = np.array([(0, 0, 0, 0,), color]) * 255
surf.module_manager.scalar_lut_manager.lut.table = cmap
cmap = np.array([(0, 0, 0, 0,), color])
lut_manager = surf.module_manager.scalar_lut_manager
lut_manager.load_lut_from_list(cmap)
return surf

def add_morphometry(self, morph_data, colormap, measure,
Expand Down Expand Up @@ -2822,7 +2826,8 @@ def add_contour_overlay(self, scalar_data, min=None, max=None,
surf = mlab.pipeline.contour_surface(thresh, contours=n_contours,
line_width=line_width)
if lut is not None:
surf.module_manager.scalar_lut_manager.lut.table = lut
lut_manager = surf.module_manager.scalar_lut_manager
lut_manager.load_lut_from_list(lut / 255.)

# Set the colorbar and range correctly
with warnings.catch_warnings(record=True): # traits
Expand Down

0 comments on commit 80f64e2

Please sign in to comment.