From 0373c9a99e7f226135958a0324b58eb4f951cb6c Mon Sep 17 00:00:00 2001 From: cfuselli Date: Mon, 11 Dec 2023 16:01:08 +0100 Subject: [PATCH] fix data starts early chunk --- amstrax/plugins/events/events.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/amstrax/plugins/events/events.py b/amstrax/plugins/events/events.py index 251aac67..16e3554a 100644 --- a/amstrax/plugins/events/events.py +++ b/amstrax/plugins/events/events.py @@ -34,7 +34,7 @@ def get_window_size(self): return (2 * self.config['left_event_extension'] + self.config['right_event_extension']) - def compute(self, peaks): + def compute(self, peaks, start, end): le = self.config['left_event_extension'] re = self.config['right_event_extension'] @@ -52,6 +52,12 @@ def compute(self, peaks): left_extension=le, right_extension=re) + # Don't extend beyond the chunk boundaries + # This will often happen for events near the invalid boundary of the + # overlap processing (which should be thrown away) + t0 = np.clip(t0, start, end) + t1 = np.clip(t1, start, end) + result = np.zeros(len(t0), self.dtype) result['time'] = t0 result['endtime'] = t1