Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data starts earlier than chunk #291

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion amstrax/plugins/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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
Expand Down