^{*}

The authors have declared that no competing interests exist.

Conceived and designed the experiments: AE WJ JI CT. Performed the experiments: AE JI. Analyzed the data: AE CT. Contributed reagents/materials/analysis tools: AE WJ JI TGC. Wrote the paper: AE TGC. Supervision and guidance of project outcomes: CT TC.

This work presents a new method that combines symbol dynamics methodologies with an Ngram algorithm for the detection and prediction of epileptic seizures. The presented approach specifically applies Ngram-based pattern recognition, after data pre-processing, with similarity metrics, including the Hamming distance and Needlman-Wunsch algorithm, for identifying unique patterns within epochs of time. Pattern counts within each epoch are used as measures to determine seizure detection and prediction markers. Using 623 hours of intracranial electrocorticogram recordings from 21 patients containing a total of 87 seizures, the sensitivity and false prediction/detection rates of this method are quantified. Results are quantified using individual seizures within each case for training of thresholds and prediction time windows. The statistical significance of the predictive power is further investigated. We show that the method presented herein, has significant predictive power in up to 100% of temporal lobe cases, with sensitivities of up to 70–100% and low false predictions (dependant on training procedure). The cases of highest false predictions are found in the frontal origin with 0.31–0.61 false predictions per hour and with significance in 18 out of 21 cases. On average, a prediction sensitivity of 93.81% and false prediction rate of approximately 0.06 false predictions per hour are achieved in the best case scenario. This compares to previous work utilising the same data set that has shown sensitivities of up to 40–50% for a false prediction rate of less than 0.15/hour.

Epilepsy is a neurological disorder that affects approximately 1% of the world’s population. It is characterised by seizures, which can manifest in several ways, from simple loss of awareness to more severe motor movements with loss of consciousness. A multitude of fields have studied the underlying mechanisms behind seizures, looking at the brain from multiple perspectives including bottom-up (i.e. local neuronal microcircuits) to global approaches (i.e. network activity monitored through local field potentials or EEG).

The goal of this work is in the detection and prediction of the epileptic seizure. Prediction has seen work ever since the 1950s applying linear, nonlinear (state-space) or multivariate analysis techniques to EEG and derivatives of it

Early work on seizure detection has predominantly focused on neonatal EEG. Seizures in neonates can be indications of Neonatal Encephalopathy (NE) - the manifestation of abnormal neonatal brain function - and can affect from 0.5–4 neonates per 1000

More recent detection work, looking at wave morphology changes

Similar to detection, there has been a wealth of work aiming to predict seizures

One of the first to separate temporal and frontal, and clinical and subclinical seizures showed sensitivities of 40–50% for a FPR of 0.15/h

At present, there are still avenues to explore for both prediction and detection of seizures. Prediction specifically has progressed significantly since

Pattern recognition algorithms typically involve three stages: (1) data acquisition, (2) data representation and (3) decision making

Traditionally applied to language models, an N-gram model extracts and counts the subsequences of a particular symbolic sequence

In an N-gram model -sequences of symbols are found within the data, setting up an N-gram tree with

For pattern recognition, separation of this symbol sequence into meaningful patterns is the first step after symbolisation, i.e. it allows the formation of a pattern search tree. This is typically done using entropy and information theory methods

Symbolic data analysis itself has been applied to time series in many applications including EEG analysis

A few studies have looked at signal symbolic analyses as a way of quantifying seizure-related activity. The first, is a series of work by Hively et al.

Schindler et al

The results of these studies have shown significant progress in symbolic analysis’ applicability to EEG-based time series, but have yet to quantify statistical prediction properties, including significance.

The aforementioned analyses methods are typically based on symbolic time series literature, while, as we previously mentioned, in language modelling this type of analyses uses an N-gram approach. In this section we describe our methodology (illustrated in

Our data contains 50 Hz mains noise so we apply a

Once filtered, the signals are separated into time windows and re-quantized. In data acquisition systems a signal is typically quantized into

Also shown are the equivalent hexadecimal symbol representation of this data.

Although typical hardware quantization employs binary (

The re-quantized signal is generated by converting the already quantized signal,

The aim of our method is to utilise the principles of an N-gram model but without the requirements of building an N-gram tree first. Instead we build the tree as we progress in time through a fixed window (1 minute), defining the patterns and associated counts. While building the tree we extract significant pattern counts. There are four ways we do this, three of which are illustrated in

The index of each unique pattern is also labelled.

Pattern (n = 3) | Count | Pattern (n = 2) | Count |

1 | 2 | ||

1 | 1 | ||

1 | 1 | ||

1 | 1 | ||

1 | 2 | ||

1 | 1 | ||

1 | 1 | ||

1 |

The above four mentioned methods are the first step in the process of analysis. For the overlapping cases, as we want to establish the unique set of patterns in a symbol sequence we need to establish which overlapping patterns to count and which to discard (note the results in

Unique patterns are achieved during the process of extracting patterns in the time window. During this process we first look for the largest pattern and if it has occurred previously we skip the remaining smaller ones; the largest pattern that repeats is considered dominant over any others which overlap with it. Significant patterns are then defined as those that occurred more than

The pattern is initially compared against a table containing the largest patterns (i.e. length 4). If found, the pattern count is incremented, otherwise the pattern is compared to the next largest pattern (i.e. length 3). If no match is found here both are added to the tables.

As an example, during a seizure onset (annotated in

The first measure is the percentage of similar symbols of two sequences using the inverse Hamming distance (HD). For patterns of equal lengths

The second similarity index we consider is based on the Needleman-Wunsch (NW) dynamic programming algorithm

For example, two sequences,

Comparing the Hamming distance and NW algorithm to exact pattern matching we now observe an average increase in the number of larger patterns and decrease in the number of smaller ones (

Once processed we have a count of the unique patterns over a pre-defined window (such as those illustrated in

The dynamic threshold is a function of the moving average of the pattern count,

To facilitate the application of the threshold on the ictal and interictal data we normalize the pattern count to the average of a randomly chosen interictal period, i.e. subtract the mean and divide by the maximum of an interictal period such that a signal (interictal or octal)

Also shown is a zoomed in view of the seizure on the EEG (top) and the optimal dynamic and static prediction thresholds.

The detection or prediction threshold defined in the previous section among other parameters is determined in a training phase (

This is iterated for each seizure of the patient.

Since some of our methods will produce multiple pattern counts (

Other parameters to be optimised include the intervention time (IT) and seizure occurrence period (SOP), both of which are defined in the next section.

For detection and prediction we use the standard metrics of sensitivity and false detection/prediction rate (FDR/FPR) to quantify accuracy. In addition, we use the prediction statistical framework described in

To validate the results of our prediction we apply the statistical framework described in

Seizure data were obtained from the University Hospital of Freiburg Epilepsy Centre, Germany (see

Patient | Seizures | Precital/hrs | Origin |
Electrode |
Interictal/hrs |

1 | 4 | 4.65 | F | g,s | 23.00 |

2 | 3 | 3.62 | T | d | 24.00 |

3 | 5 | 6.65 | F | g,s | 24.00 |

4 | 5 | 5.51 | T | d,g,s | 24.00 |

5 | 5 | 6.03 | F | g,s | 24.00 |

6 | 3 | 3.31 | T/O | d,g,s | 24.00 |

7 | 3 | 4.08 | T | d | 24.61 |

8 | 2 | 2.68 | F | g,s | 23.16 |

9 | 5 | 6.10 | T/O | g,s | 23.93 |

10 | 5 | 7.05 | T | d | 24.46 |

11 | 4 | 4.65 | P | g,s | 24.05 |

12 | 4 | 5.91 | T | d,g,s | 24.81 |

13 | 2 | 2.38 | T/O | d,s | 24.00 |

14 | 4 | 5.41 | F/T | d,s | 23.86 |

15 | 4 | 6.13 | T | d,s | 24.00 |

16 | 5 | 6.53 | T | d,s | 24.00 |

17 | 5 | 8.80 | T | s | 24.07 |

18 | 5 | 8.20 | F | s | 22.87 |

19 | 4 | 4.60 | F | s | 24.38 |

20 | 5 | 8.42 | T/P | d,g,s | 25.62 |

21 | 5 | 7.66 | T | g,s | 23.94 |

Origin = {F: Frontal, T: Temporal, O: Occipital, P: Parietal}.

Electrode = {g: grid, s: strip, d: depth}.

The implementation of all methods described was carried out in Matlab v.7.14. An online analysis tool (

In summary, the method we employ involves thresholding of extracted pattern counts within the data. For prediction, once a pre-seizure marker is detected, the pre-defined IT and SOP allow us to evaluate if the marker was indeed accurate in predicting the seizure. Detection does not use these pre-defined windows and as such it is simply a yes/no decision as to whether the threshold crossing is at the time of a seizure. Detection and prediction were tested as two separate studies, where optimisations were to maximise detection and prediction accuracy independently. Future work will look to combine the two methods such as to obtain an optimal threshold for both.

The results are based on pattern sizes of

Prior to our selection of parameters we performed empirical studies that varied the re-quantization parameter and looked at the pattern counts generated with a variety of pattern sizes (

This is done over an example seizure period to identify the most effective quantization resolution.

There are many considerations we can explore with regards to the use of quantization as a symbolic representation. As discussed in

In the detection of activity related to seizure onset, in part this assumption holds true; the seizure is a result of various levels of synchronous activity. In prediction, as we do not know the source of activity, whether it is embedded within the noise or is a true low-dimensionality source it is difficult for us to explicitly state the implications of quantization.

Our interpretation of the results is that for synchronous spiking activity the effect of re-quantization is to capture the periodicity and shape of these spikes. The addition of the hamming distance (or NW algorithm) also improves on this activity capture. Other types of activity (e.g. high frequency, low amplitude) seen during seizures also reflect this paradigm of thought. It is our belief, of why this method generally works for detection. For prediction, it is difficult to say as we do not know all the mechanisms that lead to seizure onset. As 8 bits (i.e.

We described

The detection and prediction results show that the methods using multiple patterns (

Results for the static and dynamic (moving average) threshold are also shown.

Both the first seizure used for training and the best performing training seizure for the optimal channel are shown in

These results show us that: (1) Assuming we only use the first seizure, we would have a sensitivity of 71.8% with FDR of 0.8. This is primarily distorted by case 18, that without sensitivity becomes 70.33% and FDR of 0.212. Assuming we have multiple seizures to fine tune the process we can achieve a sensitivity of 88.17% with FDR of 0.15.

We note that any combination of FDR and sensitivity can be implemented. For example, case 18, a better result uses the second seizure for optimization, giving a sensitivity of 20% and an FDR of 0. In addition, as we do not have information about the specific seizure types, or whether they are clinical or subclinical thus cannot illustrate in more detail why some seizures are detected and others not. The lack of accurate databasing with well annotated data sets has prompted initiatives to create them, including the Epilepsiae project

For prediction, the same parameters were used and, given the limited preseizure time available (due to the non contiguousness of the data samples), we analysed intervention times (IT) of 30, 20 and 10 minutes and with an SOP of 10 minutes. An example of the results for the 20 minute (SOP = 10 minutes) period is shown in

SOP = 10 mins | ||||||||||

IT (mins) | 10 | 20 | 30 | Opt. (Min. FPR) | Opt. (Max. Sens) | |||||

68.49% | 0.21 | 66.35% | 0.09 | 47.06% | 0.23 | 57.30% | 0.03 | 75.16% | 0.21 | |

46.51% | 0.31 | 50.48% | 0.28 | 30.71% | 0.28 | 36.19% | 0.10 | 59.44% | 0.28 |

S: Sensitivity.

FPR: False Prediction Rate.

IT (mins) | 10 | 20 | 30 | Opt. (Min. FPR) | Opt. (Max. Sens) | |||||

^{1} |
^{2} |
|||||||||

90.95% | 0.06 | 70.87% | 0.06 | 58.57% | 0.11 | 78.33% | 0.01 | 93.81% | 0.06 | |

70.08% | 0.21 | 50.08% | 0.12 | 37.78% | 0.11 | 54.37% | 0.09 | 72.22% | 0.22 |

To differentiate these results from a random predictor we use the binomial probability statistic with an FPR of 0.15 and SOP of 10 minutes to define our critical sensitivity boundaries (Section

SOP = 10 min | 1ST: min. FPR | 1ST: max. S | ||||||

Statistics | Exceeds | Statistics | Exceeds | |||||

42.41% | 0.01 | 77.8% | 55.6% | 66.85% | 0.12 | 100% | 88.9% | |

30.83% | 0.31 | 83.33% | 83.33% | 71.67% | 0.61 | 100% | 100% | |

32.22% | 0.01 | 83.33% | 33.33% | 51.94% | 0.09 | 100% | 50.00% | |

52.78% | 0.00 | 88.89% | 55.6% | 67.41% | 0.04 | 100% | 88.89% | |

55.00% | 0.30 | 83.33% | 83.33% | 71.67% | 0.61 | 100% | 100% | |

56.11% | 0.01 | 100% | 100% | 80.00% | 0.08 | 100% | 100% |

A select few studies have utilised the same data sets for the same goal, seizure detection and prediction. This section reviews the results of these to offer a reliable comparison with our own results. Recently Zhou et al

The data set has mainly been used, for seizure prediction, by groups at Freiburg. The first two, from 2003, analysed the dynamic similarity index (DSI)

In 2004, a comparison was performed between the DSI, correlation dimension and accumulated energy

More recently, in 2006, two studies considered further analysis of this data set using the DSI

These results, comparable to our own, do show some interesting outcomes, especially those related to variation in results depending on brain region and time of day, as well as inter-patient variability and the optimisation of FPR, SOP, IT and sensitivity.

The method we have applied here extracts and counts the number of repeating patterns in a fixed time window. Hence a pseudo-periodic feature, linear or nonlinear, could be counted. The nonstationary nature of EEG make the alignment and extraction of these patterns much more difficult, but is alleviated by the utilisation of similarity quantifiers (Hamming distance and NW algorithm). Using intracranial EEG allowed for an overall better signal-to-noise ratio than that of scalp recordings and although the data did still contain artefacts these were eliminated by Savitsky-Golay filtering.

Several improvements can be made to the method to alleviate some potential drawbacks. These include: (1) between windows no attempt has been made to assess whether particular patterns are consistent between them and how specific patterns may be more important detective/predictive markers over others, (2) using overlapping windows needs to be investigated to see whether this avoids any discontinuities in the pattern counts, (3) finally, to analyse larger, annotated data sets such that we can correlate patterns to different types of seizures. We also aim to use these data sets for training across patient sets, i.e. using patient seizure data to predict/detect other patients and seizures. It is interesting to note that false detections and predictions are higher in frontal cases (patients 18 and 19). This could be due to increased artefacts and general activity typically found in this area of the brain. Better classification of artefacts will be required to better quantify the results as well as considerations from previous studies, on time of day and cortical versus hippocampal seizures.

Although this is a computational method, the actual processing is fixed point and therefore lends itself to implementation in traditional Von-Neumann architectures and parallel processing, making it extremely efficient for reconfigurable (e.g. FPGA) and custom (e.g. ASIC) hardware implementations. Accuracy vs. complexity of the algorithm needs to be explored, including utilisation of the electrographic to clinical onset time for more accurate quantification of detection. Given also that better thresholds can be defined based on the use of multiple seizures, our methodology would be suitable for self-learning systems that optimise based on previous events and activity.

Further to this, the results show that the seizure that produce the highest sensitivity and FPR is not typically the first. This implies that our method is best suited to longer training phases using multiple seizures to train parameters. Hence our desire to use more extensive (and continuous) data sets with multiple seizures and training phases. Although training was employed the parameters, including the threshold, can be better defined. It may be better suited to define a threshold based on the several hours of interictal data and then apply this to ictal periods, i.e. defining what is normal so you can identify abnormalities.

We have presented a new approach that utilises elements of N-grams and symbolic signal representation schemes combined with sequence similarity metrics to track dynamical changes in the various ictal states. Using intracranial EEG recordings we were able to quantify the detection and predictive power of this method using simple thresholding schemes. We assessed our method using standard statistical measures of sensitivity and false prediction rate using a single seizure and one hour interictal period to train this threshold and the optimal pattern lengths to use for a specific patient. The non-contingent nature of the data led us to use the binomial probability critical sensitivity tests

This work has successfully demonstrated an N-gram based algorithm with significant predictive power. With an average sensitivity of 67% for temporal lobe seizures and FPR of 0.04 for an SOP of 20 minutes and combined ITs of 30, 20 and 10 minutes. Frontal seizures brought the increased the average FPR, showing 72% sensitivity and FPR of 0.61 when maximizing sensitivity. This led to an overall maximum average of 75.16% and 0.21 FPR. Using different seizures for training yielded much higher results, warranting the use of multiple training seizures for future work. For temporal cases this means a sensitivity of 100% is achievable and on average low false predictions (0.06, with almost all cases exceeding the upper critical sensitivity). This showing that this method of prediction has significant predictive power that warrants further study.

We would also like to thank the University of Freiburg EEG database, provided by the university Epilepsy Centre, for sharing their extensive data sets (