Vous êtes sur la page 1sur 4

SEIZURE PREVENTION THROUGH CONTOUR FITTING

RMP 2015

Seizure Prevention: Quantifying Anomalous Changes in EEG Data


through Contour Fitting
1

Priyanka Multani,1 Abhejit Rajagopal,2

Torrey Pines High School, 3710 Del Mar Heights Road, San Diego, CA 92130
e-mail address: priya.pm2@gmail.com
2
Dept. of Electrical and Computer Engineering, University of California, Santa Barbara, 93106, USA
A new computational approach to signal processing permits the detection of epileptic seizures prior to
their onset through the identification of the seizure transition period. While existing technologies can
recognize seizures seconds before they occur, what we are proposing is a method to predict one minutes
before. To do this, we implement a regression technique that contour fits the data points representing brain
signals from before and after a seizure. These signals appear different in the two states, subsequently
altering the regression line. By applying our algorithm, the variance will become evident, allowing us to
recognize the transition period and predict the seizure. Specifically, we look at calculating the error signal
that illustrates the accuracy with which our algorithm can predict the next brain signal.
Keywords: electroencephalogram data, contour fitting, seizure transition period, interpolation, quadratic approximation

I. INTRODUCTION
Seizures are notorious for occurring without warning and
for causing irreversible damage physically to patients and
emotionally to the family. According to the Epilepsy
Foundation, people with epilepsy are up to three times more
likely to die early as a result of seizures that occur close to
time of death. Current advancements in medicine allow
doctors to prescribe patients with anticonvulsant drugs,
such as Carbamazepine or Divalproex, which can help
mitigate the affects of a seizure, but not before it procures.
[1] In addition, electrical stimulation of the vagus nerve and
adopting a Ketogenic diet are possible treatments, but these
become useful only if the seizure is predicted prior to its
onset.
A new approach to seizure detection explored in The
Epilepsies: Seizures, Syndromes and Management uses
electroencephalogram (EEG) data to produce an
incontrovertible diagnosis on an epileptic patient. We
believe that EEG data can also be used to predict a seizure
by studying the discrepancies between signals from before
and after a seizure. Prior to a seizure, brain signals will
form a very chaotic plot, while during a seizure, the signals
will present a more organized graph. By finding a general
pattern to the movement, we may be able to foresee the
period directly before a seizure, the seizure transition
period, and therefore, pinpoint any abnormalities ahead of
time.
Unfortunately, there is no significantly developed method
for anticipating a seizure. One reason for this is it would
require an algorithm that can plot real-time brain signals
and make an inference purely based on these signals.
Furthermore, brain signals come with a myriad of other
information that can obscure the seizure transition period
and hinder our ability to identify it. This perplexing topic,

however, is successfully becoming less elusive through the


work of the Scientific Computing Group. We have recently
developed a unique computational tool for processing EEG
data that can change multichannel brain signals into simple
three-dimensional points. The program employs quadratic
approximation to contrive a curve that will best fit the
electroencephalogram data as well as interpolation to
extract the essential information. In particular we focus on
quantifying the accuracy of our algorithm by using the
nearest neighbor tracking method. Through this approach,
we are able to measure how precisely we can predict the
next brain state and also classify the approximation of the
next data point as a representation of the brain state before,
during, or after a seizure. We hypothesize that due to the
disordered characteristic of non-seizure data, the error
signal will be very high, while during a seizure, the patternlike graph will make the approximation very accurate and
the error signal low.
In the future, we believe that by implementing a variation
of the shape-from-shading (SFS) algorithm created by Ruo
Zhang and Mubarak Shah, we may even be able to
determine the intensity of a seizure. Research, regarding
reconstruction of three-dimensional images from twodimensional images, proves that the intensity gradient
variable can be expressed as a linear function of surface
height. By using this approach, we can instead depict the
intensity gradient as a linear function of time, allowing us
to plot the intensity of each brain signal in real-time. This
would increase the chances of treating the patient properly
and giving them preventative medicines as opposed to the
currently used reactive medicines. The success of this
project would significantly reduce the irreversible damage
that seizures can cause and would help bring back the
quality of life that is often lost for those whose lives are
governed by the uncertainty and anticipation of a seizure.

SEIZURE PREVENTION THROUGH CONTOUR FITTING

RMP 2015

II. STEPS
Current technological advancements have allowed
doctors to prescribe patients with anticonvulsant drugs and
perform medical operations, but only after a seizure has
procured. The existing method of diagnosing epileptic
patients using EEG data unfortunately requires at least one
severe seizure to transpire in order for the results to be
accurate. As a result, our algorithm analyzed preprocessed
EEG data that quantified each brain signal as a threedimensional point in order to try and predict a seizure
before it occurs entirely.
The algorithm initially formulated bins or clusters by
interpolating the predefined matrix of time into one
hundred sections. To create the bins, we generated a matrix
with the first hundred integers and then multiplied each
entry by the interval, or the length of each bin. The interval
was the maximum value of time subtracted by the
minimum value of time, divided by the number of clusters.
In our case, this number was 0.01. To make sure that time
started equal to zero, after completing the calculations, we
manually made zero the boundary of the first bin. We then
computed the average point and time in every cluster and
plotted the resulting values on top of the plot showing all
the data points. For the initial stages of this experiment we
also calculated the mean value, with the value being
defined as a binary number: 0 if the point was not during a
seizure and 1 if it was. The resulting one hundred data
points, represented by the black data points in FIG. 1.,
successfully eliminated the noisy EEG data and clearly
defined the universal trend of the data. In addition, this new
matrix of points was used for the derivation of the
regression line so that the line could easily and accurately
capture the data. To devise the regression line, the
algorithm used derivatives to estimate how the XY position
was changing

FIG. 2. Yellow line depicts the regression line found by using


quadratic approximation, which takes both the first and second
derivative into account. Used 31 bins instead of 100 for a clearer
picture.

longer than others, it was important to measure how much


the slope was changing in order to recognize the movement
of the data. We used the forward difference formula
! = + () to take the first derivative of
each bin. The forward difference formula is one of three
ways to find the finite difference. Since it is impossible to
take the derivative of a point using the normal derivative
rules, the finite difference must be used. This approach uses
the slopes of the points around the area of interest in order
to estimate the slope of the particular point. With this
information, w could see average slope in each bin and find
the linear approximation of the data. However, due to the
curvature of the graph, the second derivative was needed to
find the best quadratic approximation, as that would better
fit the data. Using the central difference formula,
!

FIG. 1. Black dots represent averages point in each bin. Made


100 bins, each representing 0.01 in time.

! = + ( ) the
algorithm
!
!
created a cohesive connection between the respective
slopes that took both the first and second derivative into
account. The resulting information allowed us to elongate
certain parts of the regression line based on the changes in
slope, effectively fitting the curve, as shown in FIG. 2.
By implementing an error analysis on the difference
between the approximation and the actual line fitting the
curve, we were able to determine the accuracy of the
regression line or contour fit. The actual line was found
using one-dimensional interpolation. A low error would be
indicative of a very accurate contour fit. The analysis also
displayed the optimal number of bins that would best
represent the data. [4] This particular approach to creating a
regression line is based on Weierstrass Theorem, which
states that there exists a sequence of polynomials, Pn such
that as n , Pn(x) f(x) or the original function. After
figuring out a pattern of movement, the algorithm could

SEIZURE PREVENTION THROUGH CONTOUR FITTING

RMP 2015

III. EXPERIMENTAL RESULTS

FIG. 4. Is a representation of Weierstrass Theorem. The pink


flower was created by systematically plotting 628 points. The
flower was recreated with a multivariable system of equations, X
=1 + 0.3cos(10t)cos(t) and Y = 1 + 0.3cos(10t)sin(t). We defined t
between the domain of 0 and 10, and interpolated 1000 points.
FIG. 3. Purple dots represent the estimated values of the sample
points. 31 bins were kept for the purpose of simplicity.

extrapolate the curve and estimate where it would go.


The precision of the extrapolation method was measured
using a second error analysis. For this particular analysis,
we created a matrix of sample points that were taken
between each of the bins. Utilizing the known times of each
data point, the algorithm estimated the respective position
of each point on the approximated line and plotted the
resulting value, illustrated in FIG. 3. This approximation
took the both the first and second derivative into account.
Then, by using a variation of the nearest neighbor tracking
algorithm, we calculated the difference between the
estimated value and the correct value. To do this, the
algorithm found the nearest time value to the time value of
a particular sample point. The point associated with the
nearest time value was then found and the distance between
the actual data point and the sample data point was
calculated to find the error. After perfecting this method,
we decided to vary the number of bins created to determine
if there was a correlation between how copious the data set
was sampled and the error of our estimation. The result of
this analysis was quantifiable data that showed how
accurately we could predict the next brain state, or data
point by using the regression line.

(a)

(b)

The Weierstrass Theorem was tested with toy data and


proved to be successful for any data set. In FIG. 4., the
flower contour in pink was created by systematically
plotting a predetermined matrix of coordinates. Using the
theorem, we devised a multivariable system of equations
that recreated the flower when graphed. The periodicity of
the flower contour suggested that a trigonometric function
would best fit the image. However, since trigonometric
functions have an arbitrary degree, the equations
manipulated sing(x) and cos(x) in order to formulate the fit.
The equation createed two variables, X and Y, that were
each a function of time, t. By evaluating X and Y at
specified intervals of t, and then plotting the resulting
coordinate, we recreated the flower. Similarly, this theory
was applied to the EEG data during the first error analysis.
The average error between the contour fit and the
interpolated fit was found to be 0.0000825, meaning that
the regression line accurately captured the trend of the data.
The optimal number of bins was found to be eighty. These
results substantiated the use of the contour line for the rest
of the calculations.
The results for the second error analysis are shown in
FIG.5. The graph represents the error of the approximation
with respect to the time value of the relative point. Graph
(a) shows the error when only five bins are used to

(c)

FIG. 5. Shows the second error analysis that was conducted. Graph (a) was created using 5 bins and has a max error of
0.014. Graph (b) has 31 bins and a max error of 0.018. Graph (c) has 100 bins and has the smallest error of 0.012.

SEIZURE PREVENTION THROUGH CONTOUR FITTING

extrapolate the data. The maximum error for this data is


0.014. Similarly, graph (c) shows the error when one
hundred averages are taken throughout the data. While this
plot is characteristically very noisy due to the larger
number of sample points because of more bins, the
maximum error is still only 0.012. The minimal
discrepancy between using five bins versus one hundred
bins proved that how abundantly the data was sampled is
negligible when predicting the next brain state. This was
further supported by the fact that the maximum error for
using thirty one bins, graph (b), is higher than using only
five bins. It was speculated that the more the data was
sampled, the lower the error of the approximation.
However, as depicted by the results, this was not case,
thereby proving that the number of bins does not matter.
The importance of this result was immense as reducing the
total number of bins can greatly reduce the runtime of the
algorithm, thereby lowering the delay between the real-time
signals and the output of the algorithm. Additionally, the
low error legitimized the methods we used in this process.
We already knew that this preprocessed data represented a
patients brain signals during a seizure. Since brain signals
tend to form a more organized and pattern-like plot during a
seizure, the estimation of a sample point should be very
accurate as there is a distinctive trend to the data. As a
result, a low error signal would be indicative of the seizure
state. However, before a seizure, the chaotic characteristic
of the graph should result in a relatively large error signal,
as the randomness of the plot would make it difficult to
approximate the position of the next brain signal.
Therefore, the low error signal supported the data,
validating the methods the algorithm uses.

IV. CONCLUSION
Our algorithm used the Weierstrass Theorem to devise a
quadratic approximation that accurately contour fitted the
data. By using interpolation, we were able to reduce the
noise of the graph and extricate the important information.
The first and second derivative allowed us to plot a
regression line that took both the slope and the changes in
slope into account. We were able to calculate the precision
with which our algorithm can extrapolate the data using the
nearest neighbor tracking algorithm and by creating sample

[1] S. Schachter, P. Shafer, and J. Sirven, How Serious


Are Seizures?, Epilepsy Foundation, Jan-2014.
[2] C. P. Panayiotopoulos, Optimal Use of the EEG in the
Diagnosis and Management of Epilepsies, in The
epilepsies: seizures, syndromes and management:
based on the ILAE classifications and practice
parameter guidelines, Oxfordshire, UK: Bladon
Medical Publishing, 2005.

RMP 2015

points between the bins. Our results proved that there was
no correlation between how often we sampled the data and
the accuracy of our prediction of the next brain signal. The
low error signal further validated the algorithm as it
confirmed that we are able to accurately estimate the next
point. In comparison to other methods, our algorithm has
the advantage of being able to analyze the brain signals in
real time by defining each signal as a three-dimensional
point. In addition, the program can be easily manipulated to
devise regression lines of a higher degree by simply
tweaking the existing definitions. With this new approach,
doctors could now study only the error signals the
algorithm produces and make a decision based on the value
of the error. This can greatly increase the probability of
identifying the seizure transition period and preventing a
seizure minutes before it occurs. In the future, we could
create our own functions that could increase the speed of
the algorithm. We could also implement machine learning
so that doctors no longer have to stare continuously at the
signals, but rather a computer could perform the same task.
Finally, the next step for the algorithm would be to
implement a variation of the SFS algorithm to not only
predict the seizure, but also the intensity of the seizure. This
would allow doctors to supply patient-specific treatments
based on the severity of the oncoming seizure.

ACKNOWLEDGEMENTS
I would first like to thank Mr. Abhejit Rajagopal and Mr.
Nithin Govindarajan for guiding me through this project.
They not only taught me a higher level of coding but also
introduced me to the math and theory behind what we were
doing. Next, I want to thank my TA, Raymond Valdes as
well as Dr. Lina Kim for showing me the fundamentals of
research and for editing my paper, poster and presentation
to make them the best that they could be. Lastly, I want to
thank my fellow RMP students for their support and
encouragement during these six weeks, especially Samara
Shaz for her help during the initial stages of the project,
Gitanjali Multani for her help throughout the project, and
Esha Gajjar, Ashlee Brown- Hillard, Ravel Leal, Maria
Calderon, and Olivia Ettlin for being amazing friends.
[3] R. Zhang, Height recovery from intensity gradient,
Proceedings of IEEE Conference on Computer Vision
and Pattern Recognition CVPR-94, pp. 508513.
[4] D. Eberly, Derivative Approximation by Finite
Differences, http://www.geometrictools.com/, 2001. .

Vous aimerez peut-être aussi