Skip to content

Commit

Permalink
Change effective_srate when dejitter_timestamps=True
Browse files Browse the repository at this point in the history
* This is now the same calculation as when dejitter_timestamps=False
  • Loading branch information
jamieforth committed Jan 31, 2025
1 parent 387e813 commit 1f359c2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pyxdf/pyxdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_stops]
) - stream.time_stamps[seg_starts]
stream.effective_srate = np.sum(counts) / np.sum(durations)
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:
Expand Down

0 comments on commit 1f359c2

Please sign in to comment.