nstat.extras.interop.neo
Neo ↔ nstat converters (Tier-B interop, scope: spike trains).
Neo (https://github.com/NeuralEnsemble/python-neo) is the de-facto interchange object for the Elephant / SpikeInterface / Brian2 ecosystem, with readers for Spike2 / NEX / AlphaOmega / Axon / Blackrock / Plexon / TDT formats. Adding these converters lets nstat consume data from any of those file formats without nstat owning a reader.
The bridge is intentionally narrow: we convert spike-train objects only.
Analog signals, events, and segments are left for the user to manage
on the Neo side — nstat’s Trial doesn’t carry the same
hierarchical metadata that Neo’s neo.core.Block /
neo.core.Segment do.
- Install:
pip install nstat-toolbox[neo]
Functions
|
Convert a |
|
Convert a |
|
Convert an |
- nstat.extras.interop.neo.to_neo_spiketrain(nst)[source]
Convert an
nstat.nspikeTrainto aneo.SpikeTrain.- Parameters:
nst (nspikeTrain) – nstat spike train.
nst.spikeTimesis interpreted in seconds (the nstat-wide convention; see CLAUDE.md “Time and units”).- Returns:
Neo spike train with
t_start=nst.minTimes,t_stop=nst.maxTimes, and the original name and sampling rate preserved inannotations.- Return type:
neo.SpikeTrain
Notes
Neo requires explicit
pq.Quantityunits; this converter assumes seconds throughout (matching nstat’s convention).
- nstat.extras.interop.neo.from_neo_spiketrain(neo_spiketrain, *, name=None, sample_rate=None)[source]
Convert a
neo.SpikeTrainto annstat.nspikeTrain.- Parameters:
neo_spiketrain (neo.SpikeTrain) – Source Neo spike train. Must carry time units convertible to seconds (Neo’s default).
name (str | None) – Override the train name. If
None, usesneo_spiketrain.name.sample_rate (float | None) – Override the sampling rate (Hz). If
None, usesneo_spiketrain.sampling_rateconverted to Hz, or 1000.0 if the source carries no sampling rate.
- Return type:
- nstat.extras.interop.neo.to_neo_segment(spike_collection)[source]
Convert a
nstat.SpikeTrainCollectionto aneo.Segment.A Neo Segment groups spike trains that share a common time base — the natural mapping for nstat’s per-trial spike collections.
- Parameters:
spike_collection (SpikeTrainCollection)
- Return type:
neo.Segment