Standard Deviation (SD) ratio (sd_ratio)

Calculation

All spikes from the same neuron should have the same shape. This means that at the peak of the spike, the standard deviation of the voltage should be the same as that of noise. If spikes from multiple neurons are grouped into a single unit, the standard deviation of spike amplitudes would likely be increased.

This metric, first described [Pouzat] then adapted by Wyngaard, Llobet & Barbour (in preparation), returns the ratio between both standard deviations:

\[S = \frac{\sigma_{\mathrm{unit}}}{\sigma_{\mathrm{noise}}}\]

To remove the effect of drift on spikes amplitude, \(\sigma_{\mathrm{unit}}\) is computed by subtracting each spike amplitude, and dividing the resulting standard deviation by \(\sqrt{2}\). Also to remove the effect of bursts (which can have lower amplitudes), you can specify a censored period (by default 4.0 ms) where spikes happening less than this period after another spike will not be considered.

Expectation and use

For a unit representing a single neuron, this metric should return a value close to one. However for units that are contaminated, the value can be significantly higher.

Example code

import spikeinterface.qualitymetrics as sqm

# In this case we need to combine our sorting and recording into a sorting_analyzer
sd_ratio = sqm.compute_sd_ratio(sorting_analyzer=sorting_analyzer censored_period_ms=4.0)

References

spikeinterface.qualitymetrics.misc_metrics.compute_sd_ratio(sorting_analyzer: SortingAnalyzer, censored_period_ms: float = 4.0, correct_for_drift: bool = True, correct_for_template_itself: bool = True, unit_ids=None, **kwargs)

Computes the SD (Standard Deviation) of each unit’s spike amplitudes, and compare it to the SD of noise. In this case, noise refers to the global voltage trace on the same channel as the best channel of the unit. (ideally (not implemented yet), the noise would be computed outside of spikes from the unit itself).

Parameters
sorting_analyzer: SortingAnalyzer

A SortingAnalyzer object

censored_period_msfloat, default: 4.0

The censored period in milliseconds. This is to remove any potential bursts that could affect the SD.

correct_for_drift: bool, default: True

If True, will subtract the amplitudes sequentiially to significantly reduce the impact of drift.

correct_for_template_itself: bool, default: True

If true, will take into account that the template itself impacts the standard deviation of the noise, and will make a rough estimation of what that impact is (and remove it).

unit_idslist or None, default: None

The list of unit ids to compute this metric. If None, all units are used.

**kwargs:

Keyword arguments for computing spike amplitudes and extremum channel.

TODO: Take jitter into account.
Returns
num_spikesdict

The number of spikes, across all segments, for each unit ID.

Literature

Introduced by [Pouzat] (2002). Expanded by Wyngaard, Llobet and Barbour (in preparation).