# Waveform drift¶

## Spike sorting¶

Let \(X\) be a \(M\times N\) multi-channel timeseries array representing the signal acquired during a recording session. Here \(M\) is the number of channels and \(N\) is the number of timepoints in the recording. A spike sorting algorithm applied to this data will yield a sequence of firing events:

where \(t_j\) is the timepoint of the \(j^{th}\) event and \(k_j\) is the corresponding neuron label

Ideally, assuming that each firing event produces a signal spike whose shape depends only on neuron label, we would have

where \(W_k\) is the waveform corresponding to the \(k^{th}\) neuron, and \(\eta\) is noise. We can estimate the average spike waveforms, or templates, from the output of spike sorting as follows:

## Drift¶

In practice the spike waveform for a given neuron will change slightly over time. This is known as drift. Our signal model becomes more complicated:

where the waveform \(W_{k,t}\) for the \(k^{th}\) neuron now has a time dependency.