Skip to content

Interpreting Results

eftychios pnevmatikakis edited this page Sep 4, 2018 · 3 revisions

Result variables for 2p batch analysis

The results of CaImAn are saved in an estimates object. This is stored inside the cnmf object, i.e. it can be accessed using cnmf.estimates. The variables of interest are:

  • estimates.A: Set of spatial components. Saved as a sparse column format matrix with dimensions (# of pixels X # of components). Each column corresponds to a spatial component.
  • estimates.C: Set of temporal components. Saved as a numpy array with dimensions (# of components X # of timesteps). Each row corresponds to a background component denoised and deconvolved.
  • estimates.b: Set of background spatial components (for 2p analysis): Saved as a numpy array with dimensions (# of pixels X # of components). Each column corresponds to a spatial background component.
  • estimates.f: Set of temporal background components (for 2p analysis). Saved as a numpy array with dimensions (# of background components X # of timesteps). Each row corresponds to a temporal background component.
  • estimates.S: Deconvolved neural activity (spikes) for each component. Saved as a numpy array with dimensions (# of background components X # of timesteps). Each row corresponds to the deconvolved neural activity for the corresponding component.
  • estimates.YrA: Set or residual components. Saved as a numpy array with dimensions (# of components X # of timesteps). Each row corresponds to the residual signal after denoising the corresponding component in estimates.C.
  • estimates.F_dff: Set of DF/F normalized temporal components. Saved as a numpy array with dimensions (# of components X # of timesteps). Each row corresponds to the DF/F fluorescence for the corresponding component.

To view the spatial components, their corresponding vectors need first to be reshaped into 2d images. For example if you want to view the i-th component you can type

import matplotlib.pyplot as plt
plt.figure(); plt.imshow(np.reshape(estimates.A[:,i-1].toarray(), dims, order='F'))

where dims is a list or tuple that has the dimensions of the FOV. Similarly if you want to plot the trace for the i-th component you can simply type

plt.figure(); plt.plot(estimates.V[i-1])

The methods estimates.plot_contours and estimates.view_components can be used to visualize all the components.

Variables for component evaluation

If you use post-screening to evaluate the quality of the components and remove bad components the results are stored in the lists:

  • idx_components: List containing the indexes of accepted components.
  • idx_components_bad: List containing the indexes of rejected components.

These lists can be used to index the results. For example estimates.A[:,idx_components] or estimates.C[idx_components] will return the accepted spatial or temporal components, respectively. If you want to view the first accepted component you can type

plt.figure(); plt.imshow(np.reshape(estimates.A[:,idx_components[0]].toarray(), dims, order='F'))
plt.figure(); plt.plot(cnm.estimates.C[idx_components[0]])

Variables for 1p processing (CNMF-E)

The variables for one photon processing are the same, with an additional variable estimates.W for the matrix that is used to compute the background using the ring model, and estimates.b0 for the baseline value for each pixel.

Variables for online processing

The same estimates object is also used for the results of online processing, stored in onacid.estimates.