Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset-times: segment must have either time vector or sampling frequency #3380

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading