From a703a996feccf01c070998a59938734be104d230 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 7 Jun 2024 09:45:09 -0600 Subject: [PATCH] drop frame slice inheritance --- src/spikeinterface/core/baserecording.py | 18 +++++++++++++++++- .../core/baserecordingsnippets.py | 5 +---- src/spikeinterface/core/basesnippets.py | 4 +--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index 2fd14062ca..4bc4fedb80 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -657,7 +657,23 @@ def _remove_channels(self, remove_channel_ids): sub_recording = ChannelSliceRecording(self, new_channel_ids) return sub_recording - def _frame_slice(self, start_frame, end_frame): + def frame_slice(self, start_frame: int, end_frame: int) -> BaseRecording: + """ + Returns a new recording with sliced frames. Note that this operation is not in place. + + Parameters + ---------- + start_frame : int + The start frame + end_frame : int + The end frame + + Returns + ------- + BaseRecording + The object with sliced frames + """ + from .frameslicerecording import FrameSliceRecording sub_recording = FrameSliceRecording(self, start_frame=start_frame, end_frame=end_frame) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index 1094e703a2..6118af55a6 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -78,9 +78,6 @@ def _select_channels(self, channel_ids: list | np.array | tuple) -> "BaseRecordi def _channel_slice(self, channel_ids, renamed_channel_ids=None): raise NotImplementedError - def _frame_slice(self, channel_ids, renamed_channel_ids=None): - raise NotImplementedError - def set_probe(self, probe, group_mode="by_probe", in_place=False): """ Attach a list of Probe object to a recording. @@ -513,7 +510,7 @@ def frame_slice(self, start_frame, end_frame): BaseRecordingSnippets The object with sliced frames """ - return self._frame_slice(start_frame, end_frame) + raise NotImplementedError def select_segments(self, segment_indices): """ diff --git a/src/spikeinterface/core/basesnippets.py b/src/spikeinterface/core/basesnippets.py index f96bec3b51..66721c55af 100644 --- a/src/spikeinterface/core/basesnippets.py +++ b/src/spikeinterface/core/basesnippets.py @@ -142,6 +142,7 @@ def _select_channels(self, channel_ids: list | np.array | tuple) -> "BaseSnippet def _channel_slice(self, channel_ids, renamed_channel_ids=None): from .channelslice import ChannelSliceSnippets + import warnings warnings.warn( "Snippets.channel_slice will be removed in version 0.103, use `select_channels` or `rename_channels` instead.", @@ -158,9 +159,6 @@ def _remove_channels(self, remove_channel_ids): sub_recording = ChannelSliceSnippets(self, new_channel_ids) return sub_recording - def _frame_slice(self, start_frame, end_frame): - raise NotImplementedError - def _select_segments(self, segment_indices): from .segmentutils import SelectSegmentSnippets