Search tips
Search criteria 


Logo of nihpaAbout Author manuscriptsSubmit a manuscriptHHS Public Access; Author Manuscript; Accepted for publication in peer reviewed journal;
Conf Proc IEEE Eng Med Biol Soc. Author manuscript; available in PMC 2010 June 8.
Published in final edited form as:
PMCID: PMC2882069

User-Guided Interictal Spike Detection


In the diagnosis and treatment of epilepsy, long-term monitoring may be required to document and study interictal activities such as interictal spikes. However, visual inspection of the EEG done by an expert is too time consuming and researchers normally resort to automatic detection methods. We describe a new EEG user-guided interictal spike detection algorithm that only requires the user to annotate a few spikes. We use the annotations to build a template that captures the relevant features of spikes, and then use Mean Squared Error (MSE) test to detect all of the other spikes in the recording. The detected events are rank ordered so that the user can easily identify the true spikes and their time of occurrence. The true spikes are then annotated to the EEG signals and reported to the EEG expert for further evaluation. This design provides a compromise between the enormous time commitments necessary to annotate recordings by hand and the inability of fully-automatic spike detection algorithms to account for the variability between subjects. Because spike morphology and spatial distribution change considerably when patients go through cycles of wake and sleep in long-term monitoring, this detection algorithm uses multichannel multiple templates to detect more than one type of event. The algorithm is able to achieve an average sensitivity of 96% and an average of 4.8 false detections/ hour.

Index Terms: electroencephalography, epilepsy, EEG, automated spike detection, interictal spike detection


According to the National Institute of Neurological Disorders and Stroke, more than two million people in the United states have been diagnosed with epilepsy or have experienced a seizure. It is the second most common neurological disorder, outnumbered only by headache. Epileptic seizures are triggered by a burst of abnormal electrical activity in the brian. Beyond the diagnosis of epilepsy, spike detection could provide researchers with valuable descriptions of spike spatial distribution and morphology that may help prevent epilepsy or to predict which treatments will be most beneficial. Visual inspection of long-term monitoring done by an expert is too time consuming. Automatic detection of spikes saves a considerable amount of time. Unfortunately, automatic detection of spikes in the EEG is a complex task due to the variety of morphology of spikes and their similarities to waves which are part of the background noise and to artifacts such as eye blinks [1]. Several methods for spike detection have been proposed based on single and multichannel approaches. Those methods were classified into six categories [2]:

  1. Mimetic techniques that copy the human expert, [3]–[5]
  2. Template matching algorithms based on finding events that match previously selected spikes, [6]
  3. Parametric approaches based on traditional signal processing techniques [7]
  4. Neural networks (NNs) techniques [8]–[11]
  5. Data mining (DM) techniques [12], [13]
  6. Knowledge-based rules techniques [14].

Mimetic methods are based on the hypothesis that the process of identifying a transient in the EEG as epileptogenic could be divided into well-defined steps representing the reasoning and expertise of an EEG expert. Distinctive attributes of the spikes such as slope, height, duration and sharpness are compared with values provided by the EEG experts. Gotman and Gloor decomposed the waveform into two half-waves with opposite directions. Similar methods for decomposing the EEG waveform into half-waves have been used by many authors [14]–[16]. Faure et al. [15] introduced a concept where the duration, amplitude and slope attributes of half-waves were used to classify them into states.

In the template matching, the user visually selects a few spikes from a set of test signals. These spikes are averaged to create a template. Many researchers like Park et al. and [9] used wavelets to obtain features of the signal for template building and spike detection.

In the parametric approaches, researchers assume local stationarity of the noise and spikes are detected as deviation from that stationarity. Tzallas et al. [7] presented a new technique based on a time-varying autoregressive model that made use of the nonstationarities of the EEG. The autoregressive parameters were estimated via Kalman filter. The signal was first processed to accentuate the spikes and attenuate background activity and then passed through a thresholding function to determine spikes locations.

Neural Networks have been trained using either raw data or select features to detect spikes. Pang et al. [8] explored the performance of NN in spike detection. Webber et al. [16] compared multi-layer perceptron networks using both raw digitized data and half- wave attributes as input. Ozdamar et al. [11] believed that it is very difficult for the EEG experts to select and define all these waveform parameters, therefore they forgo the creation of attributes and instead used the raw waveform as input to a NN. Use of raw data eliminated the need to define half-wave, slopes and sharpness.

Data mining (DM) techniques were used by [12], [13] to build automatic detection models. In DM, the recognition of spikes does not need a clear definition of spike morphology.

Considerable use of spatial and temporal contextual information present in the EEG aids both in spike detection and background activity rejection [17]. Arising from the need to incorporate knowledge of the EEG experts, Davey et al. [14] presented an expert system approach to detection of epileptifom activity in the EEG. The system consists of two stages. The first is a feature extractor that produces a list of all spike-like occurrences. The second stage reads the list and uses rules incorporating knowledge elicited from the EEG expert to confirm or exclude each of the possible spikes.

In this paper, we propose a user-guided spike detection system. The basic idea is to have the user annotate a few spikes in the Stellate (Montreal, Canada) EEG analysis and acquisition software, use this to build a template that captures the spikes’ relevant features, then use Mean Squared Error (MSE) test to detect all of the other spikes in the recording. When the MSE exceeds a threshold, the algorithm declares the event as a spike. The detected events are rank ordered so that the user can quickly and easily identify the true spikes. The true spikes’ location is then automatically annotated in Stellate for further inspection by the EEG expert. To reduce false spike detections, we make use of spatial context information by including a number of channels in the design of templates and spike detection. This system provides a very usable compromise between the inability of fully-automatic spike detection algorithms to account for the variability between subjects and the enormous time commitments necessary to annotate recordings by hand. Our algorithm is generalized so that it uses multiple templates and looks for more than one type of event to account for changes in spike morphology and spatial distribution when patients go through cycles of wake and sleep during long-term monitoring [18].


A. Problem Statement

Many methods have been proposed to detect spikes that are embedded in a noisy background. This is usually based on the following statistical model


where x is the observed data vector, the signal s is a vector that represents the presence of a spike, and w is the background noise vector. A boldface small letter denotes a vector, and a boldface capital letter will be used to denote a matrix. If the EEG are recorded with M channels, then at the nth sample time we observe the data vector


where xm[n] is the nth sample at the mth channel. The accumulated data for the time interval [0, N − 1] is {x[0], x[1],… ,x[N − 1]}. A more convenient arrangement for the data is a windowed segment as


Using the observed data, we wish to design a detector that decides either the signal at time n is a spike or a noisy background. This could be modeled as one of choosing between H0, which is known as the null hypothesis or the noise-only hypothesis, and the alternative hypothesis or the spike-present hypothesis; H1



B. Detector design

A simple hypothesis testing could be based on the Neyman-Pearson (NP) theorem; that is the detector that maximizes the probability of detection (PD) for a given probability of false alarm (PFA = α). The NP detector decides H1 if the likelihood ratio exceeds a threshold or


For each value of the observed data, the likelihood ratio indicates the likelihood of H1 versus the likelihood of H0 and is known as the likelihood ratio test (LRT). If signals follow a linear model and the noise is Gaussian, the detector is optimal and is termed matched filter. However, due to the infrequent high magnitude noise spikes caused by eye blinks, the Gaussian assumption is not valid.

In this paper, we model the signals with a heavier-tailed distribution and use the Mean Squared Error (MSE) to decide either the signal at time n is a spike or a noisy background. MSE is the expected value of the square of the error. The error is the amount by which the signal at time n differs from the template s[n].


If the MSE exceeds a threshold, our detector decides H1 or


This is our MSE detector which consists of a test statistic T(MSE) that is a function of the data and the template, and a threshold γ. The threshold is a user-specified parameter that controls the tradeoff between sensitivity and specificity.

C. Template Estimation

The model template for spikes is estimated based on segments of the original signals centered at the indices of annotations provide by the EEG expert with a duration [ell] of 200 msec. The template for the kth channel is estimated as the median of the overlapping segments of channel k,


where med{·} represents the median operator, ii is the time index of the ith annotation, and B is the number of annotations. We use a median operator instead of the sample average because the median is more robust to outliers caused by signal artifact. These preliminary templates are used for detection and the detected spike indices are then used to estimate new templates. This sequence of template estimation followed by detection is repeated for several iterations sufficient for this algorithm to obtain a good estimate of the templates. Fig. 1 shows two examples of aligned spikes after the first and third iterations, and the corresponding estimated templates.

Fig. 1
Centered 200 ms segments and the estimated model template for spikes after (a) first and (b) third iterations.

An intermediate step in this detection system is a five second plot of all channels used in designing the templates centered at each time index of the mean squared error that exceeded the threshold. This is done for a quick visual inspection to eliminate any false positives before annotating the signal file with true annotations in the Stellate system. The spike location is marked with a gray vertical patch with its rank on top of it. One being the detected spike with the least mean squared error. Only the center spike is shown with its rank. If there are more than one detected spike, they are shown in the same window. If an original annotation that was provided by the EEG expert falls within the time frame of the five second segment, it is plotted with a dashed vertical line.


We analyzed the EEG data of two adult patients. A 32−channel EEG was performed with standard surface electrodes according to the 20/20 system. The signals were sampled at 200 Hz. For each patient, one segment of EEG was annotated in Stellate EEG analysis and acquisition software. Annotations indicate the location and type of a spike; B1 for type 1 and B2 for spikes of type 2. From the signal processing point of view, the difference between B1 and B2 for the analyzed signals is the number and location of channels to include in the design of templates. See Table I for annotations’ specifications. The signals were then bandpass filtered at 0.5 –30 Hz and up-sampled to 1000 Hz.

Events count and user-specified algorithm parameters.


Fig. 2 shows an example of a detected spike of type B1 of the first signal. The center spike has the number five on top of it to indicate its rank among the other detected spikes. Table I shows that the algorithm was presented with 29 annotations of type 1 (B1). The 29 annotations were used to estimate the templates for the first iteration for six channels . The detected spikes were then used to build the second and the third iteration templates. Using the templates of the third iteration, the algorithm detected 66 spikes, out of which 61 were true positive with sensitivity of 92%. Five detected spikes were false positives; a rate of 4.8 false detections/ hour. The design also detected 27 out of the 29 original annotations.

Fig. 2
Five second segment centered at the estimated spike. Gray vertical patch indicates a detected spike. The dashed line indicates a match of an original annotation provided by the EEG expert and a detected spike. min.

For the second file, the algorithm was presented with 12 annotations of type B2. Four channels were used to estimate the templates that are shown in fig. 1. The algorithm detected 63 spikes, out of which 63 were declared true positive with detection rate of 100%. Only 9 out of the 12 original annotations were detected and they are labeled as matched events in table I.

Fig. 3 shows a good example of the benefits of incorporating the spatial information in spike detection. The system is able to detect a few true spikes while a few spike-like nonepileptiform transients were selectively rejected. The center spike was detected by the algorithm but was not provided by the EEG expert. Two other events were provided by the expert and were detected by the algorithm. The event to the left of the plot at approximately 669 s was counted as a false positive because it did not have the sharp wave characteristics in the bottom two channels Fp2-T2 and T2–T4.

Fig. 3
This spike at 11.19 min was detected by the algorithm but was not provided by the EEG expert. Two other events were provided by the expert and were detected by the algorithm. The event to the left of the plot at approximately 669 s was counted as a false ...


The user-guided interictal spike detection described in this paper has many merits. It only requires the user to provide annotations of a few spikes with their time indices and type. It is able to estimate the template morphology automatically from the signal using the annotations. It estimates multi-channel multi-templates to account for change in morphology and spatial distribution with different patients or for the same patient who goes through cycles of wake and sleep during long-term EEG monitoring. It annotates the detected spikes back to Stellate software for further analysis by the EEG expert. Results using real recordings show that the algorithm has good sensitivity and specificity; an average detection rate of 96% and an average of 4.8 false detections/ hour .

Contributor Information

Mahmoud El-Gohary, Biomedical Signal Processing Laboratory at Portland State University, Portland, Oregon and enrolled in the PhD program of the Department of Electrical and Computer Engineering. ude.xdp@duomham..

James McNames, Biomedical Signal Processing Laboratory and an associate professor of the Department of Electrical and Computer Engineering at Portland State University, Portland, Oregon. ude.xdp@semancm..

Siegward-M. Elsas, Assistant Professor of Neurology, OHSU Comprehensive Epilepsy Center, Oregon Health and Science University, Portland, Oregon. ude.usho@sasle.


1. Wilson S, Emerson R. Spike detection: a review and comparison of algorithms. Clinical Neurophysiology. 2002;vol. 113:1873–1881. [PubMed]
2. Oikonomou V, Tzallas A, Fotiadis DI. A Kalman filter based methodology fo EEG spike enhancement. Computer methods and programs in biomedicin. 2007;vol. 86:101–108. [PubMed]
3. Gotman J, Gloor P. Automatic recognition of inter-ictal epileptic activity in the human scalp EEG recordings. Electroencephalography and clinical neurophysiology. 1976;vol. 41:513–529. [PubMed]
4. Gotman J. Automatic recognition of epileptic seizures in the EEG. Electroencephalography and clinical Neurophysiology. 1982;vol. 54:530–540. [PubMed]
5. Ktonas P, Glover J, Webster L, Antonthanasap R, Leeuwen W, Veelen C, Vliegenthart W. Automatic detection of epileptogenic sharp EEG transients, electroenceph. Clinical Neurophysiology. 1984:38–58.
6. Kalayci T, Ozdamar O. Wavelet preprocessing for automated neural network detection of EEG spikes. IEEE Engineering in Medicin and Biology. 1995:160–166.
7. Tzallas AT, Oikonomou V, Fotiadis DI. Epileptic spike detection using a kalman filter based approach. 28th Annual International Conference of the Engineering in Medicine and Biology Society; August 30–September 3; 2006. pp. 501–504. [PubMed]
8. Pang C, Upton A, Shine C, Kamath M. A comparison of algorithms for detection of spikes in the electroencephalogram. IEEE Transactions on Biomedical Engineering. 2003;vol. 50:521–525. [PubMed]
9. Park H, Lee YK, Lee SK. Detection of epileptiform activities in the EEG using neural network and expert system. Med. Inf. 1998;vol. 9:1255–1259. [PubMed]
10. Gabor AJ, Seyal M. Automated interictal EEG spike detection using artificial neural networks. Electroencephalography and clinical Neurophysiology. 1992;vol. 83:271–280. [PubMed]
11. Ozdamar O, Kalayci T. Detection of spikes with artificial neural networks using raw EEG. Electroencephalography and clinical Neurophysiology. 1998;vol. 91:122–142. [PubMed]
12. Exarchos TP, Tzallas AT, Fotiadis DI, Konitsiotis S, Giannopoulos S. EEG transient event detection and classification using association rules. IEEE Transactions on Information Technology in Biomedicine. 2006;vol. 10(no. 3):451–457. [PubMed]
13. Valenti P, Cazamajou E, Scarpettini M, Aizemberg A, Silva W, Kochen S. Automatic detection of interictal spikes using data mining models. Journal of Neuroscience Methods. 2006;vol. 150:105–110. [PubMed]
14. Davey B, Fright WR, Caroll GJ, Jones RD. Expert system approach to detection of epileptiform activity in the EEG. Med. and Biol. Eng. and Comput. 1989;vol. 27:365–370. [PubMed]
15. Faure C. Attributed strings for recognition of epileptic transients in EEG. Inter.J Biomed Comput. 1985;vol. 16:217–229. [PubMed]
16. Webber W, Litt B, K W, Lasser R. Practical detection of epileptiform discharges (eds) in the eeg using an artificial neural network: a comparison of raw and parameterized eeg data. Electroencephalography and clinical neurophysiologytroencephalography and clinical Neurophysiolog. 1994;vol. 91:194–204. [PubMed]
17. Dingle AA, Jones RD, Caroll GJ, Fright WR. A multistage system to detect epileptiform activity in the EEG. IEEE Transactions on Biomedical Engineering. 1993;vol. 40(no. 12):1260–1268. [PubMed]
18. Gotman J, Wang L. State dependent spike detection: concepts and preliminary results. Electroencephalography and clinical Neurophysiology. 1991;vol. 79:11–19. [PubMed]