Skip to content

Let callers override fs/t0, and defer to SI's own clock when unset - #57

Open
oliche wants to merge 2 commits into
mainfrom
si-times-fs-t0-override
Open

Let callers override fs/t0, and defer to SI's own clock when unset#57
oliche wants to merge 2 commits into
mainfrom
si-times-fs-t0-override

Conversation

@oliche

@oliche oliche commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a constructor-level fs/t0 override to AbstractDataModel, resolved via get_sampling_frequency()/get_t0() ahead of a per-backend _get_metadata_* hook. SpikeGLXDataModel, LFPackDataModel, and SpikeInterfaceDataModel all take optional fs/t0 kwargs; the GUI threads them from EphysBinViewer/LFPackBinViewer down to every data model constructed when opening a file or switching an lfpack recording.
  • LFPackDataModel gains a real _get_metadata_t0(), reading the sync-corrected LFPackReader.t0 (falling back to zero when there's no sync data) instead of silently treating every lfpack file as starting at zero.
  • Per Joe's review comment on Support spikeinterface times. #54: get_time_from_sample/get_sample_from_time only use the linear t0 + sample/fs model when a caller explicitly overrides fs/t0. Otherwise they defer to _get_metadata_time_from_sample/_get_metadata_sample_from_time, whose default is still linear (correct for SpikeGLX/lfpack) but which SpikeInterfaceDataModel overrides to call sample_index_to_time/time_to_sample_index directly — so a recording with a genuinely non-uniform set_times() vector still reports its true times.

Test plan

  • uv run --with pytest-qt --with pyqt5 python -m pytest src/viewephys/tests/ -q — 61 passed.
  • ruff check / ruff format --diff clean.
  • New tests cover: fs/t0 override on each backend, lfpack t0 sourced from sync metadata vs. defaulting to zero, and a SpikeInterface recording with a non-uniform set_times() vector (constant shift + per-sample ramp) confirming conversion matches SpikeInterface's own functions exactly rather than the linear approximation, and that an explicit override still forces the linear model.

Base automatically changed from si-times to main August 8, 2026 02:37
oliche added 2 commits August 8, 2026 11:00
Adds a constructor-level fs/t0 override to AbstractDataModel, resolved once
in get_sampling_frequency()/get_t0() (marked @Final) ahead of a per-backend
_get_metadata_sampling_frequency()/_get_metadata_t0(). SpikeGLXDataModel,
LFPackDataModel and SpikeInterfaceDataModel all gain fs/t0 kwargs; the GUI
threads them from EphysBinViewer/LFPackBinViewer down to every data model
constructed when opening a file or switching an lfpack recording.

LFPackDataModel also gains a real _get_metadata_t0(), reading the
sync-corrected LFPackReader.t0 (falling back to zero when there's no sync
data, i.e. NaN) instead of silently treating every lfpack file as starting
at zero.
Addresses Joe's PR #54 review comment: the base-class linear t0+sample/fs
model should not silently override a user's own set_times() time vector on a
SpikeInterface recording.

Splits get_time_from_sample/get_sample_from_time so the linear model only
applies when the caller has explicitly overridden fs/t0; otherwise they defer
to a new _get_metadata_time_from_sample/_get_metadata_sample_from_time hook,
whose default is still the linear metadata model (correct for SpikeGLX and
LFPack) but which SpikeInterfaceDataModel overrides to call
sample_index_to_time/time_to_sample_index directly, honoring a genuinely
non-uniform SI clock exactly. An explicit fs/t0 override still forces the
synthetic linear clock, since that's what asking for one means.
@oliche
oliche force-pushed the si-times-fs-t0-override branch from b838ee7 to 2cec7ba Compare August 8, 2026 03:00
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