From bd605aac049ce0280e73aad6f3e685cb35260691 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 25 Oct 2018 14:32:51 -0400 Subject: [PATCH 1/5] FIX: Render tweaks --- surfer/viz.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index cb76a1c..17cfb15 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -229,6 +229,9 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen, for f in figure: f.scene.interactor.interactor_style = \ tvtk.InteractorStyleTerrain() + for figure in figures: + for f in figure: + f.scene.renderer.use_fxaa = True else: if isinstance(figure, int): # use figure with specified id figure = [mlab.figure(figure, size=scene_size)] @@ -387,6 +390,7 @@ class Brain(object): texts : dict The text objects. """ + def __init__(self, subject_id, hemi, surf, title=None, cortex="classic", alpha=1.0, size=800, background="black", foreground=None, figure=None, subjects_dir=None, @@ -2957,6 +2961,7 @@ def _scale_mayavi_lut(lut_table, fmin, fmid, fmax, transparent, class _Hemisphere(object): """Object for visualizing one hemisphere with mlab""" + def __init__(self, subject_id, hemi, figure, geo, geo_curv, geo_kwargs, geo_reverse, subjects_dir, bg_color, backend, fg_color): @@ -3139,7 +3144,7 @@ def _add_vector_data(self, vectors, vector_values, fmin, fmid, fmax, vmax=fmax, figure=self._f, opacity=vector_alpha) # Enable backface culling - quiver.actor.property.backface_culling = False + quiver.actor.property.backface_culling = True quiver.mlab_source.update() # Compute scaling for the glyphs From 3d68d63f4df33499db8bfa9182576af38b488070 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 25 Oct 2018 15:04:52 -0400 Subject: [PATCH 2/5] FIX: Use correct data_dict --- surfer/viz.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/surfer/viz.py b/surfer/viz.py index 17cfb15..305c3ec 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -1186,7 +1186,8 @@ def time_label(x): self._data_dicts[hemi].append(data) - self.scale_data_colormap(min, mid, max, transparent, center, alpha) + self.scale_data_colormap(min, mid, max, transparent, center, alpha, + data) if initial_time_index is not None: self.set_data_time_index(initial_time_index) @@ -1907,7 +1908,7 @@ def _brain_color(self): @verbose def scale_data_colormap(self, fmin, fmid, fmax, transparent, - center=None, alpha=1.0, verbose=None): + center=None, alpha=1.0, data=None, verbose=None): """Scale the data colormap. The colormap may be sequential or divergent. When the colormap is @@ -1946,17 +1947,22 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, center of the (divergent) colormap alpha : float sets the overall opacity of colors, maintains transparent regions + data : dict | None + The data entry for which to scale the colormap. + If None, will use the data dict from either the left or right + hemisphere (in that order). verbose : bool, str, int, or None If not None, override default verbose level (see surfer.verbose). """ divergent = center is not None # Get the original colormap - for h in ['lh', 'rh']: - data = self.data_dict[h] - if data is not None: - table = data["orig_ctable"].copy() - break + if data is None: + for h in ['lh', 'rh']: + data = self.data_dict[h] + if data is not None: + break + table = data["orig_ctable"].copy() lut = _scale_mayavi_lut(table, fmin, fmid, fmax, transparent, center, alpha) From 993c61c94b7d3dca12753022ef0c76d20d736c29 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 26 Oct 2018 07:29:35 -0400 Subject: [PATCH 3/5] FIX: test backend --- surfer/viz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index 305c3ec..a06aa2c 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -231,7 +231,8 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen, tvtk.InteractorStyleTerrain() for figure in figures: for f in figure: - f.scene.renderer.use_fxaa = True + if f.scene.renderer is not None: # i.e., non-test backend + f.scene.renderer.use_fxaa = True else: if isinstance(figure, int): # use figure with specified id figure = [mlab.figure(figure, size=scene_size)] From bab2d7654e3d6c3d6dce6075f6fd0253d1639024 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 26 Oct 2018 07:40:33 -0400 Subject: [PATCH 4/5] FIX: Better check --- surfer/viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index a06aa2c..5dc02a5 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -231,7 +231,7 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen, tvtk.InteractorStyleTerrain() for figure in figures: for f in figure: - if f.scene.renderer is not None: # i.e., non-test backend + if f.scene is not None: # i.e., on a non-testing backend f.scene.renderer.use_fxaa = True else: if isinstance(figure, int): # use figure with specified id From 796cb5f8d414c83a7e9178893c91e1402fee54dd Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 26 Oct 2018 07:56:08 -0400 Subject: [PATCH 5/5] FIX: Old VTK --- surfer/viz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index 5dc02a5..75eab52 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -231,7 +231,8 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen, tvtk.InteractorStyleTerrain() for figure in figures: for f in figure: - if f.scene is not None: # i.e., on a non-testing backend + # on a non-testing backend, and using modern VTK/Mayavi + if hasattr(getattr(f.scene, 'renderer', None), 'use_fxaa'): f.scene.renderer.use_fxaa = True else: if isinstance(figure, int): # use figure with specified id