-
Notifications
You must be signed in to change notification settings - Fork 18
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
Segment at negative timestamp breaks #127
base: main
Are you sure you want to change the base?
Conversation
Thanks. If i understand this correctly, this would catch streams where timestamp progression is negative (i.e. sampling rate was negative), not necessarily streams with negative timestamps, right? Because with a simple diff, negative timestamps would work but reversed time wouldn't or glitches wouldn't unless we take the abs as you suggest. Is that would you wanted? Or should we handle glitches, but throw an error for negative time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a refactoring and added tests (see
https://github.com/agricolab/xdf-Python/tree/pr/fix/expose-segments)
to see whether it would cause any breaking changes. Passes the new tests and this implementation additionally works for negative time and glitches, now too
ee1bb8a
to
3d668f1
Compare
* Segment when timestamp intervals exceed threshold (previous behaviour) * Always segment at non-positive timestamp intervals (irrespective of threshold) * Additional tests for non-monotonicity
3d668f1
to
deb4c54
Compare
Exactly, negative time intervals would have been a better way to put it, sorry.
Thank you for the tests, this really helped clarify things. I don't see a problem with handling negative time or negative intervals per se, then it's up to the user to decide what to do with them. However, I now think there might be a better way to do it. So I retract the The strategy I've gone for here is to always segment at a non-positive time interval – regardless of the thresholds (i.e. segments are by definition monotonic). I can't really imagine a use case for non-monotonic segments. But if you think it's a too risky breaking change, perhaps something like |
* Revert to existing dejitter segmentation logic * Handles cases where data is recorded out-of-order
51edcd7
to
8e5a76d
Compare
Another rethink... An underling problem to all the above is data being recorded out-of-order (which I don't think itself is necessarily a problem, just something more likely to happen with busy/WiFi networks etc.). So ensuring the time-series data is sorted prior to synchronisation and dejitter avoids the problem! |
Thanks for the effort and the additonal work. I agree that non-monoticity is clearly indicative of a segmentation. It could stem from network issues, but also from clock resets or a bad implementation of the LSL outlet (some apps use custom timestamps). Now practically e.g Sorting this prior to segmentation could be an option, but i would not make it the default for the following reasons. First, unsorted (i.e. non-monotonic) timestamps would in principle caught as multiple segments, once we catch negative diffs in Second, pyxdf policy is to be hands-off the timeseries. We discussed this a lot during the PR for syncing stamps of different streams. The idea is to be hands-off unless the user explicitly tells pyxdf to manipulate the timeseries (and not just the timestamps). In conclusion, my suggestion would be to catch Additionally, I think that non-monotonic timestamps might be linked to clock resets, so we should be aware that this is issue is also handled by |
When dejittering, also take into account negative timestamps when
determining segment boundaries.