CalM: A Self-Supervised Foundation Model for Population Dynamics in Calcium Imaging Data
Organizations: Department of Automation, Tsinghua University, Beijing, China · School of Life Sciences, Tsinghua University, Beijing, China
Abstract
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.
Figures & tables
| Metric: corr | Held in | Held out |
|---|---|---|
| POCO | 0.2781 0.0343 | 0.2568 0.0289 |
| CalM | 0.2783 0.0562 | 0.2592 0.0364 |
| Metric: corr | Held in | Held out |
|---|---|---|
| POCO | 0.1935 0.0670 | 0.1969 0.0468 |
| CalM | 0.1841 0.0898 | 0.1601 0.0757 |
| Metric: | Held in | Held out |
|---|---|---|
| POYO+ | 0.8810 0.0745 | 0.8870 0.0649 |
| CalM | 0.9706 0.0241 | 0.9581 0.0376 |
| Metric: | Held in | Held out |
|---|---|---|
| POYO+ | 0.6922 0.2321 | 0.7394 0.0950 |
| CalM | 0.7065 0.2658 | 0.7443 0.1010 |
| Metric: | Held in | Held out |
|---|---|---|
| POYO+ | 0.4597 0.1469 | 0.4953 0.1145 |
| CalM | 0.5149 0.1378 | 0.5606 0.0807 |
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Subject id | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|
| Number of sessions | 17 | 23 | 31 | 46 | 35 | 42 | 41 | 51 |
| Number of neurons | 17861 | 20592 | 34293 | 40262 | 36621 | 42550 | 45787 | 35804 |
| Mean trial frames | 87 | 105 | 90 | 83 | 90 | 95 | 77 | 104 |
| Region | AM | MM | PM | RSC | V1 | visA |
|---|---|---|---|---|---|---|
| Number of sessions | 42 | 41 | 35 | 55 | 43 | 70 |
| Number of neurons | 42088 | 44520 | 32291 | 51262 | 39619 | 63990 |
| Mean trial length | 90 | 93 | 91 | 90 | 92 | 92 |
| Hyperparameter | Value |
|---|---|
| Hidden size | 128 |
| Layers | 1 |
| Number of heads | 16 |
| Latent tokens | 8 |
| FFN hidden size | 1024 |
| Compression Factor | 8 |
| Hyperparameter | Multi Session | Single session |
|---|---|---|
| Embedding Dimension | 128 | 64 |
| Head Dimension | 64 | 64 |
| Number of Latents | 32 | 32 |
| Latent step | 0.125 | 0.1 |
| Depth | 4 | 4 |
| Number of heads | 8 | 8 |
| Hyperparameter | Value |
| Embedding dimension | 512 |
| Codebook size | 128 |
| Encoder / Decoder layers | 4 |
| Attention heads | 4 |
| Discretization window / overlap | 4 |
| EMA decay | 0.99 |
| Hyperparameter | Value |
|---|---|
| Model dimension | 512 |
| Layers | 6 |
| Attention heads | 8 |
| FFN dimension | 2048 |
| Scheduled sampling probability | 0.6 |
| Scheduled sampling block length | 6 |
| Alpha | NQ Recon | DAT Forecast | POCO Forecast | Mean decoding |
|---|---|---|---|---|
| 0.15 (default) | 0.9561 0.0114 | 0.4600 0.0767 | 0.3328 0.0706 | 0.7499 0.0138 |
| 0.60 | 0.8984 0.0100 | 0.3603 0.0727 | 0.2470 0.0501 | 0.7746 0.0192 |
| 1.00 (w/o smoothing) | 0.8784 0.0213 | 0.3003 0.0769 | 0.2020 0.0450 | 0.7796 0.0258 |
| Metric | baseline | w/o AR loss | w/o gumbel | w/o orthogonal loss |
|---|---|---|---|---|
| AR corr | 0.3424 0.0692 | 0.2968 0.1098 | 0.3148 0.0826 | 0.3124 0.1194 |
| Metric | baseline | w/o scheduled sampling | w/o neighborhood replacement |
|---|---|---|---|
| AR corr | 0.3058 0.1098 | 0.2079 0.1027 | 0.2870 0.1160 |
| Metric (Corr) | Held-in | Held-out |
|---|---|---|
| Train | 0.9479 0.0142 | 0.9486 0.0147 |
| Eval | 0.9473 0.0143 | 0.9479 0.0149 |
| Test | 0.9473 0.0142 | 0.9482 0.0147 |
| Metric (Corr) | Real | Simulation |
|---|---|---|
| iTransformer | 0.0822 0.0383 | 0.1941 0.0996 |
| PatchTST | 0.1918 0.0526 | 0.2563 0.1501 |
| TCN | 0.1854 0.0613 | 0.4077 0.1564 |
| POCO | 0.2901 0.0783 | 0.4688 0.1365 |
| Ours | 0.4025 0.0858 | 0.5207 0.0692 |
| Metric ( ) | Pitch | Roll | Yaw |
|---|---|---|---|
| GLM | 0.6248 0.0864 | 0.5779 0.1190 | 0.5764 0.0650 |
| RRR | 0.6220 0.0912 | 0.5787 0.1195 | 0.5764 0.0649 |
| TCN | 0.6217 0.0948 | 0.6007 0.1145 | 0.6076 0.0762 |
| POYO+ | 0.6077 0.1664 | 0.6066 0.0719 | 0.6711 0.0725 |
| Ours-Linear | 0.7017 0.1017 | 0.6595 0.0875 | 0.5745 0.1391 |
| Ours-Nonlinear | 0.7715 0.0687 | 0.7314 0.1003 | 0.6493 0.0755 |
| Metric (Corr) | Held-in | Held-out |
|---|---|---|
| POCO | 0.3668 0.0605 | 0.3322 0.0511 |
| Ours | 0.3799 0.0978 | 0.3383 0.0860 |
| diff | +0.0131 | +0.0061 |
| p-value | 0.3684 | |
| significance | n.s. |
| Metric ( ) | Held-in pitch | Held-in roll | Held-in yaw | Held-out pitch | Held-out roll | Held-out yaw |
|---|---|---|---|---|---|---|
| POYO+ | 0.7227 0.0840 | 0.6751 0.1132 | 0.5853 0.2321 | 0.7073 0.0611 | 0.6446 0.1299 | 0.5430 0.2240 |
| Ours | 0.7873 0.0737 | 0.7540 0.0883 | 0.7076 0.1691 | 0.7309 0.0785 | 0.6980 0.1200 | 0.6022 0.2172 |
| diff | +0.0647 | +0.0790 | +0.1223 | +0.0236 | +0.0534 | +0.0592 |
| p-value | ||||||
| significance |
| Embeddings | Subject | Brain Region | Layer |
|---|---|---|---|
| Neural | 0.224 0.001 | 0.184 0.001 | 0.621 0.002 |
| Session | 0.930 0.025 | 0.755 0.025 | 1.000 0.000 |
Self-Supervised Pre-Training
Self-supervised pre-training learns transferable representations from unlabeled data to reduce the labels needed for downstream tasks.
See all 247 papers