Amplitude CV (amplitude_cv_median, amplitude_cv_range)

Calculation

The amplitude CV (coefficient of variation) is a measure of the amplitude variability. It is computed as the ratio between the standard deviation and the amplitude mean. To obtain a better estimate of this measure, it is first computed separately for several temporal bins. Out of these values, the median and the range (percentile distance, by default between the 5th and 95th percentiles) are computed.

The computation requires either spike amplitudes (see compute_spike_amplitudes()) or amplitude scalings (see compute_amplitude_scalings()) to be pre-computed.

Expectation and use

The amplitude CV median is expected to be relatively low for well-isolated units, indicating a “stereotypical” spike shape.

The amplitude CV range can be high in the presence of noise contamination, due to amplitude outliers like in the example below.

../../_images/amplitudes.png

Example code

import spikeinterface.qualitymetrics as sqm

# Combine a sorting and recording into a sorting_analyzer
    # It is required to run sorting_analyzer.compute(input="spike_amplitudes") or
    # sorting_analyzer.compute(input="amplitude_scalings") (if missing, values will be NaN)
amplitude_cv_median, amplitude_cv_range = sqm.compute_amplitude_cv_metrics(sorting_analyzer=sorting_analyzer)
# amplitude_cv_median and  amplitude_cv_range are dicts containing the unit ids as keys,
# and their amplitude_cv metrics as values.

References

spikeinterface.qualitymetrics.misc_metrics.compute_amplitude_cv_metrics(sorting_analyzer, average_num_spikes_per_bin=50, percentiles=(5, 95), min_num_bins=10, amplitude_extension='spike_amplitudes', unit_ids=None)

Calculate coefficient of variation of spike amplitudes within defined temporal bins. From the distribution of coefficient of variations, both the median and the “range” (the distance between the percentiles defined by percentiles parameter) are returned.

Parameters
sorting_analyzer: SortingAnalyzer

A SortingAnalyzer object

average_num_spikes_per_binint, default: 50

The average number of spikes per bin. This is used to estimate a temporal bin size using the firing rate of each unit. For example, if a unit has a firing rate of 10 Hz, amd the average number of spikes per bin is 100, then the temporal bin size will be 100/10 Hz = 10 s.

min_num_binsint, default: 10

The minimum number of bins to compute the median and range. If the number of bins is less than this then the median and range are set to NaN.

amplitude_extensionstr, default: “spike_amplitudes”

The name of the extension to load the amplitudes from. “spike_amplitudes” or “amplitude_scalings”.

unit_idslist or None

List of unit ids to compute the amplitude spread. If None, all units are used.

Returns
amplitude_cv_mediandict

The median of the CV

amplitude_cv_rangedict

The range of the CV, computed as the distance between the percentiles.

Notes

Designed by Simon Musall and Alessio Buccino.

Literature

Designed by Simon Musall and adapted to SpikeInterface by Alessio Buccino.