Deterministic Temporal Embedding for Calcium Imaging Trace Extraction
Authors: Qi Gao, Julius Beichert, Miriam Ratliff, Karl Rohr
Organizations: Core Facility Platform Mannheim, CF LIMa, Medical Faculty Mannheim, Heidelberg University, Germany · Biomedical Computer Vision Group, BioQuant, IPMB, Heidelberg University, Germany · Department of Neurosurgery, University Hospital Mannheim, Heidelberg University, Germany · Clinical Cooperation Unit Neurooncology, German Cancer Consortium (DKTK), German Cancer Research Center (DKFZ), Germany
Reliable extraction of calcium-dependent fluorescence traces in calcium imaging sequences requires identifying pixels whose fluorescence intensity reflects the same underlying cellular activity. We present a deterministic temporal embedding framework that maps pixel-wise fluorescence traces to a low-dimensional representation in which temporally coherent sources form spatially coherent regions. Starting from a fuzzy-neighborhood graph and spectral initialization, we optimize a class-balanced cross-entropy objective using exact sparse attraction and a deterministic particle-mesh decomposition of the dense repulsive interaction with sparse edge compensation, avoiding stochastic negative sampling. The resulting latent representation is spatially decoded into reliable source supports for trace extraction without imposing an explicit cellular shape prior. Experiments on synthetic and in vivo two-photon calcium imaging data demonstrate robust recovery of irregular and spatially touching sources together with efficient deterministic embedding optimization.
Figures & tables
Figure 1: (Top) Example frames from an in vivo two-photon calcium imaging sequence of glioblastoma cells; (Bottom) 3D temporal embeddings of the entire sequence generated using UMAP and our deterministic particle-mesh (PM) method, with latent coordinates mapped to RGB for visualization.
All cells
Touching cells
Method
F1 ↑
Recall ↑
F1 ↑
Recall ↑
Suite2p [ 2 ]
0.795
0.659
0.836
0.719
CaImAn [ 6 ]
0.952
0.909
0.951
0.906
PM-Euclidean
0.946
1.000
0.985
1.000
PM-Cosine
0.966
0.955
0.952
0.938
PM-Adaptive
0.967
1.000
1.000
1.000
Table 1: Performance for the synthetic dataset.
Figure 2: Results for synthetic data. (a) Maximum projection of the image sequence; (b) ground-truth blinking-cell supports, excluding static distractors; extracted supports from (c) Suite2p [ 2 ] , (d) CaImAn [ 6 ] , and (e) PM-Adaptive; and (f) spatial visualization of the PM-Adaptive embedding. In (b)–(e), different colors denote distinct source supports; in (f), the three latent coordinates are mapped to RGB for visualization.
Figure 3: Results for real calcium imaging data. Filled supports are overlaid on the maximum projection of the image sequence. (a) Top 100 accepted CaImAn components ranked by trace SNR. (b) Top 100 PM-Adaptive supports ranked by the ACF activity feature. (c) Mean fluorescence traces of the top 30 PM-Adaptive supports, with IDs corresponding to those in (b). Traces are vertically offset for visualization.
Two-photon calcium imaging is a standard tool for recording large neural populations in vivo, yet inferring spikes accurately across the growing diversity of calcium indicators remains an open problem. Existing supervised methods achieve reasonable in-domain accuracy but generalize poorly to unseen indicators, because different indicators induce distinct fluorescence kinetics and signal statistics while existing architectures remain relatively simple generic temporal regressors without dynamics-matched inductive bias. We propose SpikeSSL, a universal spike inference framework whose temporal backbone is a bank of bidirectional IIR state-space layers broadly motivated by calcium dynamics. A multi-modal conditioning encoder maps indicator identity, sampling rate, and trace-level signal statistics into a global conditioning vector that modulates the backbone via Adaptive Layer Normalization, while a heteroscedastic variance head provides calibrated per-frame uncertainty. On a benchmark with five fixed evaluation splits built from 33 public ground-truth datasets, SpikeSSL achieves state-of-the-art performance in both in-domain and zero-shot leave-one-indicator-out settings. We also develop a biophysical simulation pipeline capable of generating paired fluorescence-spike traces with systematically varied kinetic parameters, spike statistics, response nonlinearities, baseline drift, and noise. Using this pipeline, we synthesize approximately 11,000 simulated traces. Augmenting training with these data effectively closes the cross-indicator domain gap and improves zero-shot generalization. Code is publicly available at https://github.com/detimage123/SpikeSSL.
Chenghao Yue, Siming Xing, Shuran Liu +2
School of Life Sciences, Tsinghua University, Beijing, China · School of Future Information Innovation, Fudan University, Shanghai, China
While artificial neural networks excel in unsupervised learning of non-sparse structure, classical statistical regression techniques offer better interpretability, in particular when sparseness is enforced by ℓ1 regularization, enabling identification of which factors drive observed dynamics. We investigate how these two types of approaches can be optimally combined, exemplarily considering two-photon calcium imaging data where sparse autoregressive dynamics are to be extracted. We propose embedding a vector autoregressive (VAR) model as an interpretable regression technique into a convolutional autoencoder, which provides dimension reduction for tractable temporal modeling. A skip connection separately addresses non-sparse static spatial information, selectively channeling sparse structure into the ℓ1-regularized VAR. ℓ1-estimation of regression parameters is enabled by differentiating through the piecewise linear solution path. This is contrasted with approaches where the autoencoder does not adapt to the VAR model. Having an embedded statistical model also enables a testing approach for comparing temporal sequences from the same observational unit. Additionally, contribution maps visualize which spatial regions drive the learned dynamics.
Fabian Kabus, Maren Hackenberg, Julia Hindel +6
Institute of Medical Biometry and Statistics (IMBI), Faculty of Medicine and Medical Center, University of Freiburg, Germany · Department of Computer Science, University of Freiburg, Germany · Institute of Physiology I, Faculty of Medicine, University of Freiburg, Germany +2
Recent work suggests that large-scale, multi-animal modeling can significantly improve neural recording analysis. However, for functional calcium traces, existing approaches remain task-specific, limiting transfer across common neuroscience objectives. To address this challenge, we propose CalM, a self-supervised neural foundation model trained solely on neuronal calcium traces and adaptable to multiple downstream tasks, including forecasting and decoding. Our key contribution is a pretraining framework, composed of a high-performance tokenizer mapping single-neuron traces into a shared discrete vocabulary, and a dual-axis autoregressive transformer modeling dependencies along both the neural and the temporal axis. We evaluate CalM on a large-scale, multi-animal, multi-session dataset. On the neural population dynamics forecasting task, CalM achieves competitive performance against strong specialized baselines after pretraining. With a task-specific head, CalM further adapts to the behavior decoding task and achieves superior results compared with supervised decoding models. Moreover, linear analyses of CalM representations reveal interpretable functional structures beyond predictive accuracy. Taken together, we propose a novel and effective self-supervised pretraining paradigm for foundation models based on calcium traces, paving the way for scalable pretraining and broad applications in functional neural analysis. Code is released at https://github.com/TSuXinH/CalM.
Xinhong Xu, Yimeng Zhang, Qichen Qian +1
Department of Automation, Tsinghua University, Beijing, China · School of Life Sciences, Tsinghua University, Beijing, China