You are on page 1of 49

Real-Time Processing of EEG Signals for Mobile Detection of Seizures

Colm Seale
B.E. Electronic & Computer Engineering Project Report

EE426

Supervisor: Prof. Edward Jones

Co-assessor: Dr. Gearóid Ó ’ Laighin

March 2012

Page |i

Abstract
The following is a Project Thesis titled “Real-Time Processing of EEG Signals for Mobile Detection of Seizures“. Discussed in the report are the main aims and objectives of the project and the results achieved and conclusions drawn throughout the course of the project. The overall aim of the project is to design an algorithm that will read signal data from an EEG source and process this data to determine if the person is undergoing an epileptic seizure. This program will be ported to mobile devices. The aim is to find a balance between the performance of the algorithm employed in detecting seizures and the amount of processing required to calculate the presence of seizure. The project also aims to investigate the effect of compression of EEG signal data on the overall effectiveness of the seizure detection algorithm. This report will detail some of the methods and procedures taken for developing algorithms, what milestones were reached and results from testing and development. The results demonstrate the feasibility of implementing seizure detection on a smart phone platform, and furthermore, significant compression of the EEG signal is possible without loss of diagnostic data. Thus, the outcome of the project supports the possibility of significantly enhancing the range of technology available to support mobile healthcare.

P a g e | ii

Declaration of Originality
I declare that this thesis is my original work except where stated.

Date: ___________________________________

Signature: ___________________________________

P a g e | iii

Acknowledgements
The author would like to acknowledge the help and support I received throughout the project from my project supervisor Dr. Edward Jones. The author would also like to thank Gary Higgins for his input and Dr. Liam Kilmartin for his assistance at various points throughout the project. This project would not have been possible without the support of my fellow 4th EE/ECE classmates. Finally, the author would like to thank my parents for their continued support over the last 4 years.

................... 7 Data Sources ...................................... 20 3.......................................................................... Algorithm Development (MATLAB) .........5 3..........5 1.....7 4......................................................................................................P a g e | iv Table of Contents Abstract.................2 3...................1 2............ 19 Linear Discriminate Analysis: ..................................................................................................................................... i Declaration of Originality ...................6 2....................................................................................................................................................................................................................................................................................... 20 Mobile System Development ..............................................4 1............................................................. vii Equations ................................................................................................................................ 5 2................................................................................................................................................................................. 1 Aims ................................................................................... 2 Health and Safety Issues ...........................................1 Introduction ......... Background .................................................................................................................................4 3........................................................1 3.................... 4 Project Components ......................... 3 Thesis Outline .................................................................................................................................................................................................................................. 12 Algorithm Development .3 Project Hardware ...................................... 9 3............................................................................ 15 Pre-Processing ................................................................................................................... vii Glossary ................ 13 Classification in MATLAB ......................................................................................................... ii Acknowledgements ........................ 5 Project Software .......................... Project Introduction................................... iii Table of Figures....................................................................................................................................................................... vi Figures..................................................................6 Introduction ..... 1 Project Milestones ................................................................................... 2 Project Timeline ................................. 12 Algorithm Design ............................................................................................2 1..................................................1 1................................................................ 21 4............................................................................................ 19 Support Vector Machine:........................2 2...............3 1....................................................................................................................................................... 12 3. 21 ...................................... vi Tables .................. 17 Results.....................3 3................................................ 1 1.................................... viii 1....................................................................................... Conclusions ............................................................................................................................................................................................................

..............................3 5..................................... 39 A.................................................. 35 References ........3 Conclusion....................... Java Development................................................................................................................................................................. 30 Method of Study ..........2 5....................... 34 6............................. Discussion ..........................................................................................................4 Introduction ............................. 34 6......6 3........2 4.........................3 3..........................1 Introduction ..3 Wildfire Bluetooth Code Problem ..... 22 Emotiv EPOC Development ............................................................................................................................................................ 29 Compression of EEG Data .................................................................................... 40 ................................................................................................................ 37 Appendix ...............................................................................................................................7 5..................................................... 21 Programs ................................. 32 Conclusions .......................................................................... 26 Results......................................................................................................................1 HTC Wildfire Specifications: ...................... 34 6.......................................................................5 3......... 30 Results.......................................................... 33 6....................................................................................................................................................... 28 Conclusions .......................................................... 39 A........................................................................................................................................ 39 A.........................................................................................................Page |v 4................................. 30 5.............................................................................................................................1 5........2 MATLAB Filter Code...........2 Discussion .....

..................................................................................................................................................................................... 17 Figure 3-6: A visual example of a pre-processing algorithm for raw EEG signals for seizure .............................. Application requesting Bluetooth [left]................ 12 Figure 3-2: Graphs showing EEG Ictal signal [top]...... Classifying data [right] ....................................................... 19 Figure 4-1: Flowchart showing high-level design ....................P a g e | vi Table of Figures Figures Figure 1-1: Gantt chart of Project Timeline ....................................... 29 Figure 5-1: Comparison of EEG Signal at varying CR ........................ 15 Figure 3-4: LDA Classifier Performance of Raw Signal compared to Pre-Processed Signal ....................... Compression Ratio using SPIHT Compression ......................................................................................................................................................................................... Relative Band Ratios [bottom] ................. 28 Figure 4-5: PowerTutor measurements of Seizure Detection App..................................................... 3 Figure 2-1: MATLAB processing EEG data.................................... 31 Figure 5-2: Pseudo-Code for calculation of CR ..... 18 Figure 3-8: Frequency Response of MATLAB Band-Pass Filter ........................................................................................ Shannon [centre] and Kullback-Leibler [second from bottom] entropies. 24 Figure 4-2: Flowchart of Real-Time System Loop ............. Filtered EEG (Bottom) ....... 24 Figure 4-3: Application Screen Captures........................................................................................................ 18 Figure 3-7: Raw EEG (Top) vs................................................................................................ 31 Figure 5-3: Percentage Root-Mean-Squared Deviation vs............................................................................. 10 Figure 3-1: Block Diagram of Seizure Algorithm . 26 Figure 4-4: Results output of the Naïve-Bayes Classifier using the evaluateModel function from WEKA libraries ..................... 39 .............. 32 Figure A-1: Code used to design MATLAB Filter Coefficients ...... Scanning for devices [centre].............................................................................. 17 Figure 3-5: SVM Classifier Performance results of Raw Signal compared to Pre-Processed ...................... power spectra [second from top]............................... 8 Figure 2-2: Image demonstrating the different areas in an Ictal signal file taken from the Freiburg Database...... 13 Figure 3-3: Visual representation of EEG data for the raw signal and Hjorth parameters............. Power usage over a period of 10 seconds [left] and Power usage as a percentage of whole application [left].......................................................................................

........................................................................................................................... 39 Equations Activity ....................................................... 22 ..................... 33 Table A-1: Specifications of HTC Wildfire.......... CR ......................... 14 Sensitivity ........................... 20 Table 5-1: Performance of LDA Classifier vs........................................................................................................................................................................................................ 32 Table 5-2: Performance of SVM Classifier vs.......................................................................................................................................................................... 11 Table 3-1: Results of LDA Classifier on Original Signals ............................................. 16 Correct Rate ...........................................................................................................................................P a g e | vii Tables Table 2-1: Comparison of two available consumer EEG Hardware options ................... 14 Complexity ............. .......................................................................................... 14 Mobility ....................................... 21 Derivative of a Signal .......................................................................... 16 Specificity ....................................................... 19 Table 3-2: Results of LDA Classifier on Original Signal. CR .......... 6 Table 2-2: Comparison of EEG Data Sources .............................................................................................................................................. 16 Standard Deviation .........................................................................................................................................................................................................................................................................................................................

P a g e | viii Glossary API – Application programming Interface CR – Compression Ratio CSV – Comma Separated Values EEG – Electroencephalography JNA – Java Native Access JNI – Java Native Interface IDE – Integrated Development Environment LDA – Linear Discriminate Analysis PRD – Percentage Root mean Squared Distortion SDK – Software Development Kit SPIHT – Set Partitioning in Hierarchical Trees SVM – Support Vector Machine .

Project Introduction 1. 1. it may be necessary to “emulate” a direct connection between the headset and the phone).com) communicating with an Android mobile phone acting as a network “hub” (because of restrictions imposed by the development environment. publicly-available databases of EEG signals will be used.emotiv. The project will also aim to investigate the effects of signal compression on seizure detection performance. this will involve DSP algorithm development (in MATLAB) in order to build a system for analysis and detection of seizures. there is growing interest in the development of “wearable” or “ambulatory” systems for monitoring and analyzing various biological signals. A commonly-used framework for the implementation of such systems (particularly where more than one sensor may be employed) is a so-called “Body Area Network” (BAN). there is significant interest in the development of technology that can help to detect medical problems at an early stage. where successful (and lower cost) intervention is more likely. .Page |1 1. for unrestricted movement by the wearer). A key requirement of such systems is that they operate with low power to permit extended battery life. Secondly. In particular. For test and development purposes. this functionality is beyond the scope of this project). using an off-the-shelf Emotiv EEG Headset (http://www.1 Background With the increasing cost and demands made of healthcare infrastructure and services. Firstly.2 Aims This project will investigate the development and implementation of a number of signal processing algorithms for epileptic seizure detection based on signal processing of Electroencephalogram (EEG) signals. the project will aim towards implementation of some of the DSP algorithms in a simulated BAN. this will be restricted to use with normal healthy subjects. which consists of a network hub. Where real-time testing is being carried out using software implemented on the Android platform. particularly the University of Freiburg EEG database [1]. Signal and data processing may be divided between the smart sensors and the hub. to which one or more “smart sensors” are connected (ideally wirelessly. depending on how computational power is distributed in the BAN (Body Area Networks typically also incorporate coding and encryption for data privacy. in the mobile digital health environment. however.

using Freiburg EEG database. . Average  Translation of feature extraction and classification algorithms into C or Java. Excellent   Investigation of the impact of compression on seizure detection performance. Very Good  Implementation of real-time or near real-time seizure detection on Android platform.  Characterization of computational complexity of feature extraction on Android platform.  Development of a basic Android application to gain familiarity with software development on this platform. Good  Development of communications infrastructure (indirect via laptop) to enable communication between Emotiv headset and Android mobile phone.3 Pass  Project Milestones Implementation of feature extraction and classification algorithms for seizure detection (in MATLAB). and will not be used other than in accordance with the manufacturer’s recommendations.4 Health and Safety Issues There are no health and safety issues. and validation of performance. The Emotiv EEG headset is an approved part. Analysis of potential power savings to be gained through the use of compression. and validation using healthy test subject(s). 1.Page |2 1. The project will largely involve software development on PC and Android platforms.

Page |3 1.5 Project Timeline Figure 1-1: Gantt chart of Project Timeline .

The first chapter outlines the major system components used in the design and development for each of the following chapters. development and testing processes of their respective objectives. This chapter provides a detailed background into each major non-standard hardware and software project components. The fifth chapter includes a small scale study on the effects of Compression of EEG. Project Components. Following this. a discussion and a conclusion.Page |4 1. Each chapter will conclude with the results obtained throughout the course of the chapter’s development and conclude with a brief summary. and will provide a critique of the project itself including areas such as Project Management etc. These chapters begin by outlining the necessary background and major aims for the chapter. .6 Thesis Outline The main text of this thesis is split into 4 main chapters. Mobile System Development and Investigation of Compression on EEG. these chapters will focus on the design. The following two main chapters (3-4) will detail the design and development of the seizure detection algorithm on PC and Smartphone. Algorithm Development (MATLAB). The final discussion and conclusion of the main text will bring together the results from the 3 main chapters and draw conclusions whilst outlining areas for future research.

The Emotiv Headset is a peripheral originally designed for gaming purposes by detecting conscious thought. Therefore in order to capture real-time data and process this data on a mobile device. the Emotiv EPOC headset has some limitations which would affect how this project progressed.1 Project Hardware Emotiv EPOC The Emotiv EPOC is a high resolution. due to the time-limited nature of this project. neuro-signal acquisition and processing wireless neuro headset. the method for transferring real data from the Emotiv EEG headset is as follows: . The headset documentation includes programs written in C++ which allows the user to Log the preprocessed EEG data from the headset. only a partial solution was found.Page |5 2. a method had to be devised of transferring the raw data over wireless connection to the handheld. The Headset features include:     14 saline sensors which are places along the scalp in order to read signals from different areas of the brain. Numerous approaches were investigated towards this. Project Components 2. However. details on which are discussed below. Also included was a JNA Wrapper (Java Native Access) program which would allow users to write Java applications to access this EEG data. This “Wrapper” works by allowing Java programs to access native DLL libraries on a machine while sacrificing the program portability that Java offers. It can also be used to collect raw EEG data from users. The Emotiv EPOC headset is only compatible with Windows PC and the EPOC Headset itself is not programmable. emotions and head rotation. but this approach encountered issues which will be discussed later in this thesis. Gyroscopes for head rotation and tilt Bluetooth connection to PC Software Suites which allow the connection to each sensor to be tested and the raw EEG can be monitored from a test bench program. This particular headset provides a cheap and affordable platform for portable wireless capture of EEG data. At the close of work on this project.

based off the Linux Kernel.  EEG features are extracted from each of these frames of data and classified as either non-Ictal or Ictal frames.  The Java program is manually run afterwards. and transfers this data to phone over Bluetooth. It is a modified version of the C++ provided in the support documentation provided by Emotiv Systems. Android OS also provides hardware support for Bluetooth which will the method of choice for establishing wireless connections between EEG Source and the . or JNI (Java Native Interface. and buffers this data into window frames with no overlaps. Other methods of transferring the data included the creation of a C++ to Java client-server socket connection. Development of Android Applications is generally through Java using Google developed java libraries. an alternative to JNA) which would also allow the java program to directly access the native DLL libraries in order to directly connect with the headset. be a more desirable and more practical solution. This data is saved to a CSV (Comma Separated Values) file which is placed in a common directory between the C++ and Java programs.Page |6  A C++ program is run on PC which reads data from the connected Emotiv EPOC Headset. 2008. This would in the long-term. A comparison of the Emotiv EPOC Headset and the Android/iOS compatible XWave Headset is given in Table 2-1. Another option available is to use a headset with compatibility with the Android mobile devices. As it is open-source. all the software and documentation required to build the desired application is free and therefore it is the platform of choice for the development lifecycle of this project. Android is available under an open-source license since October 21st. which reads the data from the CSV file. Device Emotiv EPOC XWave Cost $300 $90 Electrodes 14 1 SDK Yes Yes Android No Yes iPhone No Yes Table 2-1: Comparison of two available consumer EEG Hardware options Android Mobile Device The Android mobile platform is an open source software platform developed by Google.

2 Project Software MATLAB MATLAB (shown running on windows 7 in Figure 2-1) is a high level technical computing language and graphical interface used for intensive mathematically computations. The software also provides various toolboxes designed for use with specific parts of this project. . It provides users with various tools for data analysis and visualization. Several devices can be connected to one Bluetooth server device. enabling the creation of Personal Area Networks (PANs).0 Bluetooth is an open wireless technology standard for transmitting data over short distances between Bluetooth enabled devices. The hardware model of Android device used through this project was the HTC Wildfire Smartphone whose specs relevant to this project are detailed in Appendices A1. which opens up the possibility for using a device such as Android Mobile Devices to act as the central hub in order to create the Body Area Network (BAN) which would allow a user to monitor biofeedback from various sensors.Page |7 Mobile Device. Bluetooth v3. and will be the primary tool used in this project for accessing the effectiveness and sensitivity of any developed algorithms. which are further detailed below. It is designed to be more efficient and more accurate than typical programming languages like C++ and Java. which is beyond adequate for the purposes of this project. Bluetooth v3.0 supports up to 24 Mbit/sec theoretically. Programming of the Android device was carried out in the Eclipse IDE with the Android SDK Plug-in installed. The Eclipse IDE provides an Android Virtual Device which allows limited functionality for debugging Android programs without requiring the use of a physical Android device. 2.

It includes tools for analyzing in time and frequency domains.Bayes Linear Discriminate Classifier (LDA) which was another investigated algorithm used to classify frames of data to their individual Ictal and Non-Ictal states.Page |8 Figure 2-1: MATLAB processing EEG data Signal Processing Toolbox: The Signal Processing toolbox provides tools for analyzing and developing algorithms for digital signal processing. The signal processing toolbox was used for design of FIR filters for this project. Bioinformatics Toolbox: The Bioinformatics Toolbox includes SVM (Support Vector Machine) which was one algorithm used to classify frames of data to their individual Ictal and Non-Ictal states. data mining and data processing jar libraries developed by the University of Waikato (dubbed WEKA Libraries) were employed to the program in order to provide the necessary tools to continue development. computation of FFTs etc. The algorithms can either be applied directly to a dataset or called from your own Java code. WEKA is a collection of machine learning algorithms for data mining tasks. WEKA contains tools . WEKA In order to develop classifiers in Java. Statistics Toolbox: The Statistics Toolbox includes a simple Naïve.

BlueCove API BlueCove is a Java library which provides an interface for java programs with Bluetooth stacks found in Windows. only the first 25% of bits are retained. SPIHT Compression is a form of “lossy” compression. SPIHT Compression For the latter part of the project.Page |9 for data pre-processing. The results are then compared with that of the original signal (see Section 9: Compression on EEG Signals). The data was taken from intracranial EEG recordings conducted by the Epilepsy Center of the University Hospital of Freiburg. i. It is also well-suited for developing new machine learning schemes. Compression is then carried about by simply truncating the bit sequence by the desired compression ratio (CR) and retaining the most important bit sequence. classification. investigation was carried out into the effect that compression algorithms on the quality of the results obtained from the classifier models. The strict test .e. SPIHT Compression of a signal involves splitting a signal up into window frames. This converts a frame of samples to a sequence of bits. and calculating the Discrete Wavelet Transform (DWT) at each window. WEKA Linear Classifiers are employed in both the PC and Android Java programs for classification of seizure data. Compression will be carried out using the ‘Set Partitioning in Hierarchical Trees’ (SPIHT) Algorithm.3 Data Sources Freiburg Seizure Database The Freiburg database is a collection of EEG recordings from 21 patients suffering from ‘medically intractable focal epilepsy. association rules. and visualization. First the signal is compressed to a desired compression ratio. WEKA is open source software issued under the GNU General Public License [2]. a certain amount of data is lost in the compression process. These bits are stored in a vector and organized in order of most important bits first. before entering the preprocessing and feature extraction phases. and compares the output of the classifier to that of the original signal. WEKA provides full documentation and support online. 2. Following this the compressed undergoes decompression. clustering. For example. Mac OS and other operating systems. regression. This report investigates the Percentage Root Mean Squared Distortion (PRD) of a signal at different CR values. for a compression ratio of 4:1.

Using a modified version of C++ code provided in the documentation for the EPOC Headset. but to investigate the possibility of being able to use the processing power of modern Smartphone technology to detect seizures. It is important to note that for this project. ‘Icital’ (Seizure EEG) and ‘Non-Icital’ (NonSeizure EEG). The records are saved as ‘ASC’ files. EEG readings are recorded from the headset at a rate of 128Hz and save these recordings in CSV format. with an overlay demonstrating which section of data is Ictal or Non-Ictal. Figure 2-2: Image demonstrating the different areas in an Ictal signal file taken from the Freiburg Database. The recordings are usually between 30-seconds to a minute long where the user is in a relaxed state. Live EEG Data Live EEG Data for this project was recorded from the Emotiv EPOC headset mentioned earlier in this paper. the aim was not to create an application which would be ready for use by a patient.P a g e | 10 environment which this data was recorded ensures that the signals collected in the EEG database have high signal-to-noise ratios and few artifacts. The signal data itself into 2 different class groups. The data itself was captured at a rate of 256Hz and quantized to 16bits and has not undergone any sort of pre-processing. . Therefore. The recordings are split into 2 classes:   Ictal: These files are 1 hour long containing epileptic seizures and at least 50 minutes of pre-Ictal data. Figure 2-2 is a signal from an Ictal class data file from the Freiburg Database. and each file consists of a 1dimensional array of data representing data recorded in mV from one EEG channel. Inter-Ictal: Data files consisting of 24 hours worth of Non-Ictal data. This was to reduce the effect that artifacts would have on the seizure detection algorithm.

Table 2-2 demonstrates the important differences between the data collected locally from the Emotiv Headset and data gathered from the Freiburg database. as it is only possible to validate the ability of the software to correctly detect Non-Ictal data. For health and safety reasons outlined earlier.P a g e | 11 this report focuses on the ability of the Smartphone to classify seizure data in or close to real time. Freiburg Database Sampled at 256Hz 16 bit resolution Invasive No preprocessing Features Ictal data Table 2-2: Comparison of EEG Data Sources Emotiv EPOC Sampled at 128Hz 16 bit resolution Non-Invasive Preprocessed No Ictal data . This is a serious limitation in the validation of the software’s performance. no live seizure data was captured from epileptic patients using the EEG Headset.

2 Algorithm Design The intention during this section of the project was to design the simplest system possible for initial Android development and iteratively increase the complexity and computational cost of the system to find the best balance of Algorithm Complexity vs.. what classification algorithms were investigated. and Y0 … Yn represent features extracted from window frames of the preprocessed signal R. X X(n) Band-Pass Filter R(n) Y0(m). Unlike C++. System Performance. the Java programming language is poorly optimized for Digital Signal Processing. Java does not allow for lower level management of memory and pointers in order to make the code more efficient. Algorithm Development (MATLAB) 3. MATLAB is a high level computing language. . Discussed in this chapter are what parameters and features of EEG signals were used in the classification of seizure activity. X(n) represents the original signal. with the intention of carrying this algorithm forward through to development of the Android Application. In order to port these to java. individual functions would have to be written in java for each MATLAB function used in the ported algorithm. Also.P a g e | 12 3. Y1(m) . R(n) represents the preprocessed signal. Figure 31 is a sample block diagram of how the system was expected to work at a high level. which includes toolboxes for dealing with a wide array of mathematical functions. Yn(m) Feature Extraction Classify featrues Figure 3-1: Block Diagram of Seizure Algorithm Throughout the design it was important to keep in mind that direct porting of code from MATLAB to Java is impossible.. This is because java is a high level programming language in itself.1 Introduction This section details the design and implementation of a preliminary classification algorithm in MATLAB. how the algorithms respective performance was measured and how the respective algorithm performance was improved relating to each classification algorithm. 3.

it was apparent the basis for the simple seizure detection algorithms would be to calculate the Hjorth Parameters [4]. . power spectra [second from top]. However.3 Algorithm Development Initial development of algorithms began on one file featuring Ictal data taken from the Freiburg database. Shannon [centre] and Kullback-Leibler [second from bottom] entropies. Figure 3-2: Graphs showing EEG Ictal signal [top]. Efforts were made to look at alternative options for calculating possible seizure activity with less computational cost and complexity. 3. Relative Band Ratios [bottom].P a g e | 13 This became important when attempting to choose the features which would be extracted in order to classify EEG signals. This data was loaded into MATLAB and tested on code to extract a number of different features. some of these calculations are rather complex to port over to java code. calculating the FFT of a windowed signal is much more time consuming and processor intensive than calculating standard deviation. It also calculates the relative band ratio (RIR). For example. The original code calculates the Windowed Fourier Transform at a frame size of 1024 samples per frame with no window overlap and then calculates and plots the power spectra and the Shannon and Kullback-Leibler (relative) entropies. [3] The calculations taken and plotted over patient seizure data in order to get a visual representation for the changes that occur in these EEG features during the onset of seizure as shown in Figure 3-2. Research conducted in the paper ‘Epileptic Seizure Detection: A Non-Linear Viewpoint’ and its examination of time-dependant techniques of EEG analysis.

Since the calculation of Hjorth parameters is based on variance. . demonstrating a large spike in Activity while conversely showing a drop in Complexity to almost zero for the duration of the Ictal period. The second parameter is an estimate of the mean frequency and is called the ‘MOBILITY’. Mobility ( ) and Complexity ( ) and plot these values to graphs.e. and represents the variance of the first derivative of signal x. The first parameter ‘ACTIVITY’ is a measure of the mean power representing the activity of the signal. and represents the variance of the second derivative of signal x. the values for Activity and Complexity were calculated as per the formulae above. However. The discrete time formulas for the calculation of these parameters are on the following page.P a g e | 14 Using the code described above as a base. 4 seconds of data) samples were originally used to form the feature vectors from which the values from Activity and Complexity would be calculated. Visually these are solid indicators of seizure activity under test conditions. There was no overlap between each individual frame. The last parameter. ‘COMPLEXITY’ gives an estimate of the bandwidth of the signal. and thus this feature was not used when classifying the signal. the computational cost of this method and its complexity is considered low in comparison to other methods[5][6]. the Mobility of the signal does not show a definite change between Seizure and Non-Seizure states. The resulting visual representations demonstrated in Figure 3-3 show clear distinguishing features during Ictal periods. For each frame of data. Activity ( ). Activity: 3-1 Mobility: 3-2 Complexity: 3-3 Where represents the variance of the signal x. M files was developed to calculate the Hjorth Parameters. Window frames of 1024 (i.

Analysis of the 2 classification algorithms was carried out in MATLAB by training the linear and SVM classifier models on identical sets of training data. it was decided to conduct research into two different classification algorithms:   Linear Discriminate Analysis Support Vector Machines. . trained and evaluated through cross-validation of data with a dataset split of 10/90 (10% test. as well as the equivalent group data indicated if each frame represents either Ictal or Non-Ictal data.4 Classification in MATLAB Following supervisor advice. The results of the MATLAB Classifiers can be viewed below. Comparison tests for classifiers were carried out with raw data features vs. Figure 3-3: Visual representation of EEG data for the raw signal and Hjorth parameters 3. Training data consisted of the precalculated Activity and Complexity. classifiers were created. preprocessed feature extraction (Discussed later in this report). 90% training data).P a g e | 15 Thus it was assumed at this point in the project that the Hjorth Parameters would be the easiest to implement in Java code and later convert to the Android platform. and thus will provide the basic benchmark for the system. Utilizing the Statistics and Bioinformatics Toolbox in MATLAB.

there is often a trade-off between the Sensitivity and Specificity. Classifier performance in MATLAB is analyzed through the classperf function.e. 3-4 3-5 3-6 . ‘CorrectRate’ is the percentage value of frames within a sample which were correctly classified when compared to previously known results (i. the percentage of true positives and true negatives of classified samples). three values are taken into account. This function compares the results of the classifier on a set of test data with the real group labels of the test data.P a g e | 16 When evaluating the performance of a given Classifier. Sensitivity relates to the test's ability to identify positive results. Specificity relates to the ability of the classifier to identify negative results. When attempting to create classifier models and choose between them.

5 Pre-Processing Investigation was carried out to measure the effect of introducing pre-processing to the raw EEG data before extracting features for seizure detection. Blanke et al.P a g e | 17 Figure 3-4: LDA Classifier Performance results of Raw Signal compared to Pre-Processed Signal. From A digital band pass filter from 2Hz to 20Hz was implemented in MATLAB before carrying out the extraction and classification programs to remove noise and artifacts (More detail in section titled ‘MATLAB . A sample DSP algorithm from the aforementioned paper is featured in Figure 3-6. The inclusion of a band-pass filter increases the Classifiers performance by approx 6%. Figure 3-5: SVM Classifier Performance results of Raw Signal compared to Pre-Processed Signal.5Hz [7]. (2000) indicated that the dominant Ictal frequencies exist between the ranges of 3Hz to 8. The introduction of a band-pass filter increases the Correct Rate by 2%. 3. however the increase in sensitivity has lead to a decline in specificity. a common trade off when designing classification algorithms.

and such reliability being demonstrated using these features should not be expected in real-world applications. the project aims only to test the theoretical possibility of implementing seizure detection on mobile phones. there are many more factors to be taken into account which impede the quality of the data received and the performance of the classification algorithms. Figure 3-7: Raw EEG (Top) vs. as documented in Figure 3-4 and 3-5 above.7 gives a visual example of the change in the raw data after filtering. All 2010[8] It should be noted here that all data being tested to date was sourced from 1 patient under strict test conditions which minimized the effect of artifacts and noise in the EEG signals. When approaching the problem of capturing live EEG data from a mobile patient. Figure 3-6: A visual example of a pre-processing algorithm for raw EEG signals for seizure detection taken from Cecchin et. Filtered EEG (Bottom) . The results demonstrated a considerable increase in the specificity and sensitivity of the LDA Classifier.P a g e | 18 Filters’). Figure 3. For the moment.

The tables feature 3 the performance of the algorithms on 3 Ictal datasets from the Freiburg Database and 2 Non-Ictal Datasets.7988 0.011 0.2.9811 Table 3-1: Results of LDA Classifier on Original Signals .9855 0. The code listing for the filter can be found at Appendix A. Linear Discriminate Analysis: Dataset: Correct Rate Sensitivity Specificity 0015 (Ictal) 0.7143 0017 0.5 0021 (Ictal) 0. (The code for the filter can be found in the ‘filterB. The MATLAB fir1 function creates a digital filter using the window method.6 Results Tables 3-1 and 3-2 contain results from tests run on the classifier models with data from the Freiburg Database.9867 0. the dominant Ictal frequencies are believed to reside between the 2 and 20Hz region.98 0.9955 0. A simple filter was designed using MATLAB’s fir1 function of order 50 with a band-pass between 2 and 20Hz in order to isolate these signal bands.P a g e | 19 MATLAB Filter Design As mentioned earlier in this report.9911 0.6129 0018 (Ictal) 0.9922 0. The filter was designed based on the following parameters.9911 0022 0.m’ function file found on the disc provided with this report).998 0. The frequency response for the filter is plotted in Figure 3-8 using MATLAB's freqz function.9999 0. Figure 3-8: Frequency Response of MATLAB Band-Pass Filter 3.

whilst also affecting the sensitivity and specificity of each algorithm to different extents.9575 0.5818 0. It should be noted here that the EEG signals used for this part of the report were sourced from the intracranial data of one individual patient in the database featuring little to no artifacts. the effect compression has on data classification is analyzed later in this paper and includes the Support Vector Machine classifier model in its analysis. However. In turn this means that the data used to develop the algorithm was ‘ideal’ in nature and the resulting high classification rates should not be expected with signals that are more complex in nature. Preprocessing the signal before classification through a 2-20Hz band-pass filter increased the rate of correctly classified results by between 2-6%.5778 0021 (Ictal) 0. the LDA classifier was significantly better than the SVM Classifier.7 Conclusions The results for this section of the project demonstrate that overall.6726 0022 0.9121 0. Taking this knowledge forward into the Mobile Development part of the project.485 0 0.9355 0.9055 0. it was decided that the LDA classifier the Hjorth Parameter feature extraction would be implemented on the Android platform for the first iteration of the Android Application.778 0.9015 0017 0. and high signal-to-noise ratio.9113 0018 (Ictal) 0.4855 Table 3-2: Results of LDA Classifier on Original Signal 3.P a g e | 20 Support Vector Machine: Dataset: Correct Rate Sensitivity Specificity 0015 (Ictal) 0.6719 0 0. .

as well as a discussion on the use of Bluetooth and integrating the Emotiv EPOC into the mobile development. It was outside the scope of this project to develop an interactive UI for potential users to monitor their own EEG state. The overall aim of this part of the project was to determine if it is possible to implement a simple seizure detection algorithm on a mobile platform which operates in or close to real time. These results were identical to 10 decimal places. Standard Deviation: 4-1 . two equations which form the basis for calculating the Activity and Complexity of a signal.m files and replicate these codes in java. Areas of the project covered in this section are the application design. which should be more than adequate for the purposes of this project. 4. These calculations were later verified through comparison with MATLAB that these were desirable results.P a g e | 21 4.1 Introduction This section details the development process of the underlying java classification program which formed the basis for porting the application to the Android Mobile Platform. Also covered is the integration of WEKA Libraries into the classifier application at both the Java and Android levels. converting high-level Math Programming Language code to Java processes and deploying this code to the Android OS platform. This involved manually writing Java code which calculates basic values such as standard deviation and the derivative of a signal. and the issues thereof. Mobile System Development 4.2 Java Development The aim of this section of the project was simply to convert the code produced in MATLAB .

From the libraries provided by WEKA. Two important methods were created from within the model class in java. One method performed an evaluation of the classifiers performance. and its performance was evaluated by running it against another test set of data.P a g e | 22 Derivative of a Signal 4-2 4. Porting Classifier to Android Following the creation of a program which would run on PC.MODEL file. This allows for a classifier model to be trained and evaluated offline before the model is ported to the target android platform.MODEL file can then be ported to the Android device. a Naïve-Bayes linear classification algorithm was chosen and a classifier model trained and evaluated on sample data through cross validation. The app then ran classification on hard-coded data in order to verify the classification algorithm was functioning on the hardware. Development of the classification program on the Android platform required that some changes had to be made to the source WEKA libraries in order to make them compatible with . This is important functionality because the training of a classifier is the most processor intensive and most power-hungry part of developing classifier models. this program serializes and saves the trained java classifier object to a . This program opened and de-serialized the . The Android device simply does not have the required computational power to do this. The resulting trained model can be serialized and saved to a . This .MODEL file to the project directory. trained this model on the signal file and provided group data (the same data used to train the MATLAB classifiers). The other method was intended for end use by the Android application and classified an individual instance of data against the classifier model. where the java classifier can be de-serialized and used for classification of received signals. Once the model was created and evaluated. a simple Android program was developed.3 Programs Classifier Training Program (PC) The first program created was a simple program which loaded a signal file and created a instance of a Naïve-Bayes Classifier model.MODEL file provided by the PC program.

it was intended to create a connection between the Emotiv EPOC Headset and PC. and implement them in Java programs provided the correct version of the MRE is present on that system.MODEL file and then attempting to de-serialize this . both the offline classification training program and the classification application running on the Android target device must use identical jar libraries. The main aim was to merge the Client app with the classification program and allow the Server to send EEG data over a Bluetooth link every 4 seconds to allow the mobile platform to convert data close to real-time. the MRE would allow developers to create Java classes directly from the MATLAB IDE or command-line interface. attention shifted towards using the WEKA java libraries in order to implement a classifier on the Android platform. Bluetooth Client and Server Programs (Android and PC) The third and fourth programs created throughout this project are Bluetooth client and server programs which run on the Android Device and PC respectively. There was some time spent investigating if it was possible to implement the MRE (MATLAB Runtime Environment) on the Android Platform. This Android program was based off the Bluetooth Chat app provided by Google and a simple Bluetooth Chat to PC application sourced online [8]. At this point.P a g e | 23 the OS. Doing this required certain parts of the WEKA libraries to be stripped away [9]. The PC would also be used to buffer data from the headset (sampling at 128Hz) into frames of 1024 samples to be transmitted to the Android device every 8 seconds.model file on the target device. It is not possible to serialize a . In other words. . This was abandoned in favor of a simpler approach. Figure 4-1 demonstrates this intention visually. The full intention was to allow the PC to act as a ‘relay device’ to allow the Emotiv EPOC headset to transmit data to the Android device in real time.It should be noted here that the java program used to generate the classifier model offline should use an identical version of the WEKA library used by the Android OS. For a PC based OS. The java PC server was programmed through the BlueCove API Libraries. as they will not be compatible.MODEL file with one version of WEKA and de-serialize the file with another. Following the development of a Bluetooth ServerClient connection between PC and Android. This is to avoid issues which arise when serializing a .

The development of Bluetooth Server for java involved the inclusion of BlueCove API (mentioned in the chapter 2. as shown in Figure 4-2: Read Data from Buffer Extract Features Classify Data Wait for Buffer Figure 4-2: Flowchart of Real-Time System Loop This would require that the time taken for the total processing required for these 4 steps to be under 8 seconds. Bluetooth was chosen due because it is commonplace in devices which are used in short-distance communication and because it was readily available in the chosen hardware. . ‘System Overview’) which allows for development of Bluetooth (JSR-82 implementation) with Bluetooth enabled devices with the proper JRE version installed. it was decided that due to the time friendly nature of the original aim for the application (1 frame of data every 4/8 seconds) a simple control loop was determined to suffice. allowing the system to return to a wait state before the next frame of data is ready.P a g e | 24 Data transmitted at 128Hz Buffered at frames of 1024 EMOTIV EPOC PC ANDROID Figure 4-1: Flowchart showing high-level design When determining the suitable system architecture for the real-time Android application.

searches for Bluetooth devices when called by DeviceListActvity. Seizure Application The Android Application is made of 4 main classes.java This is the main Activity.java can be called. DeviceListActivity. each frame is parsed to a string with hard-coded delimiters separating each sample. program shuts down. Object input and output streams are then opened between server and client and the String is passed between programs at a fixed rate. Each of these classes can be view in full on the supplied CD. This information is purely for immediate programmer feedback. The Bluetooth Server was developed on top of an existing Bluetooth PC Server example online. On ‘yes’ this activity starts RemoteBluetoothService.java. and RemoteBluetoothService. The code also logs all results to Android LogCat for verification. As mentioned earlier. it is not expected for a Patient to need to monitor these values and creating a userfriendly GUI for the application is outside the scope of this project. Complexity and Ictal State to the user. To transmit the data. From this Activity. On startup. RemoteBluetoothService. the . If not. This server was modified to receive a connection from an Android client and begin transmitting stored data from the Freiburg Database at rates specified within the code. This service creates the Bluetooth Adapter. first checks to see if Bluetooth has been enabled on the device. a dialogue appears requesting user to turn on Bluetooth. These results would be displayed on screen for programmer verification. On a ‘No’ click. RemoteBluetooth.java This Activity creates a ListView widget overlay populated with Bluetooth device names and ID’s retrieved from RemoteBluetoothService. and connects to Bluetooth devices specified by DeviceListActivity.java This Android service is created on Activity startup and remains running until stopped by Activity or killed by Android OS.java can be stopped.java controls the main GUI interface for displaying current Activity.java and allows the user to specify what Bluetooth device they wish to connect to.P a g e | 25 The Bluetooth Client side of the application was built using Bluetooth Chat example provided by the Android SDK as a basis. RemoteBluetooth. The main design aim was to create an application which would classify EEG data in or close to real time. DeviceListActivity.

Application requesting Bluetooth [left]. This issue halted development on the application for around 3 weeks during the Christmas period.java This java class contains the Classifier model and creates the Attributes and Elements which are the WEKA libraries equivalent to Features and States. this required a direct connection between PC and the Emotiv EPOC over Bluetooth had to be established. Classifying data [right] Issues with HTC Wildfire: Working with the HTC Wildfire as the Mobile Device of choice proved problematic throughout for the beginning of the development of the Bluetooth application for Android. This class also includes a method for classifying data against the stored Classifier Model. The problem was eventually traced back to the following line of code. Scanning for devices [centre].5 Emotiv EPOC Development Developing the system to incorporate real-time classification of EEG data required a number of steps. the workaround for which is featured in Appendices A. The issue related to the device being able to see and pair with other Bluetooth devices.3.P a g e | 26 aim is to validate the possibility of a mobile seizure detection system with the Smartphone as the central processing hub. but unable to connect. WEKALDA. The next requirement of the system was to establish a method from which this signal could be . 3. Firstly. and values sensed from the Emotiv EPOC at a rate of 128Hz. Application Screenshots Figure 4-3: Application Screen Captures.

and buffers the array into blocks of 1024 samples. This presented a number of issues which will be discussed later. Due to Health and Safety limitations. Therefore EEG classification of Emotiv data against a model trained from the database is unreliable. including the Java Native Access (JNA) Wrapper provided with the system documentation and a C++ to Java Socket Client-Server. The JNA Wrapper has been used successfully with projects carried out on other systems [10] but proved ineffective here. The java server program could then be run. The Emotiv EPOC is not Android compatible therefore it is not possible to directly connect the Android Phone to the Emotiv EPOC through Bluetooth. is that the Emotiv signal has undergone preprocessing. These samples were then transmitted over Bluetooth connection to the Android device where classification could be carried out. This led to the decision to use a PC as a relay point as mentioned earlier. which reads the CSV file from the desktop and stores the values in an array. . As such. The simple C++ examples acquired from the Emotiv EPOC documentation were extended to log EEG data to a CSV file which was stored on the desktop. However. Two methods of connecting the C++ and Android applications on PC were investigated. The main issue is the incompatibility between Java (Android OS) and C++ (Emotiv EPOC). There were issues related to obtaining a true real-time connection between the Emotiv EPOC Headset and the Android phone. likewise the Java-C++ ClientServer Emotiv EEG signals The main difference between data gathered from Emotiv and data gathered from Freiburg Database. Epileptic patients are inaccessible for seizure data gathering utilizing the Emotiv EEG headset as the collection device.P a g e | 27 processed from within a java program. is mentioned above. this also proved to be problematic. it can only be verified that data can be transmitted from Headset to Android and that classification does occur.

Its impact on phone power consumption and the speed which it performs classification was measured.8821 % 6. but this was not completed within the project timeline. The Android App was tested to take buffered data at frame sizes of 128 every half second.P a g e | 28 3.6 Results A java classifier model was created and performance evaluated using a small test set.0669 0. It was intended to also focus time on developing digital filters in java.2448 99. . A working Android Application which classifies EEG signals using basic features and a lightweight NaïveBayes linear classifier was created. Application Statistics Contained in Figure 4-4 are the results of a WEKA Linear Classifier model.1179 % Mean rel. This model could be ported to an Android device for use in mobile classification.327 % 93.95 level) Total Number of Instances 51.0037 0.1465 % 94.95 level) 844 55 0.6129 % 899 Figure 4-4: Results output of the Naïve-Bayes Classifier using the evaluateModel function from WEKA libraries Total Number of Instances 899 Using an application called PowerTutor designed by students in the University of Michigan [11] the power consumption of the application while active was processing could be estimated. region size (0. evaluated through WEKA’s evaluateModel function Sensitivity: 0.03225806451612903 Correctly Classified Instances Incorrectly Classified Instances Kappa statistic Mean absolute error Root mean squared error Relative absolute error Root relative squared error Coverage of cases (0.9711981566820277 Specificity: 0.0938 % 134. graphed in Figure 4-5 below.

. completion of the java classifier program on Android suggests that it is indeed viable to use a mobile device such as an Android phone as a portable platform for monitoring of EEG state. 3. Despite issues relating to the Emotiv EPOCs physical limitations. project specific hardware must be constructed in order to provide more stability to the system and reduce the affect that physical movement has on the quality of the EEG signal received. and is not suited for use while the user is mobile. The headset itself is large and bulky in design. this report proves that the Android device is able to handle a Bluetooth stream of data from an EEG source at desirable frequencies and performance data classification. Connecting the Emotiv headset to Android for live-data BAN simulation would have been ideal.7 Conclusions The Emotiv EPOC Headset has numerous limitations which devalue its continued use within the scope of future projects similar to this. This will be discussed in more detail later in Chapter 6. Power usage over a period of 10 seconds [left] and Power usage as a percentage of whole application [left] The average runtime of the Classification algorithm is approximately 5-8ms per frame. Erratic movement cause major interference and noise in signal output. In order to continue exploring the use of mobile technology in detecting a seizure within an environment where the users themselves are mobile. but not a vital part of this project. However.P a g e | 29 Figure 4-5: PowerTutor measurements of Seizure Detection App.

Instead. Due to the time sensitive nature and wide scope of this project. including reducing saving space in memory and having potential power saving benefits. the SPIHT algorithm is not developed or implemented in Java code.1 Introduction This chapter deals with the small scale study conducted as part of this project into the effect of compression of EEG data on classifier performance and its behavior. the SPIHT algorithm was employed in MATLAB in order to investigate the effects of compression. data was again sourced from the Freiburg Database. compresses the data to a specified CR and reconstructs the data for use in evaluating change in classifier performance.P a g e | 30 5.m) takes a full signal file. For this section both Linear Discriminate Analysis and Support Vector Machine performance was evaluated against the compressed datasets. Figure 5-1 is a visual representation of the signal compressed at ratios of 1:4. The second variant (my_genSPIHT.m) takes a 1024 sample frame of data from an EEG signal file and calculates the PRD (Percentage Root-Mean-Square Deviation) for 50 different CR (Compression Ratio) values and plots these to a graph. not the SPIHT algorithm itself. . 5. 1:25. There are 2 main variants of the MATLAB SPIHT program code found on the CD provided with this thesis. on supervisor advice the algorithm will be treated as a ‘Black Box’ wherein only the effect on EEG data and the seizure detection algorithms performance is studied.2 Method of Study For this small study. 1:50 and 1:100 and compared to the original signal. For this study. The first variant (driver1. This data was passed into a compression program in MATLAB. Compression of EEG Data 5. Compression of data offers numerous benefits in systems like the one described throughout this paper. Detail on the SPIHT Algorithm can be found earlier in Chapter 2: Project Components.

Sensitivity and Specificity are the values used earlier in this paper to evaluate the performance of different classifiers. The compression ratios were calculated programmatically as in Figure 5-2: NumberofPoints = 100 totalBits = length(bits) fractionBitLen = nearestWhole((totalBits/numberOfPoints)). . The PRD is a measure of how accurate the reconstructed signal is when compared to the original waveform. A higher PRD value demonstrates a higher level of distortion compared to the uncompressed signal. reconstructedBits) x = decompressSignal(x) } end Figure 5-2: Pseudo-Code for calculation of CR CorrectRate. for i = 1 to NumberofPoints do{ reconstructedBits = fractionBitLen*NumberofPoints x = doSPIHTCompression(signal.P a g e | 31 Figure 5-1: Comparison of EEG Signal at varying CR For the study 4 main areas of effect of compression on EEG and Classifier performance were analyzed.

7% Correct Rate -0. Linear Discriminate Classifier: Compression Ratio 4:1 25:1 50:1 100:1 Sensitivity -0% -0.28% -7.32% -12.P a g e | 32 5. and the second set is representative of the Support Vector Machine Classifier. The tables demonstrate the average change in percentage performance of the LDA Classifier.38% -0.4% Specificity -0.05% -0. Compression Ratio using SPIHT Compression Tables 5-1 and 5-2 each demonstrate the effect of different SPIHT Compression ratios on the LDA and SVM Classifier performance estimation values respectively. Figure 5-3: Percentage Root-Mean-Squared Deviation vs.61% Table 5-1: Average change in performance of LDA Classifier vs.05% -0.3 Results Figure 5-3 demonstrates the increase in PRD as the CR increases incrementally for 100 different compression ratios. CR .23% -0.16% -0.94% -10.

.78% -2. which suggests that under circumstances where data compression is involved. However.88% Specificity -0. without a significant drop in performance.18% Table 5-2: Average change in performance of SVM Classifier vs.0% -4.28% -14. the Linear Classifier would be the more robust choice. Also. CR 5. 79% -3.76% -4.645% Correct Rate -0. suggesting that the system could benefit from data compression.4 Conclusions Graphing the above data shows a steady decline in Specificity in accordance with Compression Ratio.01 % -4.P a g e | 33 Support Vector Machine: Compression Ratio 4:1 25:1 50:1 100:1 Sensitivity -0% -0 % -0. thus demonstrating that the most significant impact of increasing Compression Ratio is a decreasing ability in the algorithms ability to correctly detect negative results. the performance of both classifiers on compressed EEG is relatively similar to that of the original signal. the SVM classifier itself seems to show extra sensitivity towards the change in CR compared to the Linear Classifier.84% -2.

This issue could have been mitigated had the program been tested on a second device earlier in the Bluetooth development cycle. In chapter 4.1 Introduction This chapter aims to put in context what has been achieved through the timeline of this project. which involved changing configuration settings. This phase heavily depended on the use of MATLAB in developing the algorithm. as referenced earlier in Chapter 4. this method was abandoned. The second issue faced at this stage related to the incompatibility between the Emotiv EPOC headset and Android. extraction and comparison of features. This would have identified the issue as being hardware specific at an earlier stage and a solution could have been resolved quicker.2 Discussion In chapter 3. what was successful and what has still to be done in terms of a project with this scope. Discussion 6. being required for measuring algorithm performance. and the development of a real-time system relay between the Emotiv EPOC and Android phone through the PC. This was unforeseen to a degree. the two major issues being the development of the Bluetooth connection between PC and the HTC Wildfire phone. This phase came with numerous difficulties. The initial Android Seizure Classifier Application was completed in full. However this method has seen success in other projects. The resulting algorithm proved effective on test data and fit the requirements outlined throughout the project. examination of the effects and benefits of signal pre-processing and ultimately deciding on an algorithm to move forward with into the mobile development phase of the project. This data could be transmitted in frames to the Android device. which would then perform classification of the received data. However after numerous attempts. as the Emotiv headset documentation provides a JNA Wrapper class for Java to allow Java applications to access Native DLL libraries on a system in order for these programs to read EEG data from the Emotiv Headset. This issue arose due to the incompatibility issues between Java and C++. the Algorithm Development phase of this project was covered. The second attempted solution was also to modify . the development of the mobile system was discussed. changing system paths and project class paths. The issue was not well documented and therefore a work-around was hard to find. areas which caused trouble. The Bluetooth connection issue was specific to the HTC Wildfire and limited other HTC models.P a g e | 34 6. This system connected over Bluetooth to a Bluetooth Server containing EEG data. 6.

To this end. The Emotiv EPOC is not suited to this purpose due to its bulky nature. the project achieved all of the milestones set out in the opening chapter. with the exception of measuring . In order to continue development. However. being restricted to the use of healthy personal for live testing means it is very difficult to determine if the classifier is working on live data. Chapter 5 detailed the small scale study into the effects of compression of EEG signal and the resulting impact compression has on Classifier performance. The issue regarding connecting the Emotiv headset directly or indirectly to Android is still open for resolution. as touched upon earlier in Chapter 4. the percentage of correctly identified instances only dropped by roughly 4.3 Conclusion The aim of this project was to investigate the development and implementation of a number of signal processing algorithms for epileptic seizure detection through digital signal processing of EEG signals. The project also aimed to carry out small scale investigation of compression of EEG signals in order to determine if there was a relationship between signal compression and seizure detection performance. and its usefulness within this project. This causes additional movement when a patient is mobile and increases the level of noise on the EEG signals. With regards to the Project Plan outlined for Semester 1 and Semester 2 and the relative effectiveness of both: the Project Plan for Semester 1 proved to be very successful and was adhered to throughout the course of the Semester. 6. The Semester II plan could have featured more detail and offer more time for development considering the newer technologies involved (e.5% perfect between compression ratios of 50:1 to 100:1. The plan allowed ample time for research.g. there are a number of limitations that have been noted with regard to the Emotiv EPOC Headset as a mobile EEG Capture device. This small scale study identified an inverse relationship between increasing CR and classifier specificity. Ictal data must be collected beforehand on the EEG sensing device which is to be used in the mobile BAN system. implementation and testing. Firstly. but this also proved unsuccessful. As the project progressed. within the mobile digital health environment. It aimed to combine off-the-shelf hardware for sensing EEG signals and Smartphone technology to act as the processing hub to create a BAN for monitoring of EEG signals. suggesting that either the features used in classification in this project.P a g e | 35 an example C++/Java Client-Server code. Bluetooth and the Emotiv EPOC). or the classification algorithms themselves are robust in terms of dealing with compressed data.

P a g e | 36 the potential power savings to be gained from the use of data compression. This projects value could be increased as further research continues into areas such as seizure prediction. . could provide epileptic patients with “early warning” systems to minimize risk to self. Therefore it should be deemed unsuitable for further use in projects such as this. This project opens up a new area of patient “wearable” systems for monitoring and analyzing biological signals. A mobile application was created which could process EEG signals and classify Ictal activity. essentially demonstrating that wireless EEG signal processing through mobile technology was indeed possible. Specific hardware could be constructed which would be designed to remain physically stable during patient mobility in order to significantly remove noise. The small-scale study into EEG compression was completed and demonstrated an inverse relationship between signal compression and classifier specificity. EEG hardware could also be compatible with mobile devices to give the system practical value. which when combined with the research in this project. It is advised that future projects and studies into the area of mobile EEG monitoring should focus on developing hardware specific solutions to the EEG sensing issues. This application could be connected through Bluetooth to a compatible EEG source. However also demonstrated was the off-the-shelf system used within this project proved to have many limitations in a real-life application such as the one described in this project.

Volume 79. Clinical Neurophysiology. Pages 151-159. Jari Nissinen. G. Landis. Mohseni. Asla Pitkänen.edu/~rodri/programs/spect.1016/j. Markku Penttonen.cs. Michel.P a g e | 37 References [1]EEG Database. ”Epileptic seizure detection: A nonlinear viewpoint”. R. University of Waikato http://www. Pages 763772 [8] T. Volume 111. L.njit.https://epilepsy. Lantz.006 [5]M. Vespignani. CA 91125-http://www. S. O.cmpb. M.vis. Clinical Neurophysiology. Issue 3. L.waikato. T. Thut. A. R. Koessler. “Temporal and spatial determination of EEG-seizure onset in the frequency domain”. Computer Methods and Programs in Biomedicine.” Seizure Prediction in Freiburg. Cecchin.2005. Tapio Grönfors. Papadourakis. Blanke. First International Conference on Advances in Medical Signal and Information Processing [6]Hamid R. “Seizure lateralization in scalp EEG using Hjorth parameters”. doi:10. C. Vourkas. Seppo Lammi. 1 May 2000. Germany . Ranta.edu/pdf/1721_Mohseni.de/freiburg-seizure-prediction-project/eeg-database [2]WEKA: Data Mining Software in Java. August 2006. 28th International Annual Conference IEEE Engineering in Medicine and Biology Society(EMBS). Spinelli. The Andersen Lab.pdf [7] O. Pages 290-300 . Division of Biology California Institute of Technology Pasadena. Caspary. ”Use of ANN and Hjorth parameters in mental-task discrimination”. H. “Seizure Detection in EEG signals: A Comparison of Different Approaches”.04. Maillard. August 2005.unifreiburg. G. Grave de Peralta.nz/ml/weka/ [3] MATLAB EEG code.caltech. Micheloyannis and G. http://embc2006. L. Maghsoudi and Mohammad B. Issue 2. Shamsollahi. Issue 5.m [4] Niina Päivinen.M. Volume 121. Seeck.ac. March 2010.

Page 46 [11]PowerTutor. University of Michigan. “Weka for Android”. “EEG Signal Processing and Emotiv’s Neuro Headset”. http://ziyang. Hoffman. 28-09-2010. Lide Zhang.com/#/Research/WekaforAndroid/ [10] A.eecs. Mark Gordon.P a g e | 38 *9+RJ Marson.edu/projects/powertutor/ .umich. http://rjmarsan.

via Java MIDP emulator Standard battery.2 MATLAB Filter Code function hd = filterB() %FILTERB Summary of this function goes here % Detailed explanation goes here %sampling frequency fsamp = 256.P a g e | 39 Appendix A. end Figure A-1: Code used to design MATLAB Filter Coefficients . N=50.3. W1 = (bandstart/(fsamp/2)). Li-Ion 1230 mAh Yes. v3. upgradable to v2.3 (Gingerbread).0 A. v2. W = [W1 W2].1 HTC Wildfire Specifications: Relevant Specs: OS Android OS. Qulacomm MSM7227 600 MHz ARM 11 Adreno 200 Yes.5 Chipset GPU CPU Java Battery Bluetooth Table A-1: Specifications of HTC Wildfire. bandstart=2. hd = fir1(N. W2 = (bandstop/(fsamp/2)). bandstop=20. W).

P a g e | 40 A.invoke(device. Replaced With: Method m = device. tmp = (BluetoothSocket) m. This error seems to stem from HTC lacking Bluetooth support in some phone models. . new Class[] {int. Offending Code: tmp = device. 1). ConnectThread method. The code below was provided as a work-around.3 Wildfire Bluetooth Code Problem In RemoteBluetoothService.java.class}).createRfcommSocketToServiceRecord(MY_UUID).getClass(). a Service Discovery Failed Exception occurs.getMethod("createRfcommSocket".