Abstract—Detecting action potentials has an important role in analyzing extracellular neuronal recordings. Current algorithms require subjective tuning by a user in the form of user-specified parameters. This paper describes a fully automatic template-matching spike detection algorithm that does not require any tuning. This algorithm is robust to noise and performs better than an optimum threshold detection algorithm. Keywords—action potential, globus pallidus internus (GPi), microelectrode recording (MER), stereotactic deep brain stimulation (DBS) surgery, subthalamus nucleus (STN). I. INTRODUCTION Neurons communicate with one another by firing action potentials. They are often simply called ‘spikes.’ Detecting action potentials is a very important prerequisite for analysis of the extracellular neuronal recording’s characteristics. When an extracellular neuronal recording does not have strong background noise, simple hardware threshold detection works reliably. It becomes a challenge to detect action potentials when an extracellular neuronal recording has significant amount of background noise. Several software-oriented action potential detection algorithms have been introduced as computers’ data processing speed increases [1] [2]. Among them, a threshold detection algorithm and a feature-matching algorithm are the most common ones. The threshold detection technique is the simplest technique and many neurosurgeons use it in practice. After visual inspection of extracellular neuronal recordings, a user sets a threshold for amplitude and a detector declares an action potential every time the signal exceeds the user-specified threshold. When the action potential’s amplitude is significantly greater (>3 times) than that of background noise, finding the optimum threshold is a relatively easy task [3]. However, when background noise is strong, it is hard to find the optimum threshold and performance of the threshold detector becomes poor even if a user chooses the optimum threshold. The feature-matching algorithm collects feature data of typical action potentials prior to the detection process of action potentials. A detector declares an action potential when a signal’s features match those of typical action potentials. Although golden rules do not exist for what kinds of features are the best, there are several features that are used widely such as peak amplitude, rising/falling slopes and duration of an action potential [2]. Some algorithms use an entire action potential as a template- model, which are called the template-matching algorithms [4]. The main concept of this algorithm is to choose one of many model templates automatically from a template library and calculating the distance of a microelectrode-recording signal from the model template of an action potential at time t. When the distance is small enough at a certain time t, a detector classifies the signal as an action potential. Although most procedures in this technique are automatic, it still requires a user’s visual inspection of the optimal threshold for the distance. Its performance highly depends on how many diverse model templates the template library has. Above all, the algorithms described above require a user’s intervention or preprocessing of extracellular neuronal recordings before they actually detect action potentials. Action Potential Detection with Automatic Template Matching S. Kim 1 , J. McNames 1 , K. Burchiel 2 1 Biomedical Signal Processing Laboratory, Electrical and Computer Engineering, Portland State University, Oregon, USA 2 Department of Neurological Surgery, Oregon Health and Science University, Oregon, USA The objectives of this paper were to develop the algorithm for template-matching spike detection which does not require any user intervention or preprocessing of signals and to assess its performance in comparison with that of an optimum threshold detection algorithm. The new technique will help neurophysiologists detect action potentials of various morphologies in extracellular neuronal recordings faster and more reliably than the optimum threshold detection algorithm. II. METHODOLOGY A. Detection Algorithm Step 1: The first step is to detect all positive amplitude local maxima. The duration of an action potential is typically no greater than 1.3 ms. The relationship between a sampling frequency and the number of sample points for a model template can be expressed as T f N s × = (1) where, N is the number of sample points, f s is the sampling frequency in kHz and T is the duration of a single action potential in ms. Now, each positive amplitude local maximum corresponds to a sequence of N number of sample points, which are from the N/2 sample point prior to each local maximum to the N/2 sample point subsequent to each local maximum. Step 2: The second step is to calculate the energy of each sequence of N sample points around each local maximum. The sum of squared values of N sample