Skip to content

Commit f55a940

Browse files
committed
Add 'shift start time' function.
1 parent bbf7daf commit f55a940

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/spikeinterface/core/baserecording.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,26 @@ def reset_times(self):
509509
rs.t_start = None
510510
rs.sampling_frequency = self.sampling_frequency
511511

512+
def shift_start_time(self, shift, segment_index=None):
513+
"""
514+
Shift the starting time of the times.
515+
516+
shift : int | float
517+
The shift to apply to the first time point. If positive,
518+
the current start time will be increased by `shift`. If
519+
negative, the start time will be decreased.
520+
521+
segment_index : int | None
522+
The segment on which to shift the times.
523+
"""
524+
segment_index = self._check_segment_index(segment_index)
525+
rs = self._recording_segments[segment_index]
526+
527+
if self.has_time_vector():
528+
rs.time_vector += shift
529+
else:
530+
rs.t_start += shift
531+
512532
def sample_index_to_time(self, sample_ind, segment_index=None):
513533
"""
514534
Transform sample index into time in seconds

0 commit comments

Comments
 (0)