MouseLand / suite2p

cell detection in calcium imaging recordings
http://www.suite2p.org
GNU General Public License v3.0
361 stars 243 forks source link

Cell quality from Suite2p (Cell order by SNR, classifiers etc) #813

Open catubc opened 2 years ago

catubc commented 2 years ago

Hello We have been using Suite2p at the lab for a while and it's great. We were wondering a bit about the cell export order as it seems to generally follow cell quality with earlier cells much higher quality than later. But other than order, we didn't find a specific metric saved in the python files (maybe there's one in the matlab files?!).

Lately there are papers that suggest using mixed metrics like modified SNR to evaluate quality (but the methods can be involved and seem to require a bunch more assumptions, see below).

Is there a bit more info on the suite2p cell order and quality metrics used? It seems skewness is generally a good metric, but not always given the natural distribution of [ca] signal data. We'd prefer to rely on Suite2p cell order/quality if these metrics are relatively robust (which they seem to be).

Thanks so much, catubc

Functional network topography of the medial entorhinal cortex Obenhaus] et al PNAS https://www.pnas.org/doi/full/10.1073/pnas.2121655119

From Methods

_After automatic ROI extraction, the Suite2p GUI was used to manually sub-select putative neurons based on anatomical and signal characteristics and discard obvious artefacts that accumulated during the analysis (e.g., unrealistically large ROIs or ROIs that did not have a clearly delineated footprint in the generated maximum intensity projection). Raw fluorescence traces were processed to create a corrected fluorescence signal (F corr ) by first subtracting 0.7 * neuropil signal, and ΔF/F was then calculated as (F corr - F 0 ) / F 0 . F 0 was estimated as constant for each cell after smoothing F corr with a 15 s spanning window (convolution of a scaled window with the signal, after introducing reflected copies of the signal at both ends so that transient parts are minimized in the beginning and end part of the output signal) and taking the median of the minimum 20% of this signal. Non-negative deconvolution (14) was used for deconvolving the neuropil and baseline corrected fluorescence (F corr ), yielding unfiltered, deconvolved events.

After deconvolution we kept events (i.e., filtered events) that were larger than one standard deviation over the mean (calculated over all extracted events for that neuron) and filtered out cells that did not meet a signal-to-noise ratio (SNR) cutoff of 3.5. We used the deconvolved, filtered amplitudes (events) as input for all subsequent analyses (spatial tuning maps etc.). For SNR calculation, noise statistics were extracted from the ΔF/F traces after filtering for episodes in which no deconvolved events were present (F noise ). These episodes had to lie at least 1 second before and 10 seconds after any deconvolved event to prevent signal contamination (safety margins). The SNR of that cell was then calculated as the ratio of the mean amplitude of filtered events over the standard deviation of F noise . If no filtered events were maintained for a cell, a SNR of zero was assigned. Since the MEMS scanner of the two-photon miniscope introduces warping artefacts to the image due to inhomogeneities in its control voltage response, unwarping procedures were used to re-align ROI pixel and image projection data (i.e., average, or maximum intensity projections). For this, a standard grid distortion target (R1L3S3P, Thorlabs) was first imaged and piecewise affine transformation was used to re-align warped key points (crossings of all grid lines) to an idealized grid pattern.

The resultant transformation matrix was then applied to unwarp both projection data (e.g., average, maximum-intensity projections) as well as ROI data. We filtered out ROIs that retained less than 10% of their original number of pixels after unwarping to get rid of edge artefacts for topographic analyses. Since the GRIN lenses we used have a magnification of 0.8 between the object plane and image plane), anatomical data that was acquired via these implants underwent additional post-correction with a scaling factor that was extract by aligning 2p miniscope FOVs to images acquired on the table-top fluorescence microscope through the same implant (see hardware description above, example can be seen in SI Appendix, Fig. S1B bottom)._

carsen-stringer commented 2 years ago

the ROIs are extracted in the order of variance explained -- how much variance they explain of the movie. this is saved in ops in 'Vmax' Vmax but could be added to the ROI stats