nstat.extras.interop.pynapple
pynapple ↔ nstat converters (Tier-B interop).
pynapple (https://github.com/pynapple-org/pynapple) is the modern
systems-neuroscience time-series library — its Ts / Tsd /
TsdFrame containers plus IntervalSet epoch math are exactly the
kind of trial-window operations users repeatedly hand-roll on top of
nstat’s Trial. This module exposes the conversion so users
can keep epoch math in pynapple and do MATLAB-style GLM / point-process
analysis in nstat.
- Install:
pip install nstat-toolbox[pynapple]
Functions
|
Convert a |
|
Convert an |
|
Convert a |
Convert an |
- nstat.extras.interop.pynapple.to_pynapple_ts(nst)[source]
Convert an
nstat.nspikeTrainto apynapple.Ts.The resulting
Tscarries timestamps in seconds (pynapple’s canonical unit, matching nstat’s convention). The pynappleTshas no notion ofminTime/maxTimeoutside its own timestamps, so useto_pynapple_with_support()if you need to preserve nstat’s recording-window bounds.- Parameters:
nst (nspikeTrain) – nstat spike train.
- Return type:
pynapple.Ts
- nstat.extras.interop.pynapple.to_pynapple_with_support(nst)[source]
Convert an
nstat.nspikeTrainplus its recording window.Returns a
(Ts, IntervalSet)pair so the downstream pynapple workflow knows the full recording window — important for tuning curves, perievent histograms, and rate calculations that need to know “how much time was observed” (not just when spikes happened).- Returns:
ts (pynapple.Ts)
support (pynapple.IntervalSet) – Single-interval set
[nst.minTime, nst.maxTime].
- Parameters:
nst (nspikeTrain)
- Return type:
tuple[nap.Ts, nap.IntervalSet]
- nstat.extras.interop.pynapple.from_pynapple_ts(ts, *, name='', sample_rate=1000.0, support=None)[source]
Convert a
pynapple.Tsto annstat.nspikeTrain.- Parameters:
ts (nap.Ts) – pynapple timestamps (seconds).
name (str) – nstat spike-train name.
sample_rate (float) – Recording sample rate in Hz. Default 1000 Hz to match nstat’s default; override to match your acquisition.
support (nap.IntervalSet | None) – Optional pynapple
IntervalSetproviding the recording window. If provided, its[start, end]is used forminTime/maxTime. If absent, the window defaults to the[min, max]of the timestamps (no padding).
- Return type:
- nstat.extras.interop.pynapple.to_pynapple_tsgroup(spike_collection)[source]
Convert a
nstat.SpikeTrainCollectionto apynapple.TsGroup.A pynapple
TsGroupis the natural container for a per-neuron population (the same role nstat’sSpikeTrainCollectionplays).- Parameters:
spike_collection (SpikeTrainCollection)
- Return type:
nap.TsGroup