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

from_neo_spiketrain(neo_spiketrain, *[, ...])

Convert a neo.SpikeTrain to an nstat.nspikeTrain.

to_neo_segment(spike_collection)

Convert a nstat.SpikeTrainCollection to a neo.Segment.

to_neo_spiketrain(nst)

Convert an nstat.nspikeTrain to a neo.SpikeTrain.

nstat.extras.interop.neo.to_neo_spiketrain(nst)[source]

Convert an nstat.nspikeTrain to a neo.SpikeTrain.

Parameters:

nst (nspikeTrain) – nstat spike train. nst.spikeTimes is interpreted in seconds (the nstat-wide convention; see CLAUDE.md “Time and units”).

Returns:

Neo spike train with t_start = nst.minTime s, t_stop = nst.maxTime s, and the original name and sampling rate preserved in annotations.

Return type:

neo.SpikeTrain

Notes

Neo requires explicit pq.Quantity units; 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.SpikeTrain to an nstat.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, uses neo_spiketrain.name.

  • sample_rate (float | None) – Override the sampling rate (Hz). If None, uses neo_spiketrain.sampling_rate converted to Hz, or 1000.0 if the source carries no sampling rate.

Return type:

nspikeTrain

nstat.extras.interop.neo.to_neo_segment(spike_collection)[source]

Convert a nstat.SpikeTrainCollection to a neo.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