nstat.extras.latents.gpfa_bridge
Gaussian-Process Factor Analysis (Yu et al. 2009, J. Neurophysiol.
102(1)) for inferring smooth low-dimensional latent trajectories from
simultaneous spike trains. Bridges
elephant.gpfa.GPFA;
pure Python-only extension, no MATLAB nSTAT counterpart.
Install
pip install nstat-toolbox[latents]
Pulls Elephant (>=1.2) plus Neo and quantities (~50 MB combined).
API
Symbol |
Notes |
|---|---|
|
Fit configuration; frozen dataclass with |
|
Main entry point. Accepts |
|
Frozen dataclass: |
Worked example
Notes
Multi-trial requirement. GPFA’s EM covariance estimation is degenerate on a single trial; the bridge raises
ValueErroriflen(spike_trains) < 2.Axis order. Latent trajectories are returned as
(n_bins, x_dim)— nstat’s(time, feature)convention. Elephant’s native order is(x_dim, n_bins), transposed inside the bridge.Log-likelihood reporting. Elephant evaluates the log-likelihood only every
freq_ll=5iterations; intermediate trace entries areNaN.GPFAResult.log_likelihoodreturns the last finite entry, orNoneif elephant produced no finite value.Seed semantics. Elephant’s GPFA uses module-level numpy random. Passing
seedtofit_gpfatemporarily sets the legacy seed and restores the previous state on exit, so the caller’s RNG context is preserved. This is the sole legacy-np.random.seeduse in nstat — thedefault_rng-only convention applies everywhere else.
References
Yu BM, Cunningham JP, Santhanam G, Ryu SI, Shenoy KV, Sahani M. (2009). Gaussian-process factor analysis for low-dimensional single-trial analysis of neural population activity. J. Neurophysiol. 102(1): 614–635.