From a87f34b2b317eddd56da9e24706b750af0702e45 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:39:54 -0500 Subject: [PATCH] Add warning and clip for plot traces --- src/spikeinterface/widgets/traces.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/spikeinterface/widgets/traces.py b/src/spikeinterface/widgets/traces.py index 45ae9c91aa..ae8a02f4a7 100644 --- a/src/spikeinterface/widgets/traces.py +++ b/src/spikeinterface/widgets/traces.py @@ -120,6 +120,12 @@ def __init__( if time_range is None: time_range = (0, 1.0) time_range = np.array(time_range) + if time_range[1] > rec0.get_duration(segment_index=segment_index): + warnings.warn( + "You have selected a time after the end of the segment. The range will be clipped to " + f"{rec0.get_duration(segment_index=segment_index)}" + ) + time_range[1] = rec0.get_duration(segment_index=segment_index) assert mode in ("auto", "line", "map"), 'Mode must be one of "auto","line", "map"' if mode == "auto":