Skip to content

Commit

Permalink
Merge pull request #3380 from alejoe91/reset-times
Browse files Browse the repository at this point in the history
Reset-times: segment must have either time vector or sampling frequency
  • Loading branch information
samuelgarcia authored Sep 10, 2024
2 parents 0503867 + a3fef70 commit 358e0d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,17 @@ def set_times(self, times, segment_index=None, with_warning=True):

def reset_times(self):
"""
Reset times in-memory for all segments that have a time vector.
Reset time information in-memory for all segments that have a time vector.
If the timestamps come from a file, the files won't be modified. but only the in-memory
attributes of the recording objects are deleted.
attributes of the recording objects are deleted. Also `t_start` is set to None and the
segment's sampling frequency is set to the recording's sampling frequency.
"""
for segment_index in range(self.get_num_segments()):
if self.has_time_vector(segment_index):
rs = self._recording_segments[segment_index]
rs.t_start = None
rs.time_vector = None
rs.t_start = None
rs.sampling_frequency = self.sampling_frequency

def sample_index_to_time(self, sample_ind, segment_index=None):
"""
Expand Down
4 changes: 4 additions & 0 deletions src/spikeinterface/core/tests/test_baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ def test_BaseRecording(create_cache_folder):
# reset times
rec.reset_times()
for segm in range(num_seg):
time_info = rec.get_time_info(segment_index=segm)
assert not rec.has_time_vector(segment_index=segm)
assert time_info["t_start"] is None
assert time_info["time_vector"] is None
assert time_info["sampling_frequency"] == rec.sampling_frequency

# test 3d probe
rec_3d = generate_recording(ndim=3, num_channels=30)
Expand Down

0 comments on commit 358e0d3

Please sign in to comment.