Skip to content

Commit

Permalink
Add checks for start/end_frames
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Jun 22, 2024
1 parent 04fef83 commit 048fa78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,12 @@ def get_traces(
segment_index = self._check_segment_index(segment_index)
channel_indices = self.ids_to_indices(channel_ids, prefer_slice=True)
rs = self._recording_segments[segment_index]
start_frame = int(max(0, start_frame)) if start_frame is not None else 0
start_frame = int(start_frame) if start_frame is not None else 0
end_frame = int(min(end_frame, rs.get_num_samples())) if end_frame is not None else rs.get_num_samples()
if start_frame < 0:
raise ValueError("start_frame cannot be negative")
if start_frame > end_frame:
raise ValueError("start_frame cannot be greater than end_frame")
traces = rs.get_traces(start_frame=start_frame, end_frame=end_frame, channel_indices=channel_indices)
if order is not None:
assert order in ["C", "F"]
Expand Down

0 comments on commit 048fa78

Please sign in to comment.