A Computational toolbox for large scale Calcium Imaging data Analysis. The code implements the CNMF algorithm [1] for simultaneous source extraction and spike inference from large scale calcium imaging movies. Many more features are included (see below). The code is suitable for the analysis of somatic imaging data. Improved implementation for the analysis of dendritic/axonal imaging data will be added in the future.
-
Source extraction
- Separates different sources based on constrained nonnegative matrix factorization (CNMF) [1-2]
- Deals with heavily overlaping and neuropil contaminated movies
- Selection of inferred sources using a pre-trained convolutional neural network classifier
- Component registration across different sessions/days
-
Denoising, deconvolution and spike extraction
-
Handling of very large datasets
-
Motion correction
We moved the code into the Flatiron Institute github account and renamed the repository to CaImAn-MATLAB to bring it more in touch with the CaImAn Python package. Everything else is the same. The old link https://github.com/epnev/ca_source_extraction
redirects here.
If you use this code please cite the corresponding papers where original methods appeared (see References below), as well as:
[1] Giovannucci A., Friedrich J., Gunn P., Kalfon J., Koay S.A., Taxidis J., Najafi F., Gauthier J.L., Zhou P., Tank D.W., Chklovskii D.B., Pnevmatikakis E.A. (2018). CaImAn: An open source tool for scalable Calcium Imaging data Analysis. bioarXiv preprint. [paper]
The following references provide the theoretical background and original code for the included methods.
[1] Pnevmatikakis, E.A., Soudry, D., Gao, Y., Machado, T., Merel, J., ... & Paninski, L. (2016). Simultaneous denoising, deconvolution, and demixing of calcium imaging data. Neuron 89(2):285-299, [paper].
[2] Pnevmatikakis, E.A., Gao, Y., Soudry, D., Pfau, D., Lacefield, C., ... & Paninski, L. (2014). A structured matrix factorization framework for large scale calcium imaging data analysis. arXiv preprint arXiv:1409.2903. [paper].
[3] Friedrich J. and Paninski L. Fast active set methods for online spike inference from calcium imaging. NIPS, 29:1984-1992, 2016. [paper], [Github repository - Python], [Github repository - MATLAB].
[4] Pnevmatikakis, E. A., Merel, J., Pakman, A., & Paninski, L. Bayesian spike inference from calcium imaging data. In Signals, Systems and Computers, 2013 Asilomar Conference on (pp. 349-353). IEEE, 2013. [paper], [Github repository - MATLAB].
[5] Pnevmatikakis, E.A., and Giovannucci A. (2017). NoRMCorre: An online algorithm for piecewise rigid motion correction of calcium imaging data. Journal of Neuroscience Methods, 291:83-92 [paper], [Github repository - MATLAB].
The best way to start is by looking at the various demos.
- demo_script.m: A simple demo with a small dataset included in the repo to display the notation and basic operations
- demo_script_class.m: Replicates the demo_script.m file in a cleaner way using a CNMF object.
- demo_patches.m: A larger demo displaying the process of memory mapping and spliting the field of view in patches to be processed in parallel and then combined.
- demo_patches_class.m: Similar to demo_patches.m but using the CNMF object.
- run_pipeline.m: Demo for the complete pipeline of motion correction, source separation and spike extraction for large datasets. More details about the pipeline can be found here.
- 3D/demo_3D.m: Demo for processing of 3D volumetric imaging data.
A complete analysis Python pipeline including motion correction, source extraction and activity deconvolution is performed through the package CaImAn. This package also includes method for online processing of calcium imaging data and elements of behavioral analysis in head fixed mice.
Check the demo scripts and the wiki to get started.
The following matlab toolboxes are needed for the default parameter settings:
- Statistics and Machine Learning Toolbox
- Image processing toolbox
Depending on the settings the following toolboxes may also be required
- Neural networks toolbox (required for component classifier)
- Signal processing toolbox (recommended but not required)
- Parallel computing toolbox (recommended for large datasets but not required)
- Optimization toolbox (not required)
Depending on the settings the following packages may also be required
- The CVX library which can be downloaded from http://cvxr.com/cvx/download/ (after unpacking CVX open Matlab and run cvx_setup from inside the CVX directory to properly install and add CVX to the Matlab path). CVX is no longer required.
- SPGL1 package from https://github.com/mpf/spgl1 (for solving constrained_foopsi using SPGL1)
This package is mainly developed and maintained by Eftychios A. Pnevmatikakis (Flatiron Institute, Simons Foundation) with help from a lot of contributors.
Special thanks to the following people for letting us use their datasets for our various demo files:
- Weijian Yang, Darcy Peterka, Rafael Yuste, Columbia University
- Sue Ann Koay, David Tank, Princeton University
- Diego Pacheco Pinedo, Mala Murthy, Princeton University
- Clay Lacefied, Randy Bruno, Columbia University
Please use the gitter chat room (use the button above) for questions and comments and create an issue for any bugs you might encounter.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.