Skip to content
Switch branches/tags


Constrained Nonnegative Matrix Factorization for microEndoscopic data. 'E' also suggests 'extension'. It is built on top of CNMF with supports to 1 photon data.


OPTION 1: download the package using this LINK

OPTION 2: (recommended) clone the git repository In this way, you are able to get the latest updates of the package within 1-line command or 1-button click.

git clone --recurse-submodules 


Run cnmfe_setup.m to add CNMF-E package to the search path of MATLAB

>> cnmfe_setup

Required MATLAB toolboxes are listed below.

  1. /images/images
  2. /shared/optimlib/
  3. /signal/signal/
  4. /stats/stats/
  5. /curvefit/curvefit


The best way to get started is running a demo script for analyzing an example data. We included three demo scripts for you to try. You can modify these demos to process your own datasets.

  1. demo_endoscope.m : this demo is good for exploratory analysis of your data. It gives you a good sense of different stages of CNMF-E pipeline and how different parameter selections influence your final results.

>> run demos/demo_endoscope.m

  1. demo_large_data_1p.m : this demo is good for processing large-scale dataset with the minimal manual intervention. It can process small data as well and should be used in most automated analysis.

>> run demos/demo_large_data_1p.m

  1. demo_large_data_2p.m : this demo is the same as demo_large_data_1p.m. It is optimized for processing 2p data.

>> run demos/demo_large_data_2p.m


You can ask questions by sending emails to or joining our slack channel for discussions. An email request for slack channel invitation is required, or you can ask your collegues who have joined the slack channel already for an invitation.

Please read more from the wiki page


This repository is the native implementation of the CNMF-E model & algorithms using MATLAB. There is also a python implementation of the model in CaImAn. However, these two implementations are not exactly the same in some details and we are still working to make them consistent. For those people who love Python but still want to run CNMF-E using the MATLAB implementation, we provided a Python wrapper (thanks to Tim Machado) for calling MATLAB version CNMF-E in Python. You can use the ipython notebook file python_wrapper/ analyze_cnmfe_matlab.ipynb to get started. In the meanwhile, Thomas Akam provided a solution to load CNMF-E results from python, please check it out .


Please cite these papers when you use CNMF-E in your research. Thanks!

Zhou, P., Resendez, S.L., Rodriguez-Romaguera, J., Jimenez, J.C, Neufeld, S.Q., Giovannucci, A., Friedrich, J., Pnevmatikakis, E.A., Stuber, Garret D , Stuber, G.D., Hen, R., Kheirbek, M.A., Sabatini, B.L., Kass, R.E., Paninski, L. (2018). Efficient and accurate extraction of in vivo calcium signals from microendoscopic video data. eLife, pp.e28728. (When you use the (Corr+PNR) algorithm in the initialization step or use the ring model for estimating background components)

Pnevmatikakis, E.A., Soudry, D., Gao, Y., Machado, T.A., Merel, J., Pfau, D., Reardon, T., Mu, Y., Lacefield, C., Yang, W., Ahrens, M., Bruno, R.,Jessell, T.M., Peterka, D.S., Yuste, R., and Paninski L., 2016. Simultaneous denoising, deconvolution, and demixing of calcium imaging data. Neuron, 89(2), pp.285-299. (The original CNMF framework paper; When you use the vanilla CNMF model in this paper )


Copyright 2016 Pengcheng Zhou

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 3 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


Constrained Nonnegative Matrix Factorization for microEndoscopic data







No packages published