Repository navigation
DAQ system: read raw epochs at 0-based samples, as ingested ones (fix off-by-one) - #348
Merged
Merged
Conversation
ndi_daq_system_mfdaq.readchannels_epochsamples takes 0-based sample positions, as epochtimes2samples and epochsamples2times do in this port (docs/developer_notes/ndi_xlang_principles.md). It passed them unchanged to both readers, but a raw reader's readchannels_epochsamples takes 1-based samples while the ingested reader takes 0-based ones. So a raw epoch read one sample later than the same epoch ingested, and a probe's raw data were one sample off from the times returned with them. The raw path now adds 1. The system and probe docstrings, which called these 1-indexed, and the system's bridge entry are corrected. tests/test_daq_system_sample_indexing.py checks, on the example Intan session, that sample 0 is the first sample, that the raw time channel matches epochsamples2times, and that raw and ingested reads agree; all three fail without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011v7R5rnKYwncJkrNZRXhtw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ndi_daq_system_mfdaq.readchannels_epochsamplesread a raw epoch one sample later than the same epoch ingested.In this port, sample positions are 0-based:
epochtimes2samples,epochsamples2timesand the ingested reader all use them (seedocs/developer_notes/ndi_xlang_principles.md, NDI-python#313). A raw reader'sreadchannels_epochsamples, though, takes 1-based samples, as in MATLAB. The DAQ system passed its numbers to both readers unchanged.For the example Intan session,
readchannels_epochsamples("analog_in", [1], 1, 1, 5):[0, -15.015, -10.92, -30.81, -22.425][-15.015, -10.92, -30.81, -22.425, -12.48]The probe layer is affected too.
ndi_probe_timeseries_mfdaq.readtimeseriesepochturns times into 0-based samples withepochtimes2samples, reads the data through the DAQ system, and computes the returned times withepochsamples2times. On a raw epoch, the data were therefore one sample off from their own time vector. Ingested epochs were right.What
ndi_daq_system_mfdaq.readchannels_epochsamplesadds 1 tos0/s1before calling a raw reader. The ingested path is unchanged.ndi_daq_system_mfdaq.readchannels_epochsamplesandndi_probe_timeseries_mfdaq.read_epochsamples.readchannels_epochsamplesis corrected the same way.The raw readers' own 1-based
readchannels_epochsamplesis not changed: their bridge entries record it, tests pin it, and ingestion depends on it. Only the DAQ system, which callers use, now converts between the two.Testing
tests/test_daq_system_sample_indexing.py, on the example Intan session:epochsamples2times(10..19), the pairing a probe returns;aiandtime, at the start and mid-epoch.mainand pass with the fix.Generated by Claude Code