nstat.HistoryBasis
- class nstat.history.History(windowTimes, minTime=None, maxTime=None, name='History')[source]
Bases:
objectSpike-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]towindowTimes[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]
- 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
Covariateper spike train, each withnumWindowscolumns corresponding to the history windows.- Return type:
- static fromStructure(structure)[source]
Reconstruct a History from a dictionary (inverse of
toStructure()).
- classmethod raisedCosine(K, tMin=None, tMax=None)[source]
Construct a
HistorywithKlog-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:
- Returns:
History object whose
windowTimesis[0, peaks...]withKlog-spaced peaks in[tMin, tMax]. The leading0defines the first window from spike-onset totMin.- Return type:
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
RaisedCosineBasisclass with overloadedcomputeHistory. 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).