Skip to content

Outlet: stamp a regular-rate chunk with its last sample's time - #56

Merged
cboulay merged 1 commit into
mainfrom
fix/outlet-last-sample-timestamp
Nov 24, 2026
Merged

cboulay merged 1 commit into
mainfrom
fix/outlet-last-sample-timestamp

Conversation

@cboulay

@cboulay cboulay commented Nov 20, 2026

Copy link
Copy Markdown
Member

OutletProcessor._process stamps a regular-rate chunk with message.axes[dim].value(dat.shape[0]). That is the time one period after the chunk's last sample. pylsl.StreamOutlet.push_chunk reads a scalar timestamp as the capture time of the most recent sample and derives the earlier samples from the nominal rate. As a result, every pushed sample was stamped one sample period late: about 33 µs at 30 kHz, but 10 ms for a 100 Hz stream such as binned features or decoder outputs.

The fix passes value(n - 1), the last sample's own time, so sample i is stamped with axis.value(i).

  • Irregular-rate streams (per-sample data timestamps) are unchanged.
  • String streams already passed per-sample stamps and are unchanged.
  • test_outlet_non_time_stream_dim asserted the old value; it now expects value(n - 1).
  • A new test, test_outlet_stamps_chunk_with_last_sample_time, pins the behaviour.

Behaviour change: LSL timestamps from regular-rate outlets move one sample period earlier. Anything that compared them against the old stamps, including recordings or latency measurements, will see that shift.

Tests: uv run pytest tests gives 115 passed. The ruff and ruff-format pre-commit hooks pass.

pylsl's push_chunk reads a scalar timestamp as the capture time of the most
recent sample and derives the others backwards from the nominal rate. The
outlet passed axis.value(n), the time one period after the last sample, so
every pushed sample was stamped one sample period late.
@cboulay
cboulay merged commit b5b200b into main Nov 24, 2026
14 checks passed
@cboulay
cboulay deleted the fix/outlet-last-sample-timestamp branch November 24, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant