Improved inference of latent neural states from calcium imaging data

Stephen Keeley, David M. Zoltowski, Adam S. Charles, Jonathan W. PillowbioRxiv 2025

Abstract

Calcium imaging (CI) is a standard method for recording neural population activity, as it enables simultaneous recording of hundreds-to-thousands of individual somatic signals. Accordingly, CI recordings are prime candidates for population-level latent variable analyses, for example using models such as Gaussian Process Factor Analysis (GPFA), hidden Markov models (HMMs), and latent dynamical systems. However, these models have been primarily developed and fine-tuned for electrophysiological measurements of spiking activity. To adapt these models for use with the calcium signals recorded with CI, per-neuron fluorescence time-traces are typically either de-convolved to approximate spiking events or analyzed directly under Gaussian observation assumptions. The former approach, while enabling the direct application of latent variable methods developed for spiking data, suffers from the imprecise nature of spike estimation from CI. Moreover, isolated spikes can be undetectable in the fluorescence signal, creating additional uncertainty. A more direct model linking observed fluorescence to latent variables would account for these sources of uncertainty. Here, we develop accurate and tractable models for characterizing the latent structure of neural population activity from CI data. We propose to augment HMM, GPFA, and dynamical systems models with a CI observation model that consists of latent Poisson spiking and autoregressive calcium dynamics. Importantly, this model is both more flexible and directly compatible with standard methods for fitting latent models of neural dynamics. We demonstrate that using this more accurate CI observation model improves latent variable inference and model fitting on both CI observations generated using state-of-the-art biophysical simulations as well as imaging data recorded in an experimental setting. We expect the developed methods to be widely applicable to many different analysis of population CI data.

Introduction

To understand the neural basis of behavior, neuroscientists seek to identify "latent states"—hidden patterns of population activity representing internal variables like decisions or sensory perceptions. While electrophysiology provides direct spike recordings, modern large-scale recordings often utilize calcium imaging (CI). CI uses fluorescent sensors to monitor calcium influx, offering a high-throughput but indirect measure of neural activity.

The resulting fluorescence signals are slow, noisy, and follow asymmetric distributions. Traditional analysis pipelines typically either deconvolve these signals into estimated spikes—a process prone to error—or apply standard latent variable models (LVMs) under Gaussian noise assumptions, which fail to capture the underlying biophysics. This work introduces a statistical framework that directly links latent brain states to raw fluorescence.

The Calcium LVM Framework

The proposed framework inserts a biophysically inspired "hidden" layer between the latent variables and the observed fluorescence. The generative process follows four key steps:

  1. Latent Variables: Hidden states (e.g., discrete HMM states or continuous factors) evolve over time.
  2. Poisson Spiking: These states determine the instantaneous firing rate of each neuron.
  3. Autoregressive (AR) Dynamics: Spikes trigger a sharp rise and exponential decay in calcium concentration, modeled via AR dynamics.
  4. Observation: The final fluorescence is observed with added Gaussian noise.
Schematic of the Calcium LVM framework, illustrating the transition from latents to firing rates, Poisson spiking, and AR-dynamics.

A critical innovation is the "marginalization" of spike counts. Instead of attempting to estimate exact spike times, the model integrates over all possible spike combinations to calculate the likelihood of the observed fluorescence. This approach maintains robustness against the inherent uncertainty of CI data. The framework is "plug-and-play," compatible with Hidden Markov Models (HMMs), Gaussian Process Factor Analysis (GPFA), and Latent Factor Analysis via Dynamical Systems (LFADS).

Results and Discussion

The framework was validated using synthetic data from the NAOMi biophysical simulator and real-world recordings from the mouse Piriform cortex during odor exposure.

Superior Latent Recovery and Precision

In LFADS benchmarks, the Calcium LVM achieved a latent state reconstruction of $R^2 = 0.77$, more than doubling the performance of standard Gaussian models ($R^2 = 0.37$). In experimental data, the model demonstrated significantly higher log-likelihoods across all test cases.

Furthermore, the Calcium HMM provided superior temporal resolution. In the Piriform cortex, it identified an "odor onset" state that was tightly synchronized with the actual delivery of the stimulus. In contrast, standard Gaussian models exhibited significant lag and lower precision.

Comparison of odor onset detection precision between the Calcium HMM and a standard Gaussian HMM.

Conclusion

By accounting for the physics of calcium decay and the stochasticity of spiking, the Calcium LVM framework provides a more accurate and flexible tool for neural population analysis. While the model currently depends on accurate initial source extraction, future iterations could integrate this observation model directly into the pixel-level processing pipeline. This framework represents a significant step toward more reliable inference of hidden brain states from large-scale imaging data.

Summary updated

BibTeX
@misc{keeley2025improved,
  author = {Stephen Keeley and David M. Zoltowski and Adam S. Charles and Jonathan W. Pillow},
  title = {{Improved inference of latent neural states from calcium imaging data}},
  year = {2025},
  doi = {10.1101/2025.10.17.682993},
  howpublished = {bioRxiv},
}
Figure