nstat.HistoryBasis

nstat.HistoryBasis

alias of History

class nstat.history.History(windowTimes, minTime=None, maxTime=None, name='History')[source]

Bases: object

Spike-history basis defined by a set of window boundaries.

Given a vector of N window-times, N − 1 piecewise-constant basis functions are created. Window i spans from windowTimes[i] to windowTimes[i+1].

Parameters:
  • windowTimes (array_like) – Strictly increasing vector of window boundary times (seconds). Must contain at least two entries.

  • minTime (float or None) – Optional lower time bound for the computed history covariate.

  • maxTime (float or None) – Optional upper time bound for the computed history covariate.

  • name (str, default 'History') – Display name.

Examples

>>> h = History([0, 0.001, 0.01, 0.05, 0.1])
>>> h.numWindows
4

See also

TrialConfig, Analysis.computeHistLag

__init__(windowTimes, minTime=None, maxTime=None, name='History')[source]
Parameters:
Return type:

None

property lags: ndarray
property numWindows: int
computeHistory(trains, historyIndex=None, time_grid=None)[source]

Matlab-facing alias for compute_history().

Parameters:

historyIndex (int | None)

setWindow(windowTimes)[source]

Replace the window-times vector.

Parameters:

windowTimes (array_like) – New window boundary times (must be strictly increasing, length ≥ 2).

Return type:

None

plot(*_, handle=None, **__)[source]

Plot each of the history windows as step functions.

Parameters:

handle (Axes or None) – Matplotlib axes to draw into. If None, a new figure is created.

Returns:

The axes or plot handles.

Return type:

Axes or list

toFilter(delta)[source]

Convert the history windows to a discrete-time filter bank.

Parameters:

delta (float) – Sample period (seconds). Must be positive.

Returns:

Bank of FIR filters (one per window) in the z⁻¹ domain.

Return type:

HistoryFilterBank

compute_history(trains, historyIndex=None, time_grid=None)[source]

Compute the history covariate(s) for one or more spike trains.

Parameters:
  • trains (nspikeTrain or nstColl or sequence of nspikeTrain) – Spike train(s) whose history to compute.

  • historyIndex (int or None) – Optional label index appended to the data labels.

  • time_grid (array_like or None) – Optional external time grid. If None, the spike train’s own time grid is used.

Returns:

One Covariate per spike train, each with numWindows columns corresponding to the history windows.

Return type:

CovariateCollection

toStructure()[source]

Serialise the History to a plain dictionary.

Return type:

dict[str, Any]

static fromStructure(structure)[source]

Reconstruct a History from a dictionary (inverse of toStructure()).

Parameters:

structure (dict[str, Any] | None)

Return type:

‘History’ | None

classmethod raisedCosine(K, tMin=None, tMax=None)[source]

Construct a History with K log-spaced windows in [tMin, tMax].

Windowed-basis analog of the Pillow et al. 2008 raised-cosine basis on log time — log-spaced lag scales capture refractory effects at short lags (small bins) and slow adaptation at long lags (large bins).

Parameters:
  • K (int) – Number of history windows (typical: 5–10). Must be >= 2.

  • tMin (float, optional) – Shortest lag in seconds. Default 0.002 (2 ms — absolute refractory edge).

  • tMax (float, optional) – Longest lag in seconds. Default 0.100 (100 ms — typical slow-adaptation horizon).

Returns:

History object whose windowTimes is [0, peaks...] with K log-spaced peaks in [tMin, tMax]. The leading 0 defines the first window from spike-onset to tMin.

Return type:

History

Notes

Returns the WINDOWED-basis approximation of the Pillow 2008 raised-cosine basis. The true Pillow basis is a set of smooth cosine bumps; reproducing those requires a separate RaisedCosineBasis class with overloaded computeHistory. For PP-GLM history-coefficient fitting where the basis is collapsed into bin counts the log-spaced windowed approximation is sufficient.

Mirrors MATLAB History.raisedCosine (History.m:197).