Skip to content

feat: read raw traces through SpikeInterface - #68

Merged
rossant merged 7 commits into
cortex-lab:masterfrom
AllenNeuralDynamics:feat/spikeinterface-reader-sync
Oct 22, 2026
Merged

rossant merged 7 commits into
cortex-lab:masterfrom
AllenNeuralDynamics:feat/spikeinterface-reader-sync

Conversation

@galenlynch

Copy link
Copy Markdown
Contributor

phy can only show traces from a flat binary or mtscomp file, so a SpikeInterface recording has to be exported before phy can display it. This adds a reader that opens the recording through SpikeInterface instead, so dat_path in params.py can point at a SpikeInterface provenance .json (from recording.dump_to_json()) or a saved SpikeInterface .zarr:

dat_path = r'recording.json'

The preprocessing chain is computed lazily, a 0.5 s block at a time with a small LRU cache, which lets phy show remote data without downloading it. Traces are raw and unscaled, like a .dat. The sample rate, channel count and dtype come from the recording, and the reader warns if params.py disagrees.

SpikeInterface is an optional extra (pip install phylib[spikeinterface]) and is imported only when one of these files is opened. Versions 0.100 and later work. I added it to requirements-dev.txt so the new tests run in CI.

I'll follow up with a separate PR that prefetches the next block while scrolling.

Lets phy open any recording SpikeInterface can load, given as a
recording object, a provenance .json or a saved .zarr. A preprocessing
chain over remote raw data can then be viewed without exporting it to a
flat binary file first.

Traces are read in fixed-size blocks with a small LRU cache, since
computing a block of a preprocessed or remote recording is slow and phy
reads overlapping windows. The recording sets the sample rate, channel
count and dtype; values from params.py that disagree are reported,
because phy computes trace windows from params.py. Loading works with
spikeinterface 0.100 onward, where `load` replaced `load_extractor`.
The SpikeInterface reader imports spikeinterface only when used, so it
stays optional for installs, as the `spikeinterface` extra. CI installs
it through requirements-dev.txt so the reader's tests run instead of
being skipped.
@galenlynch galenlynch changed the title Feat/spikeinterface reader sync feat: read raw traces through SpikeInterface Oct 22, 2026
@rossant

rossant commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding this! Direct access through SpikeInterface will be useful, and the reader tests cover a lot.

Could you add an integration test through params.py and TemplateModel, checking that channel mapping and extracted waveform samples match the recording? A relative provenance JSON with a small lazy preprocessing chain would exercise the intended workflow. Please also verify SI 0.100, since that’s the advertised minimum.

Exercise relative provenance paths, lazy preprocessing, channel mapping,\nand waveform samples through params.py and TemplateModel. Add CI coverage\nfor the advertised SpikeInterface 0.100.0 minimum.
Exercise relative provenance paths, lazy preprocessing, channel mapping,
and waveform samples through params.py and TemplateModel. Add CI coverage
for the advertised SpikeInterface 0.100.0 minimum.
@galenlynch

Copy link
Copy Markdown
Contributor Author

Added test_model_spikeinterface_relative_json, which loads params.py through TemplateModel from a different working directory. It uses relative provenance paths and lazy dtype conversion and common referencing, then checks reordered channels and waveform samples against the recording, including padding at both ends.

All nine SpikeInterface tests in this PR pass on 0.100.0 and the current release. A new CI job checks 0.100.0 on Python 3.11.

@rossant

rossant commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for adding this and for the integration and minimum-version coverage! All CI checks passed, and this is now merged.

The phy follow-ups are open:

Both phy PRs link back here and test against the merged phylib revision.

@rossant
rossant merged commit f160796 into cortex-lab:master Oct 22, 2026
8 checks passed
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.

2 participants