Skip to content

dFF Tools

HagaiHargil edited this page Sep 25, 2018 · 5 revisions

Introduction

The file dff_tools.py contains several functions that can help with the analysis of dF/F traces. In general, almost all functions take a data variable that corresponds to the dF/F traces of neurons, each row being a cell with the columns as time. This wiki is in addition to the (detailed) documentation of each function.

calc_dff and calc_dff_batch

Functions that facilitate cell-by-cell dF/F calculation. A list of files can be presented to _batch, and if these files have corresponding CaImAn-results files, the returned dF/F matrix will be derived from there. Else, it will calculate its own dF/F metric.

locate_spike_peakutils

Uses the peakutils package to analyze the fluorescent trace of dF/F matrices. The threshold and minimal distance between subsequent peaks can be controlled. The result is a matrix with a similar shape to that of the raw data, containing 1 wherever a peak was detected, and 0 otherwise.

scatter_spikes

Creates a scatter plot in which each cell's dF/F is a row, and the detected peaks are shown as dots on the individual traces. The method requires both the raw dF/F data and the spike timing data that was calculated using the locate_spike method. Scatter plot

plot_mean_vals

Computes a mean rolling window across all cells. Input data can either be the raw dF/F trace, creating an output of the mean dF/F value over time for an "average" cell, or the spike timings matrix, creating the rolling mean spike rate over the entire FOV.

display_heatmap

Shows an "image" of the activity of cells over time, each row being a cell, columns representing time, and the dF/F value is the brightness of the image. Accepts an "epoch" argument for the title, a downsampling factor and the recording's FPS. Heatmap

display_cell_excerpts_over_time

Shows a "mosaic" of cells over time, as their calcium activity changes. Requires an .npz file with the CaImAn results and the path to the original .tif stack. You can also supply the specific indices you wish to view (if you have some cells which were co-labeled with a morphological marker, for example). You can also supply the expected cell radius in pixels. Other parameters are self-explanatory. Mosaic

draw_rois_over_cells

For a given .tif stack, find the analyzed ROIs that CaImAn generated and draw their contours around the cells. Also adds a small number label next to each component.