Skip to content

Commit 16e5ed2

Browse files
authored
MRG: Fix scale_data_colormap and add FXAA (#261)
* FIX: Render tweaks * FIX: Use correct data_dict * FIX: test backend * FIX: Better check * FIX: Old VTK
1 parent c635dcb commit 16e5ed2

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

surfer/viz.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
229229
for f in figure:
230230
f.scene.interactor.interactor_style = \
231231
tvtk.InteractorStyleTerrain()
232+
for figure in figures:
233+
for f in figure:
234+
# on a non-testing backend, and using modern VTK/Mayavi
235+
if hasattr(getattr(f.scene, 'renderer', None), 'use_fxaa'):
236+
f.scene.renderer.use_fxaa = True
232237
else:
233238
if isinstance(figure, int): # use figure with specified id
234239
figure = [mlab.figure(figure, size=scene_size)]
@@ -387,6 +392,7 @@ class Brain(object):
387392
texts : dict
388393
The text objects.
389394
"""
395+
390396
def __init__(self, subject_id, hemi, surf, title=None,
391397
cortex="classic", alpha=1.0, size=800, background="black",
392398
foreground=None, figure=None, subjects_dir=None,
@@ -1182,7 +1188,8 @@ def time_label(x):
11821188

11831189
self._data_dicts[hemi].append(data)
11841190

1185-
self.scale_data_colormap(min, mid, max, transparent, center, alpha)
1191+
self.scale_data_colormap(min, mid, max, transparent, center, alpha,
1192+
data)
11861193

11871194
if initial_time_index is not None:
11881195
self.set_data_time_index(initial_time_index)
@@ -1903,7 +1910,7 @@ def _brain_color(self):
19031910

19041911
@verbose
19051912
def scale_data_colormap(self, fmin, fmid, fmax, transparent,
1906-
center=None, alpha=1.0, verbose=None):
1913+
center=None, alpha=1.0, data=None, verbose=None):
19071914
"""Scale the data colormap.
19081915
19091916
The colormap may be sequential or divergent. When the colormap is
@@ -1942,17 +1949,22 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent,
19421949
center of the (divergent) colormap
19431950
alpha : float
19441951
sets the overall opacity of colors, maintains transparent regions
1952+
data : dict | None
1953+
The data entry for which to scale the colormap.
1954+
If None, will use the data dict from either the left or right
1955+
hemisphere (in that order).
19451956
verbose : bool, str, int, or None
19461957
If not None, override default verbose level (see surfer.verbose).
19471958
"""
19481959
divergent = center is not None
19491960

19501961
# Get the original colormap
1951-
for h in ['lh', 'rh']:
1952-
data = self.data_dict[h]
1953-
if data is not None:
1954-
table = data["orig_ctable"].copy()
1955-
break
1962+
if data is None:
1963+
for h in ['lh', 'rh']:
1964+
data = self.data_dict[h]
1965+
if data is not None:
1966+
break
1967+
table = data["orig_ctable"].copy()
19561968

19571969
lut = _scale_mayavi_lut(table, fmin, fmid, fmax, transparent,
19581970
center, alpha)
@@ -2957,6 +2969,7 @@ def _scale_mayavi_lut(lut_table, fmin, fmid, fmax, transparent,
29572969

29582970
class _Hemisphere(object):
29592971
"""Object for visualizing one hemisphere with mlab"""
2972+
29602973
def __init__(self, subject_id, hemi, figure, geo, geo_curv,
29612974
geo_kwargs, geo_reverse, subjects_dir, bg_color, backend,
29622975
fg_color):
@@ -3139,7 +3152,7 @@ def _add_vector_data(self, vectors, vector_values, fmin, fmid, fmax,
31393152
vmax=fmax, figure=self._f, opacity=vector_alpha)
31403153

31413154
# Enable backface culling
3142-
quiver.actor.property.backface_culling = False
3155+
quiver.actor.property.backface_culling = True
31433156
quiver.mlab_source.update()
31443157

31453158
# Compute scaling for the glyphs

0 commit comments

Comments
 (0)