From 11ce432524129ca432a3f217ec15150c5ba2a5f7 Mon Sep 17 00:00:00 2001 From: Christian Brodbeck Date: Tue, 5 May 2015 20:19:07 -0400 Subject: [PATCH 1/3] ENH movie example: time in ms --- examples/save_movie.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/save_movie.py b/examples/save_movie.py index 0efafc3..d1eb464 100644 --- a/examples/save_movie.py +++ b/examples/save_movie.py @@ -27,8 +27,8 @@ data = stc['data'] times = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin'] brain.add_data(data, colormap='hot', vertices=stc['vertices'], - smoothing_steps=10, time=times, time_label='%0.3f s', - hemi=hemi) + smoothing_steps=10, time=times, hemi=hemi, + time_label=lambda t: '%s ms' % int(round(t * 1e3))) """ scale colormap From a2fe975f05b664f6f0f946df256f09d32dd7f326 Mon Sep 17 00:00:00 2001 From: Christian Brodbeck Date: Tue, 5 May 2015 20:19:33 -0400 Subject: [PATCH 2/3] ENH Brain time-label: constant size --- surfer/viz.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/surfer/viz.py b/surfer/viz.py index ea3b353..a67f093 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -895,8 +895,9 @@ def add_data(self, array, min=None, max=None, thresh=None, bars.append(bar) row, col = np.unravel_index(bi, self.brain_matrix.shape) if array.ndim == 2 and time_label is not None: - self.add_text(0.05, y_txt, time_label(time[0]), - name="time_label", row=row, col=col) + self.add_text(0.95, y_txt, time_label(time[0]), + name="time_label", row=row, col=col, + font_size=14, justification='right') self._toggle_render(True, views) data['surfaces'] = surfs data['colorbars'] = bars @@ -1385,7 +1386,7 @@ def add_contour_overlay(self, source, min=None, max=None, self._toggle_render(True, views) def add_text(self, x, y, text, name, color=None, opacity=1.0, - row=-1, col=-1): + row=-1, col=-1, font_size=None, justification=None): """ Add a text to the visualization Parameters @@ -1412,6 +1413,11 @@ def add_text(self, x, y, text, name, color=None, opacity=1.0, text = self.brain_matrix[row, col].add_text(x, y, text, name, color, opacity) self.texts_dict[name] = dict(row=row, col=col, text=text) + if font_size is not None: + text.property.font_size = font_size + text.actor.text_scale_mode = 'viewport' + if justification is not None: + text.property.justification = justification def update_text(self, text, name, row=-1, col=-1): """Update text label From 188c833caf0cd1b71eafa975469b4931e88bdd56 Mon Sep 17 00:00:00 2001 From: Christian Brodbeck Date: Wed, 6 May 2015 11:32:38 -0400 Subject: [PATCH 3/3] API Brain.add_data(): expose time_label_size --- surfer/viz.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/surfer/viz.py b/surfer/viz.py index a67f093..94d5afb 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -767,7 +767,7 @@ def add_data(self, array, min=None, max=None, thresh=None, colormap="RdBu_r", alpha=1, vertices=None, smoothing_steps=20, time=None, time_label="time index=%d", colorbar=True, - hemi=None, remove_existing=False): + hemi=None, remove_existing=False, time_label_size=14): """Display data from a numpy array on the surface. This provides a similar interface to add_overlay, but it displays @@ -820,6 +820,8 @@ def add_data(self, array, min=None, max=None, thresh=None, remove_existing : bool Remove surface added by previous "add_data" call. Useful for conserving memory when displaying different data in a loop. + time_label_size : int + Font size of the time label (default 14) """ hemi = self._check_hemi(hemi) @@ -897,7 +899,8 @@ def add_data(self, array, min=None, max=None, thresh=None, if array.ndim == 2 and time_label is not None: self.add_text(0.95, y_txt, time_label(time[0]), name="time_label", row=row, col=col, - font_size=14, justification='right') + font_size=time_label_size, + justification='right') self._toggle_render(True, views) data['surfaces'] = surfs data['colorbars'] = bars