From 014168424de30d66f6edfdfda46be0ae9ab3723b Mon Sep 17 00:00:00 2001 From: Jamie Forth Date: Thu, 30 Jan 2025 16:41:54 +0000 Subject: [PATCH] Change effective_srate when dejitter_timestamps=True * This is now the same calculation as when dejitter_timestamps=False --- src/pyxdf/pyxdf.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pyxdf/pyxdf.py b/src/pyxdf/pyxdf.py index 9ca09c9..3540b2a 100644 --- a/src/pyxdf/pyxdf.py +++ b/src/pyxdf/pyxdf.py @@ -665,12 +665,11 @@ def _jitter_removal(streams, threshold_seconds=1, threshold_samples=500): # Recalculate effective_srate if possible counts = (seg_stops + 1) - seg_starts if np.any(counts): - # Calculate range segment duration (assuming last sample duration was - # exactly 1 * stream.tdiff) + # Calculate range segment duration durations = ( - stream.time_stamps[seg_stops] + stream.tdiff - ) - stream.time_stamps[seg_starts] - stream.effective_srate = np.sum(counts) / np.sum(durations) + stream.time_stamps[seg_stops] - stream.time_stamps[seg_starts] + ) + stream.effective_srate = np.sum(counts - 1) / np.sum(durations) srate, effective_srate = stream.srate, stream.effective_srate if np.abs(srate - effective_srate) / srate > 0.1: