Drift metrics (drift_ptp, drift_std, drift_mad)

Calculation

Geometric positions and times of spikes within the cluster are estimated. Over the duration of the recording, the drift observed in positions of spikes is calculated in intervals, with respect to the overall median positions over the entire recording. These are referred to as “drift signals”.

  • The drift_ptp is the peak-to-peak of the drift signal for each unit.

  • The drift_std is the standard deviation of the drift signal for each unit.

  • The drift_mad is the median absolute deviation of the drift signal for each unit.

The SpikeInterface implementation differes from the original Allen because it uses spike location estimates (using compute_spike_locations() - either center of mass or monopolar triangulation), instead of the center of mass of the first PC projection. In addition the Allen Institute implementation assumes linear and equally spaced arrangement of channels.

Finally, the original “cumulative_drift” and “max_drift” metrics have been refactored/modified for the following reasons:

  • “max_drift” is calculated with the the peak-to-peak, so it’s been renamed “drift_ptp”

  • “cumulative_drift” sums the absolute value of the drift signal for each interval. This makes it very sensitive to
    the number of bins (and hence the recording duration)! The “drift_std” and “drift_mad”, instead, are measures of
    the dispersion of the drift signal and are insensitive to the recording duration.

Expectation and use

Drift metrics represents how much, in um, a unit has moved over the recording. Larger values indicate more “drifty” units, possibly of lower quality.

Example code

import spikeinterface.qualitymetrics as qm

# It is required to run `compute_spike_locations(wvf_extractor)`
# (if missing, values will be NaN)
drift_ptps, drift_stds, drift_mads = qm.compute_drift_metrics(wvf_extractor, peak_sign="neg")
# drift_ptps, drift_stds, and drift_mads are dict containing the units' ID as keys,
# and their metrics as values.

Reference

spikeinterface.qualitymetrics.misc_metrics.compute_drift_metrics(waveform_extractor, interval_s=60, min_spikes_per_interval=100, direction='y', min_fraction_valid_intervals=0.5, min_num_bins=2, return_positions=False)

Compute drifts metrics using estimated spike locations. Over the duration of the recording, the drift signal for each unit is calculated as the median position in an interval with respect to the overall median positions over the entire duration (reference position).

The following metrics are computed for each unit (in um):

  • drift_ptp: peak-to-peak of the drift signal

  • drift_std: standard deviation of the drift signal

  • drift_mad: median absolute deviation of the drift signal

Requires ‘spike_locations’ extension. If this is not present, metrics are set to NaN.

Parameters
waveform_extractorWaveformExtractor

The waveform extractor object.

interval_sint, optional

Interval length is seconds for computing spike depth, by default 60

min_spikes_per_intervalint, optional

Minimum number of spikes for computing depth in an interval, by default 100

directionstr, optional

The direction along which drift metrics are estimated, by default ‘y’

min_fraction_valid_intervalsfloat, optional

The fraction of valid (not NaN) position estimates to estimate drifts. E.g., if 0.5 at least 50% of estimated positions in the intervals need to be valid, otherwise drift metrics are set to None, by default 0.5

min_num_binsint, optional

Minimum number of bins required to return a valid metric value. In case there are less bins, the metric values are set to NaN.

return_positionsbool, optional

If True, median positions are returned (for debugging), by default False

Returns
drift_ptpdict

The drift signal peak-to-peak in um

drift_stddict

The drift signal standard deviation in um

drift_maddict

The drift signal median absolute deviation in um

median_positionsnp.array (optional)

The median positions of each unit over time (only returned if return_positions=True)

Notes

For multi-segment object, segments are concatenated before the computation. This means that if there are large displacements in between segments, the resulting metric values will be very high.

Literature

First introduced in [Siegle] and modified by the SpikeInterface Team.