Using FISSA with CNMF from MATLAB

CNMF is blind source separation toolbox for cell detection and signal extraction.

Here we illustrate how one can use the ROIs detected by CNMF, and use FISSA to extract and decontaminate the traces.

In this tutorial, we assume the user is using the MATLAB implementation of CNMF. As such, this also serves as a tutorial on how to import data from MATLAB into Python to use with FISSA.

However, note that there is also a Python implementation of CNMF, which you can use instead to keep your whole workflow in Python.

Reference: Pnevmatikakis, E.A., Soudry, D., Gao, Y., Machado, T., Merel, J., ... and Paninski, L. Simultaneous denoising, deconvolution, and demixing of calcium imaging data. Neuron, 89(2):285-299, 2016. doi: 10.1016/j.neuron.2015.11.037.

Import packages

Running CNMF in MATLAB, and importing into Python

We ran CNMF in MATLAB using the run_pipeline.m script available from the CNMF repository on our example data (found at ../exampleData/20150529/).

We saved the Coor and F_df variables generated by that script into a .mat file (cNMFdata.mat) which we now load here.

Show detected cells

Let's render the ROIs using matplotlib.

Running FISSA on cells detected by CNMF

FISSA needs ROIs to be provided either as an ImageJ zip file, or a set of numpy arrays.

CNMF can output ROIs in coordinates (as we imported above), which can be directly read into FISSA. A given ROI after importing from MATLAB is given as

Coor[i, 0]

FISSA expects a set of rois to be given as a list of lists,

[[roiA1, roiA2, roiA3, ...]]

so we will need to change the format of the ROIs first.

Which can then be put into FISSA and run as follows.

Plotting the results

Let's plot the traces for ROIs as they were detected by CNMF, and after removing neuropile with FISSA.

The figure shows the raw signal from the ROI identified by CNMF (pale), and after decontaminating with FISSA (dark). The hues match the ROI locations drawn above. Each column shows the results from one of the ROIs detected by CNMF. Each row shows the results from one of the three trials.