Skip to content

Commit 0923073

Browse files
ENH Brain.add_data(): argument for initial time index
1 parent 75daf55 commit 0923073

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

surfer/viz.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ def add_data(self, array, min=None, max=None, thresh=None,
802802
colormap="RdBu_r", alpha=1,
803803
vertices=None, smoothing_steps=20, time=None,
804804
time_label="time index=%d", colorbar=True,
805-
hemi=None, remove_existing=False, time_label_size=14):
805+
hemi=None, remove_existing=False, time_label_size=14,
806+
initial_time=None):
806807
"""Display data from a numpy array on the surface.
807808
808809
This provides a similar interface to add_overlay, but it displays
@@ -857,6 +858,8 @@ def add_data(self, array, min=None, max=None, thresh=None,
857858
conserving memory when displaying different data in a loop.
858859
time_label_size : int
859860
Font size of the time label (default 14)
861+
initial_time : float
862+
Time initially shown in the plot.
860863
"""
861864
hemi = self._check_hemi(hemi)
862865

@@ -907,6 +910,12 @@ def add_data(self, array, min=None, max=None, thresh=None,
907910
if not self.n_times == len(time):
908911
raise ValueError('time is not the same length as '
909912
'array.shape[1]')
913+
# initial time
914+
if initial_time is None:
915+
initial_time_index = None
916+
else:
917+
initial_time_index = self.index_for_time(initial_time)
918+
# time label
910919
if isinstance(time_label, string_types):
911920
time_label_fmt = time_label
912921

@@ -919,6 +928,7 @@ def time_label(x):
919928
else:
920929
self._times = None
921930
self.n_times = None
931+
initial_time_index = None
922932

923933
surfs = []
924934
bars = []
@@ -938,6 +948,8 @@ def time_label(x):
938948
name="time_label", row=row, col=col,
939949
font_size=time_label_size,
940950
justification='right')
951+
if initial_time_index is not None:
952+
self.set_data_time_index(initial_time_index)
941953
self._toggle_render(True, views)
942954
data['surfaces'] = surfs
943955
data['colorbars'] = bars

0 commit comments

Comments
 (0)