From 30f03b22c3f7e844668f118ae07ed5d85281fa99 Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Mon, 1 Jul 2024 21:08:18 +0100 Subject: [PATCH] Round instead of int for 'time_to_sample_index'. --- src/spikeinterface/core/baserecording.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index 7c43f16c83..734135368b 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -869,8 +869,10 @@ def time_to_sample_index(self, time_s): sample_index = time_s * self.sampling_frequency else: sample_index = (time_s - self.t_start) * self.sampling_frequency + sample_index = round(sample_index) else: sample_index = np.searchsorted(self.time_vector, time_s, side="right") - 1 + return int(sample_index) def get_num_samples(self) -> int: