Skip to content

Commit 8515afa

Browse files
committed
Use different interface for setting LUT (closes #188)
1 parent 69e969b commit 8515afa

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.mailmap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Michael Waskom <[email protected]> mwaskom <[email protected]> Michael Waskom <[email protected]>
1+
Michael Waskom <[email protected]> mwaskom <[email protected]> Michael Waskom <[email protected]> Michael Waskom <[email protected]>

surfer/viz.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, verbose=None):
18111811
if data is not None:
18121812
for surf in data['surfaces']:
18131813
cmap = surf.module_manager.scalar_lut_manager
1814-
cmap.lut.table = table_new
1814+
cmap.load_lut_from_list(table_new / 255.)
18151815
cmap.data_range = np.array([fmin, fmax])
18161816

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

27222723
# apply look up table if given
27232724
if lut is not None:
2724-
surf.module_manager.scalar_lut_manager.lut.table = lut
2725+
lut_manager = surf.module_manager.scalar_lut_manager
2726+
lut_manager.load_lut_from_list(lut / 255.)
27252727

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

27522754
# Set the color table
2753-
surf.module_manager.scalar_lut_manager.lut.table = cmap
2755+
lut_manager = surf.module_manager.scalar_lut_manager
2756+
lut_manager.load_lut_from_list(cmap / 255.)
27542757

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

27742778
def add_morphometry(self, morph_data, colormap, measure,
@@ -2822,7 +2826,8 @@ def add_contour_overlay(self, scalar_data, min=None, max=None,
28222826
surf = mlab.pipeline.contour_surface(thresh, contours=n_contours,
28232827
line_width=line_width)
28242828
if lut is not None:
2825-
surf.module_manager.scalar_lut_manager.lut.table = lut
2829+
lut_manager = surf.module_manager.scalar_lut_manager
2830+
lut_manager.load_lut_from_list(lut / 255.)
28262831

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

0 commit comments

Comments
 (0)