From 3712da0ab5bfe22cf53598dc04c47c37ef554c02 Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Mon, 6 Nov 2023 21:35:01 +0000 Subject: [PATCH 1/3] Handle start / stop frame default `None`. --- src/spikeinterface/sortingcomponents/motion_interpolation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/spikeinterface/sortingcomponents/motion_interpolation.py b/src/spikeinterface/sortingcomponents/motion_interpolation.py index a81212897c..86485aa25d 100644 --- a/src/spikeinterface/sortingcomponents/motion_interpolation.py +++ b/src/spikeinterface/sortingcomponents/motion_interpolation.py @@ -387,6 +387,11 @@ def get_traces(self, start_frame, end_frame, channel_indices): ) # times = np.asarray(self.time_vector[start_frame:end_frame]) else: + if start_frame is None: + start_frame = 0 + if end_frame is None: + end_frame = self.get_num_samples() + times = np.arange((end_frame or self.get_num_samples()) - (start_frame or 0), dtype="float64") times /= self.sampling_frequency t0 = start_frame / self.sampling_frequency From 266be6f2861490bd3e8a3d5e3d3a9c49527f6f50 Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Mon, 6 Nov 2023 21:36:50 +0000 Subject: [PATCH 2/3] Remove redundant `else` statement. --- .../sortingcomponents/motion_interpolation.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/spikeinterface/sortingcomponents/motion_interpolation.py b/src/spikeinterface/sortingcomponents/motion_interpolation.py index 86485aa25d..ba046db85f 100644 --- a/src/spikeinterface/sortingcomponents/motion_interpolation.py +++ b/src/spikeinterface/sortingcomponents/motion_interpolation.py @@ -386,18 +386,18 @@ def get_traces(self, start_frame, end_frame, channel_indices): "time_vector for InterpolateMotionRecording do not work because temporal_bins start from 0" ) # times = np.asarray(self.time_vector[start_frame:end_frame]) - else: - if start_frame is None: - start_frame = 0 - if end_frame is None: - end_frame = self.get_num_samples() - - times = np.arange((end_frame or self.get_num_samples()) - (start_frame or 0), dtype="float64") - times /= self.sampling_frequency - t0 = start_frame / self.sampling_frequency - # if self.t_start is not None: - # t0 = t0 + self.t_start - times += t0 + + if start_frame is None: + start_frame = 0 + if end_frame is None: + end_frame = self.get_num_samples() + + times = np.arange((end_frame or self.get_num_samples()) - (start_frame or 0), dtype="float64") + times /= self.sampling_frequency + t0 = start_frame / self.sampling_frequency + # if self.t_start is not None: + # t0 = t0 + self.t_start + times += t0 traces = self.parent_recording_segment.get_traces(start_frame, end_frame, channel_indices=slice(None)) From dcce25a397e7b365a1bd0de22032b32d48128a4c Mon Sep 17 00:00:00 2001 From: Joe Ziminski <55797454+JoeZiminski@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:48:16 +0000 Subject: [PATCH 3/3] Update src/spikeinterface/sortingcomponents/motion_interpolation.py Co-authored-by: Alessio Buccino --- src/spikeinterface/sortingcomponents/motion_interpolation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/sortingcomponents/motion_interpolation.py b/src/spikeinterface/sortingcomponents/motion_interpolation.py index ba046db85f..93a8ce62c8 100644 --- a/src/spikeinterface/sortingcomponents/motion_interpolation.py +++ b/src/spikeinterface/sortingcomponents/motion_interpolation.py @@ -392,7 +392,7 @@ def get_traces(self, start_frame, end_frame, channel_indices): if end_frame is None: end_frame = self.get_num_samples() - times = np.arange((end_frame or self.get_num_samples()) - (start_frame or 0), dtype="float64") + times = np.arange(end_frame - start_frame, dtype="float64") times /= self.sampling_frequency t0 = start_frame / self.sampling_frequency # if self.t_start is not None: