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:
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.