Spike Detection

 

Spike Detection
Figure 16: The red dots show the spikes detected by the Spikeprocessing class of the Datapipeline API

Spike detection algorithms exist in a plentiful amount. For the purpose of online processing multichannel neural data with Python, the algorithm implemented in the Spikeprocessing class is rather simple but yields usable results. The implementation roughly follows the spike detection method described in http://www.scholarpedia.org/article/Spike_sorting and Hernan Gonzalo Rey, Carlos Pedreira, and Rodrigo Quian Quiroga. "Past, present, and future of spike sorting techniques" Brain Research Bulletin, vol. 119, 2015. doi:10.1016/j.brainresbull.2015.04.007
The cornerstone of the algorithm is the computation of a sensible threshold in a way that is robust against noise, artifacts, and outliers.

Let |x| be the absolute value of our neural signal. We know that for Gaussian noise, the median of the absolute value of the signal will be 0.6745σ, where σ is the standard deviation of the Gaussian noise. Thus we can compute the threshold for our spike signal as:

 

robust threshold
Figure 17: This is a very commonly used spike threshold implemented in commercial as well as open-source software.

The assumption here is, that action potentials have a greater amplitude than the background noise. Thus, thresholding methods attempt to accurately estimate background noise levels.
By using the median we make sure that our method is robust against noise, artifacts, and outliers and therefore superior to the regular standard deviation. Furthermore, this method is computationally very inexpensive and therefore ideal for multichannel online spike detection in Python.

improved threshold
Figure 18: The difference between the standard threshold using the regular standard deviation and the median method can be clearly seen. The improved threshold is much closer to what a human would select. It is also clear that the standard threshold misses a lot of smaller action potentials.