chua boon jin capstone project final report

111
SIM UNIVERSITY SCHOOL OF SCIENCE AND TECHNOLOGY ENTROPIES FOR DETECTION OF EPILEPSY IN EEG STUDENT : CHUA BOON JIN (Q0706456) SUPERVISOR : DR RAJENDRA ACHARYA U PROJECT CODE : JAN2010/BME/0018

Upload: ayothy-senthil

Post on 30-Oct-2014

45 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Chua Boon Jin Capstone Project Final Report

SIM UNIVERSITYSCHOOL OF SCIENCE AND TECHNOLOGY

ENTROPIES FOR DETECTION OF EPILEPSY IN EEG

STUDENT : CHUA BOON JIN (Q0706456)SUPERVISOR : DR RAJENDRA ACHARYA U PROJECT CODE : JAN2010/BME/0018

A project report submitted to SIM Universityin partial fulfilment of the requirements for the degree of

Bachelor of Science (or Bachelor of Biomedical Engineering)

November 2010

Page 2: Chua Boon Jin Capstone Project Final Report

Abstract

The aim of this paper is to interpret EEG signal to enable neurologist to diagnose epilepsy

more effectively. EEG data was obtained from Bonn University and Non-linear Analysis

was used for this paper with a total of 8 entropies estimators used. These entropies

estimators are Bi-Spectral Entropy 1 and 2, Approximate Entropy, Wen Entropy, Sample

Entropy, Shannon Spectral Entropy, Renyi’s Entropy and Kalmogorov-Sinai Entropy. By

using ANOVA test, a low p-value (probability value) of < 0.0001 was achieved for all of

our entropies estimators used except Shannon Spectral Entropy. For classification, 4

entropies estimators namely Approximate Entropy, Renyi’s Entropy, Bi-Spectral Entropy 1

and Sample Entropy were used. The highest classification rate of 94.44% for GMM

classifier was achieved. To further improve the accuracy rate of the probability of epilepsy

better, a new parameter known as Index was introduced. By using the same 4 entropies

estimators used for classification, a low p-value of < 0.0001 was achieved. The same as the

7 entropies estimators used earlier. This further proves that entropies estimators are able to

predict normal, epilepsy and pre-ictal effectively to enhance the probability of a correct

diagnosis for patients.

Acknowledgement

I would like to thank Dr Rajendra Acharya U for his time and effort to guide me in this

project. Without his help and guidance, this project would not be a success. I would also

like to thank all anonymous reviewers for their comments and suggestions and those who

have helped me in one way or another. Once again, thank you all for all your kind

assistance.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT i

Page 3: Chua Boon Jin Capstone Project Final Report

Table of Contents

ABSTRACT.................................................................................................................................................. I

ACKNOWLEDGEMENT................................................................................................................................ I

TABLE OF CONTENTS................................................................................................................................. II

LIST OF FIGURES....................................................................................................................................... IV

LIST OF TABLES......................................................................................................................................... IV

LIST OF SYMBOLS..................................................................................................................................... IV

CHAPTER 1................................................................................................................................................ 1

INTRODUCTION..................................................................................................................................................1

CHAPTER 2................................................................................................................................................ 5

DATA...............................................................................................................................................................5ENTROPY ESTIMATORS........................................................................................................................................6

Bi-Spectral Entropy 1 and 2.......................................................................................................................6Approximate Entropy................................................................................................................................8Wen Entropy..............................................................................................................................................8Sample Entropy.........................................................................................................................................8Shannon Spectral Entropy.........................................................................................................................9Renyi’s Entropy..........................................................................................................................................9Kalmogorov-Sinai Entropy......................................................................................................................10

CLASSIFIERS.....................................................................................................................................................10Fuzzy Sugeno Classifier............................................................................................................................10Gaussian Mixture Model.........................................................................................................................11

CHAPTER 3.............................................................................................................................................. 13

RESULTS.........................................................................................................................................................13DISCUSSION....................................................................................................................................................22

CHAPTER 4.............................................................................................................................................. 24

SUMMARY......................................................................................................................................................24CONCLUSION...................................................................................................................................................24FUTURE WORKS...............................................................................................................................................24

CHAPTER 5.............................................................................................................................................. 25

REFLECTION.....................................................................................................................................................25

REFERENCES............................................................................................................................................ 27

APPENDIX A – ENTROPY VALUES.............................................................................................................. 30

ENTROPY VALUES FOR NORMAL SIGNAL...............................................................................................................30ENTROPY VALUES FOR EPILEPSY SIGNAL...............................................................................................................34ENTROPY VALUES FOR PRE-ICTAL SIGNAL.............................................................................................................36

APPENDIX B – ENTROPY CODES............................................................................................................... 41

BI-SPECTRAL ENTROPY CODES............................................................................................................................41APPROXIMATE ENTROPY CODES.........................................................................................................................42

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT ii

Page 4: Chua Boon Jin Capstone Project Final Report

WEN ENTROPY CODES......................................................................................................................................43SAMPLE ENTROPY CODES..................................................................................................................................44SHANNON SPECTRAL ENTROPY CODES.................................................................................................................46RENYI’S ENTROPY CODES..................................................................................................................................46KALMOGOROV SINAI ENTROPY CODES.................................................................................................................46

APPENDIX C - GUI.................................................................................................................................... 48

GUI MAIN SCREEN CODES................................................................................................................................48GUI SUB SCREEN CODES...................................................................................................................................56

APPENDIX D - CLASSIFIER......................................................................................................................... 59

FUZZY CLASSIFIER CODES...................................................................................................................................59Gaussian Mixture Model Classifier Codes...................................................................................................60

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT iii

Page 5: Chua Boon Jin Capstone Project Final Report

List of Figures

- Figure 1 Block diagram representation of project

- Figure 2 EEG signal of Normal, Epilepsy and Background

- Figure 3 Non-redundant region of computation

- Figure 4 Screen shot of Main GUI page

- Figure 5 Screen shot of Sub GUI page

List of Tables

- Table 1 ANOVA test on EEG data with 8 different entropies

- Table 2 Results obtained for GMM

- Table 3 Results obtained for Fuzzy

- Table 4 Comparison between GMM and Fuzzy

- Table 5 Result obtained for Index

- Table 6 Comparison between Classifier

List of Symbols

Summation

Heaviside function

Pie

Set Membership

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT iv

Page 6: Chua Boon Jin Capstone Project Final Report

Chapter 1

Introduction

The brain is a large and highly complex organ. The four major components of the brain

consist of the cerebrum, cerebellum, diencephalon and brain stem. Cerebrum is the largest

portion of the brain and its functions include sensory, motor and association areas where

they inter-relate sensory and motor areas in the interrelationships of personality traits,

memory and intellectual processes. Cerebellum is the second largest and is in-charge of

balance and coordination of muscle. Diencephalon and brain stem are for relaying sensory

impulses and regulate body functions. The brain also contains billion of nerve cells or

neurons. Nerve cells or neurons communicate in the brain by sending electrical impulses

with each other. The movement of electrical signals excites or inhibits between nerve cells

trigger by chemical reaction, produces thought, feeling, movement and memories. When

the electrical signals excite too far out of the balance between excitation and inhabitation,

misfiring occurs and this usually causes seizures. Depending on where the signal originates

from, the type of seizures varies. If it is from the motor region, a motor seizure; if from a

sensory region, a sensory perception; if the seizures spread to all region of the brain, then a

tonic-clonic seizure results, with body jerking and stiffness. These misfiring electrical

signals cause a brief interruption in the brain activities in which the suffered is unaware of.

A seizure may just happen suddenly and usually last from a few seconds to a few minutes.

Some factors that provoke seizures include stress, flashing light, alcohol and alcohol

withdrawal. A single seizure is not epilepsy. It is only when more seizures occur along a

period of time, then it can be considered as epilepsy.

Epilepsy is a general term used to describe a neurological brain disorder. It is not

contagious and is not a disease. Most of the occurred epilepsy remained unknown, only a

handful of it was known. Some known causes of epilepsy includes stroke, lack of oxygen to

the brain, high fever and brain tumour. Epilepsy can affect anyone, anywhere and anytime

regardless of how old you are.

A successful diagnostic test includes detail history of episodes information such as

blood test, Magnetic Resonance Imaging (MRI) scan and Electroencephalogram (EEG)

test. Blood test is done to look for any infectious or chemical cause of seizures. Blood test

is also important if antiepileptic drugs are to be used. MRI is used to scan the brain to check

if there are any underlying structural causes such as blood clot or tumour. MRI is more

detailed than CT or X-ray as it produces more slice images of the brain. EEG is used to

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

1

Page 7: Chua Boon Jin Capstone Project Final Report

measure electrical signals produced by the brain. Electrodes are placed in different position

on the scalp with adhesive paste. The electrodes are wired to an amplifier and to a

recording device with monitor. The electrical signals released by neurons in the brain are

captured by electrodes, amplify and convert it into waveforms, which are shown on the

monitor. These patterns of waveforms are used to determine if the patient’s are suffering

from epilepsy or any other brain associated disorders. Experience electroencephalographers

will be able to recognize these patterns. During recording, the patient’s may be asked to do

certain things such as looking at flashing light, breathe heavily or to blink the eyes.

Abnormal EEG signal known as spikes, enable electroencephalographers to mark

the tendency for seizures. Such spikes are also known as inter-ictal spikes because they

happen in between seizures. However, there are some important factors to know about

EEG test. Firstly, an EEG test cannot be used to diagnose epilepsy. It can only be used as a

tool to support the patient’s medical history, which has consistent seizures attack.

Abnormal spikes in EEG signal does not necessary mean a person is not normal especially

when they did not suffer from any seizure in the past. Secondly, a negative EEG test should

not discourage the clinician from treating especially when the patient’s has a history of

seizures attack. Therefore, EEG test is helpful in getting information to support the

diagnosis of epilepsy and to classify the types of EEG signal.

For engineers and researchers understanding these waveforms requires knowledge

of signal processing skills in relation to physiological events. Over the years, many

experiments were done using various methods to analyse EEG waveform. These include

Fast Fourier Transform (FFT), Autoregression (AR) method, Autoregressive-moving

average (ARMA) method, Time Varying Autoregression (TVAR) method, Fast Wavelet

Transform (FWT), Principal Component Analysis (PCA), Fast Independent Component

Analysis (FastICA) and Entropies Estimators.

There are a lot of FFT algorithms involved in mathematics from simple complex

number arithmetic to group theory and number theory. The most common FFT algorithm is

based on Cooley-Tukey algorithm [Cooley and Tukey, 1965]. Cooley-Tukey algorithm

breaks down Discrete Fourier Transform (DFT) into smaller bits of DFT such that it can be

combined arbitrarily with any known FFT algorithm for DFT.

FWT is another algorithm used to interpret EEG waveforms. As compared to

Fourier transform, FWT looks for space distribution of singularities instead of overall

regularity of signals [Geva and Kerem, 1998]. FWT can also accommodate wandering

signals unlike Fourier transform, which captures stationary signal. FWT is suitable for EEG BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

2

Page 8: Chua Boon Jin Capstone Project Final Report

signal interpretation as it is non-stationary in nature and its frequency content is time

variant.

TVAR is a new method of breaking down time series and provides clear

representations on EEG time frequency structure. TVAR model was developed such that

the breakdown of time series signal leads to a more significant data analysis method in the

context of state-space models [Andrew D. Krystal et al. 1999]. The data analysis arising in

state-space representation is based on instantaneous, time-evolving eigen structure analysis

of matrices.

AR method is another way to interpret EEG signal. Based on time series, AR is able

to show the centre frequency, associated power and number of oscillatory components.

Autocovariance and Autocorrelation are the 2 methods to calculate AR [R.Ghafar et al.

2008]. Autocorrelation is the more consistent of the 2 methods in displaying the frequency.

ARMA model consists of a number of finite sets of parameters (parametric model).

Dependent on its random disturbance and past values, approximate calculation of its time

series at a time can be estimated. ARMA is able to capture the required information within

the time-varying parameters of the input signal [Vangelis Sakkalis et al. 2008]. Akaike

information criterion (AIC) can be used to determine the model order for ARMA [Vangelis

Sakkalis et al 2008, Shinn-Yih Tseng et al 1993].

FastICA is a statistical signal processing technique to describe the EEG signal. It is

one of the most popular ICA algorithms. The properties of this algorithm include fast and

global convergence for certain contrasts and mixing conditions and is capable to cope well

even when noise is present. The reason to use FastICA is because the algorithm is able to

identify non-gaussian distribution directly.

PCA is used mainly for feature extraction or dimension reduction in EEG analysis.

It can express relevant information in the EEG signal by converting correlated variable into

a new uncorrelated variable by uses fewer dimensions [Sheng-Fu Liang et al. 2010].

Entropies estimators are part of non-linear analysis of time varying signals. This

entropy refers to information theory described by [C.E.Shannon, 1948] in his article A

Mathematical Theory of Communication and is unlike the entropy in thermodynamics.

Confusion between these two entropies is common. Entropy is an uncertainty value usually

associated with a random variable. It is like information contain in a message. This value is

what we obtained by running it with several of entropies algorithm.

In this paper, we have chosen Entropies Estimators as our means of interpreting

EEG waveform. By using different entropies algorithms, we were able to calculate each BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

3

Page 9: Chua Boon Jin Capstone Project Final Report

EEG waveform entropy value, and from this value, we hope to determine whether it is

normal, epilepsy or pre-ictal (background) interpretation. EEG data used in this paper were

from Bonn University. More details will be discussed in chapter 2.

For the rest of the paper, chapter 2 also covers the different types of entropies

features used in this paper and the type of classifiers used. Chapter 3 describes the

procedures for this paper, results obtained and discussion. In the last chapter a conclusion is

drawn and an overall summary of this paper with a section for future works. Chapter 5

contains my reflection for this project.

The scope of this project is to detect Epilepsy from EEG signal using Entropies. By

using different entropies algorithm, we hope to extract the important information value

associated with each EEG waveform.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

4

Page 10: Chua Boon Jin Capstone Project Final Report

CHAPTER 2

Figure 1 Block diagram representation of project

Data

EEG Data for this project was taken from Bonn University in Germany. It consist 3 classes

of data. There are Normal, Epilepsy and Pre-Ictal. Normal and Pre-Ictal data had 200 cases

each while Epilepsy had 100 cases. Normal data were obtained from 5 healthy volunteers

with 100 cases with eyes open and 100 cases with eyes closed with the volunteers in

relaxed state. Both Epilepsy and Background data were taken from 5 epilepsy patients.

Epilepsy data were taken during seizures attack and Background data when there was no

seizure attack. All data were taken with standard EEG equipment with a sampling rate of

173.61 Hz. Figure 2 shows the typical EEG waveform of Normal, Epilepsy and

Background signal.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

5

EEG Entropies Estimators

Classifie

ResultANOVA

Test

Inde

Page 11: Chua Boon Jin Capstone Project Final Report

Figure 2 EEG signal of Normal, Epilepsy and Background

Entropy Estimators

8 entropies were used for this assignment. These are Bi-Spectral Entropy 1 and 2,

Approximate Entropy, Wen Entropy, Sample Entropy, Shannon Spectral Entropy, Renyi’s

Entropy and Kalmogorov-Sinai Entropy. More details will be discussed in this section.

Bi-Spectral Entropy 1 and 2

Bi-Spectral is a higher order statistic analysis tool use for studying non-linear quadratic

function. It has a triangular region known as the non-redundant region of computation

(Figure 1) [Chua et al. 2010].

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

6

Page 12: Chua Boon Jin Capstone Project Final Report

Figure 3 Non-redundant region of computation

The following bispectral entropies formulas were defined by [Chua et al.2010] and

are used for this project. Normalized bispectral entropy ensures that the entropy calculated

lies between the non-redundant region of 0 and 1.

Weighted centre of bispectrum (WCOB):

Where and are the frequency bin index in the non-redundant region

Normalized bispectral entropy (BE 1):

Normalized bispectral square entropy (BE 2):

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

7

0.5 1

f1

f2

0.5

Non-redundant Region

0

Page 13: Chua Boon Jin Capstone Project Final Report

Approximate Entropy

Approximate entropy (ApEn) can be successfully applied to relatively short and noisy data.

[Kannathanl et al. 2006]. ApEn estimate that the logarithmic likelihood of data that are

close to the next comparison will remain close and will not differ much. Value of ApEn

will be small with a more regular and predictive EEG signal and value of ApEn will be

large with irregular and less predictive EEG signal [Physio Toolkit, U.R. Acharya et al.

2009].

ApEn by [Pincus SM, 1991] is given by:

where is the correlation integral.

For this project, is set to 5 and the standard deviation of original data

sequence.

Wen Entropy

Wen entropy is available in Matlab as wentropy under wavelet toolbox. The syntax for

wentropy is:

The type of entropy used in this paper is ‘shannon’. [Matlab]

Sample Entropy

Sample entropy (SampEn) is derived from Grassberger and his fellow researchers. The

conditional probability of the negative natural logarithm SampEn is such that 2 similar

sequences for length m within tolerance r will remain similar at next point. SampEn is

largely independent of data length. [Physio Toolkit, Richman and Randall 2000]. SampEn

can be calculated by using this equation:

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

8

Page 14: Chua Boon Jin Capstone Project Final Report

for with the length of the

input series, r is set to 0.2 and m (maximum template length) is set to 4.

The algorithm starts by finding points that match the first point within the tolerance r. The

points that match have a length of 1 and those that don’t have a length of 0. If the point

after length 1 matches with the point on length 1, the length is now length 2 and so on. If

the point after length 0 matches length 0, the length is now length 1. This matching of

points will go on until the end of data. The matches are keep track in A(k) and B(k) counters

for all lengths k up to m [Physio Toolkit].

Shannon Spectral Entropy

The normalized form of Shannon entropy is Shannon Spectral Entropy (SEN) and is given

by:

where is the power level

High entropy data have broad flat probability distribution while low entropy data have

narrow peaked probability distribution [Kannathal et al. 2006].

Renyi’s Entropy

Renyi’s entropy is given by:

where

In this paper, we used to determined the for normal and epileptic EEG data.

This is a special case called Renyi’s quadratic entropy. Renyi’s quadratic entropy is given

by:

The difference between and is that data is weighted towards frequencies

in the lower frequency band. [Kannathal et al. 2006].

Kalmogorov-Sinai Entropy

Kalmogorov-Sinai entropy measures the time taken for 2 points in the time series to move

apart. Kalmogorov Sinai entropy is given as:

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

9

Page 15: Chua Boon Jin Capstone Project Final Report

where is the average time for the pair to diverge apart and is expressed

in bits/sec.

where is the

correlation function from Grasserger and Procaccaia algorithm.

For this project, is set to 2 and the standard deviation of original data

sequence. A higher entropy value means less predictable and irregularity to the data

[Kannathal et al. 2006].

Classifiers

The classifiers used in this work are Fuzzy Sugeno Classifier and Gaussian Mixture Model

(GMM). More details will be discussed in this section.

Fuzzy Sugeno Classifier

Fuzzy Sugeno Classifier was developed by Takagi and Sugeno [Takagi, Sugeno 1985]. It is

a set of modelling system based on fuzzy implications and reasoning. Fuzzy implication is

based on input being partition into separate space. A linear input-output is formed in each

fuzzy subspace. Fuzzy reasoning output is given by the total number of the values deduced

by some implications that were applied to the input. Fuzzy model building is by input-

output data and is characterized by a mathematical tool to express a system model and

method of identification. By using its input-output data, method of identification is divided

into structure identification and parameter identification. Structure identification decides

which input variables affect the output. Parameter identification identifies the parameters in

both premises and consequences [Yaochu Jin et al. 1995]. Consider a fuzzy system with K

input and fuzzy implication R.

then

where

is the premise variables

is the fuzzy subspace along a linear membership function used for reasoning

is the consequence variable

is the function of value when satisfies the premise

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

10

Page 16: Chua Boon Jin Capstone Project Final Report

The final output y is given by:

where

is the truth value of proposition

Gaussian Mixture Model

Gaussian Mixture Model belongs to a category of unsupervised classifier [Bertrand

Scherrer, 2007]. GMM uses a statistically method for clustering and also used for density

estimation. GMM density function for d-dimension space is defined as [J.J. Verbeek et al.

2003]:

Where

denotes the parameters and

is a d-component feature vector

is the d-component vector containing the mean of each feature

is the d-by-d covariance matrix

is the determinant

A k-component GMM is defined as:

with for

where

is the mixing weight

is the mixture component

The optimization method used in GMM for classification is known as Expectation

Maximization (EM). EM allows updates to the parameters of a given k-component mixture

with regards to data set such that the probability of is never smaller than

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

11

Page 17: Chua Boon Jin Capstone Project Final Report

the new mixture. For all components, the equations for EM are [A.P. Dempster

et al. 1977, J.J. Verbeek et al. 2003]:

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

12

Page 18: Chua Boon Jin Capstone Project Final Report

CHAPTER 3

Results

8 entropy values were obtained after running them through their respective Matlab program from the 3 classes

of EEG data. Entropy values of these 8 entropies are shown in Appendix A. These 8 entropy values were used

to obtain their mean, standard deviation, P – (probability) value and Group Mean with 95% Confidence

Interval value by using ANOVA (Analysis Of Variance) test. Table 1 shows the results for ANOVA test.

Entropies Normal Epilepsy Pre-Ictal P - Value

Bi Spectral Entropy 1

0.56570±7.634E-02 0.48325±0.155 0.47132±5.833E-02 < 0.0001

Bi Spectral Entropy 2

0.77377±3.163E-02 0.73184±4.555E-02 0.67811±3.926E-02 < 0.0001

Kalmogorov-Sinai Entropy

7.68840E-03±1.408E-02

3.36197E-02±7.547E-02

2.16623E-02±4.632E-02

< 0.0001

Sample Entropy 1.3324±0.122 0.92647±0.139 1.0175±0.163 < 0.0001

Shannon Spectral Entropy

Too few data Too few data Too few data N.A.

Renyi’s Entropy -16.339± 0.653 -19.535± 1.02 -16.378± 0.935 < 0.0001

Approximate Entropy

2.2512± 5.578E-02 1.9325± 0.215 1.8785± 0.256 < 0.0001

Wentropy-5.17516E+07±

5.255E+07-2.75498E+09±

2.540E+09-1.41293E+08±

7.067E+08< 0.0001

Group Mean with 95% Confidence Interval

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

13

Page 19: Chua Boon Jin Capstone Project Final Report

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

14

Page 20: Chua Boon Jin Capstone Project Final Report

Table 1 ANOVA test on EEG data with 8

different entropies

From the results we can see that all the p-value is very small at < 0.0001. This means that

the probabilities of obtaining very different or more different results as compared to the

results shown above are very small. Assuming all the data collected was correct. BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

15

Page 21: Chua Boon Jin Capstone Project Final Report

4 sets of data namely Renyi’s, Bi-Spec 1, SampEn and ApEn were fed into 2 classifier

Fuzzy and GMM. Before the data can be fed into the classifier, these data must be sort into

training and testing categories. 100 data from each class were selected to be split into

training and testing. 70 data from each class were used for training while 30 were used for

testing. The 70 training data were mixed into rows by rows of normal, epilepsy and pre-

ictal while the testing data were arranged by normal data at the top followed by epilepsy

data and lastly pre-ictal data. These data were known as training1 and testing 1. 2 more sets

of training and testing data were created. These were achieved by swapping the 30 testing1

data to training1 and the first 30 of training1 data to testing1. These data were arranged

according to their respective arrangement as mentioned above. These data were named as

testing2 and training2. The 30 testing2 data were once again swap with the next 30 of

training2 and arranged according to their arrangement and these data were named as

testing3 and training3. The results for GMM are shown on Table 2.

Training 1 and Testing 1

Classification rate: 94.4444%EEG Test Result

EEG Data

Normal Epilepsy Pre-Ictal

Normal 30 0 0PPV = 100%NPV = 95%

Epilepsy 1 28 1PPV = 93.33%NPV = 98.33%

Pre-Ictal 2 1 27PPV = 90%NPV = 98.33%

Sensitivity = 90.91%

Specificity = 100%

Sensitivity = 96.55%

Specificity = 98.33%

Sensitivity = 96.43%

Specificity = 95.16%

Training 2 and Testing 2

Classification rate: 94.4444%EEG Test Result

EEG Data

Normal Epilepsy Pre-Ictal

Normal 27 0 3PPV = 90%NPV = 100%

Epilepsy 0 29 1PPV = 96.67%NPV = 98.33%

Pre-Ictal 0 1 29PPV = 96.67%NPV = 93.33%

Sensitivity = 100%

Specificity = 95.24%

Sensitivity = 96.66%

Specificity = 98.33%

Sensitivity = 87.88%

Specificity = 98.24%

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

16

Page 22: Chua Boon Jin Capstone Project Final Report

Training 3 and Testing 3

Classification rate: 93.3333%EEG Test Result

EEG Data

Normal Epilepsy Pre-Ictal

Normal 29 0 1PPV = 96.67%NPV = 96.67%

Epilepsy 1 29 0PPV = 96.67%NPV = 95.00%

Pre-Ictal 1 3 26PPV = 86.67%NPV = 98.33%

Sensitivity = 93.55%

Specificity = 98.31%

Sensitivity = 90.63%

Specificity = 98.23%

Sensitivity = 96.30%

Specificity = 93.65%

Table 2 Results obtained for GMM

From the results, both training1 and testing 1, training2 and testing2 have the same

classification results of 94.4444% while training3 and testing3 not far behind at 93.3333%.

Sensitivity, which test the sensitivity of the classifier to predict true positive results range

from 87.88% to 100%. This means the rate of the classifier ability to successfully predict

normal, epilepsy and pre-ictal signal is very high. On the other hand, specificity, which

refers to how accurately, the classifier is able to diagnose successfully true negative results

range from 93.65% to 100%. When specificity is 100%, this means that False Positive

(FP) is equal to 0 and every test the classifier diagnoses is correct 100% accuracy diagnosis.

Positive Predictive Value (PPV) shows the probability of the classifier to correctly diagnose

the positive results. Specificity of 100% usually is equal to 100% PPV. Negative Predictive

Value (NPV) shows the probability of negative results that are correctly diagnosed. PPV for

GMM range from 86.67% to 100% while NPV range from 93.33% to 100%.

For Fuzzy, the 3 sets of data need to be normalized before fed into the classifier. After

normalizing, the normalized were split in the same way as GMM data sets into training and

testing data. The results of Fuzzy are shown on Table 3.

Training1 and Testing1

Classification rate: = 81.11%  EEG Test Results

EEG Data   Normal Epilepsy Pre-Ictal  

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

17

Page 23: Chua Boon Jin Capstone Project Final Report

Normal 28 0 2PPV = 93.33%NPV = 85.00%

Epilepsy 6 21 3PPV = 70.00%NPV = 95.00%

Pre-Ictal 3 3 24PPV = 80.00%NPV = 91.67%

 

Sensitivity = Sensitivity = Sensitivity =75.68% 87.50% 82.76%

Specificity = Specificity = Specificity =96.23% 86.36% 90.16%

Training2 and Testing2

Classification rate: = 84.44%  EEG Test Results

EEG Data

  Normal Epilepsy Pre-Ictal  

Normal 26 4 0PPV = 86.67%NPV = 90.00%

Epilepsy 3 23 4PPV = 76.67%NPV = 93.33%

Pre-Ictal 3 0 27PPV = 90.00%NPV = 93.33%

 

Sensitivity = Sensitivity = Sensitivity =81.25% 85.19% 87.10%

Specificity = Specificity = Specificity =93.10% 88.89% 94.92%

Training3 and Testing 3

Classification rate: = 85.56%  EEG Test Results

EEG Data

  Normal Epilepsy Pre-Ictal  

Normal 29 0 1PPV = 96.67%NPV = 83.33%

Epilepsy 4 24 2PPV = 80.00%NPV = 100.00%

Pre-Ictal 6 0 24PPV = 80.00%NPV = 95.00%

 

Sensitivity = Sensitivity = Sensitivity =74.36% 100.00% 88.89%

Specificity = Specificity = Specificity =98.04% 90.91% 90.48%

Table 3 Results obtained for Fuzzy

From the results, the highest classification rate achieved was 85.56%. Sensitivity range

from 74.36% to 100% and this proves that Fuzzy is not as sensitive when it comes to

predicting the TP of normal, epilepsy or pre-ictal signals as compared to GMM. Specificity

for Fuzzy range from 86.36% to 98.04% and this again shows there is quite a number of

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

18

Page 24: Chua Boon Jin Capstone Project Final Report

FP generated by Fuzzy and this can hinder the accuracy of predicting these EEG signals.

PPV for Fuzzy range from 70% to 96.67% and NPV range from 83.33% to 100%. Table 4

shows the comparison between GMM and Fuzzy.

Classification Sensitivity Specificity PPV NPV

GMM Test1Normal

94.44%

90.91% 100% 100% 95%

Epilepsy 96.55% 98.33% 93.33% 98.33%

Pre-Ictal 96.43% 95.16% 90% 98.33%

Fuzzy Test1Normal

81.11%

75.68% 96.23% 93.33% 85.00%

Epilepsy 87.50% 86.36% 70.00% 95.00%

Pre-Ictal 82.76% 90.16% 80.00% 91.67%

GMM Test2Normal

94.44%

100% 95.24% 90% 100%

Epilepsy 96.66% 98.33% 96.67% 98.33%

Pre-Ictal 87.88% 98.24% 96.67% 93.33%

Fuzzy Test2Normal

84.44%

81.25% 93.10% 86.67% 90.00%

Epilepsy 85.19% 88.89% 76.67% 93.33%

Pre-Ictal 87.10% 94.92% 90.00% 93.33%

GMM Test3Normal

93.33%

93.55% 98.31% 96.67% 96.67%

Epilepsy 90.63% 98.23% 96.67% 95%

Pre-Ictal 96.30% 93.65% 86.67% 98.33%

Fuzzy Test3Normal

85.56%

74.36% 98.04% 96.67% 83.33%

Epilepsy 100.00% 90.91% 80.00% 100.00%

Pre-Ictal 88.89% 90.48% 80.00% 95.00%

Table 4 Comparison between GMM and Fuzzy

Overall, it can be seen, GMM classifier shows the highest accuracy in terms of

classification, sensitivity, specificity, PPV and NPV.

For greater and better accuracy, we have come up with a new parameter known as index.

Index is calculated using the same 4 set used for classifier. The entropies are Approximate

Entropy, Sample Entropy, Bi-Spectral Entropy 1 and Renyi’s Entropy. The equation is:

Table 5 shows the result for Index using ANOVA test. The probability value is < 0.0001, which shows index

can be used for correctly predicting the outcome.

Entropies Normal Epilepsy Pre-Ictal Probability ValueIndex 0.60135±2.047E-02 0.70779±3.170E-02 0.66309±5.876E-02 < 0.0001

Group Mean with 95% Confidence Interval

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

19

Page 25: Chua Boon Jin Capstone Project Final Report

Table 5 Result obtained for Index

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

20

Page 26: Chua Boon Jin Capstone Project Final Report

For easy access of deducing the result, a GUI was created to incorporate all data needed to

deduce the final results. These results will tell us whether the EEG signal is normal,

epilepsy or pre-ictal. Graphical details of GUI are shown below.

Figure 4 Screen shot of Main GUI page

To analyze an EEG signal via the GUI, the user must first add in an EEG signal using the

Browse button. Once the signal has been add in, the analog and digital value of the signal

will be plot. After which, click the Analyze button to determine the result. If the Analyze

button is pressed before an EEG signal is uploaded, the GUI comes with a pop up (shown

below) to remind you to input an EEG signal. To find out the index value of the signal,

press Index button located at the bottom of the GUI and the index value will be shown on

the text box beside it. To select another EEG signal, press Reset. This will remove all data

shown before. To exit the GUI, simply press Close.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

21

Page 27: Chua Boon Jin Capstone Project Final Report

Figure 5 Screen shot of Sub GUI page

Discussion

Epilepsy or seizures is the common term to describe brain disorder. It is usually caused by

neurons misfiring in the brain. The frequency and neurons firing pattern differ significantly

from normal, epilepsy and pre-ictal state. The EEG signal produced by the pattern of

neurons firing is complex and chaotic [H. Adeli et al. 2006]. Results shown in table 1 by

the ANOVA test, shows a very distinct value pattern for normal and epileptic state. Value

for normal state is always higher than epileptic state with the exception of Wen Entropy.

This indicates that the brain is less organized and more chaotic and complex during normal

brain activity. During Epilepsy, the brain is more organized and less complex as indicated

by the lower value.

Using the same data set used in this work, several papers demonstrated different features extraction

approach that are comparable to this paper. These results were compiled and compared in Table 6. Table 6

shows the comparison between classifier results.

Authors MethodClassifier Accuracy

This Paper Non-linear features with GMM and Fuzzy classifier 90%

Paper by Kannathal et al.

Non-linear features with Adaptive Neuro-Fuzzy Inference System classifier

92.26%

Paper by U. R. Acharya et al.

Non-linear features with GMM and SVM classifier 94.44%

Table 6 Comparison between Classifier

Kannathal N. et al. (2006) demonstrated similar reading in his work. Using Spectral

Entropy, Renyi’s Entropy, Kalmogorov-Sinai Entropy and Approximate Entropy with

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

22

Page 28: Chua Boon Jin Capstone Project Final Report

Adaptive Neuro-Fuzzy Inference System (ANFIS) classifier, Kannathal N. et al. (2006)

reported higher value for normal state and a lower value for epileptic state. This shows that

normal state is more chaotic than epileptic state. Classification rate for normal state shows

93.02% while epileptic state shows 91.49% with an average of 92.26% accuracy.

In another paper by U.R. Acharya et al. (2009), Approximate Entropy, Correlation

Dimension, Fractal Dimension, Hurst Exponent and Largest Lyapunov Exponent together

with GMM and Support Vector Machine (SVM) classifier were used for feature extraction

and classification. U.R. Acharya et al. (2009) achieved a p (probability) -value of < 0.0001

for all entropies used. GMM classifier reported an average of 95% accuracy and SVM

reported an average of 93.88% accuracy with a total average of 94.44%.

H. Adeli et al. (2006) uses a wavelet-chaos methodology to analyse EEG data.

Discrete wavelet transform is used to decompose into delta, theta, alpha, beta and gamma

sub-bands. Correlation Dimension and Largest Lyapunov Exponent are used to quantify

EEG signal. Result shows higher entropy value for normal EEG signal as compared to

epileptic EEG signal. This means higher chaoticity for normal state.

For this paper, Approximate Entropy, Bi-Spectral Entropy 1, Sample Entropy and

Renyi’s Entropy used to for classification. Classification rate achieved for Fuzzy was

85.56% and 94.44% for GMM. Average accuracy for both classifiers was 90%. This is

lower as compared to other papers but this can be further improved by having more training

data. Entropy values for normal state show higher value than epileptic state with p-value of

< 0.0001 from ANOVA test. This proves normal state signal are more chaotic.

The above studies have shown that entropies estimator can be used as a tool to

extract EEG features. To further improve the accuracy of the differentiating the EEG

signal, we propose a new parameter known as Index. Index uses part of the entropies

estimators to form a formula and evaluate the EEG signal. Classification from the index

reported 94.44%. ANOVA test shows the value for normal, epilepsy and pre-ictal are well

space out for group mean of 95% greater confidence interval. This means the value

obtained from index can be greatly differentiate between normal, epilepsy and pre-ictal

EEG signal and enhance its accuracy.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

23

Page 29: Chua Boon Jin Capstone Project Final Report

CHAPTER 4

Summary

Electroencephalogram or EEG as most of us call it is actually electrical signal captured by

neurons firing in the brain. Sometimes these neurons misfire and thus cause epilepsy. To

fully understand these neurons firing pattern and accurately interpret epilepsy, non-linear

analysis such as entropies estimators were used. 8 entropies estimators namely Bi-Spectral

Entropy 1 and 2, Approximate Entropy, Sample Entropy, Spectral Shannon Entropy,

Kalmogorov-Sinai Entropy, Wen Entropy and Renyi’s Entropy were used for features

extraction. ANOVA test on these 8 entropies reported a p-value of < 0.0001%. 4 entropies

namely Approximate Entropy, Bi-Spectral Entropy 1, Renyi’s Entropy and Sample Entropy

were used for classification and reported results of 94.44%. These same 4 entropies were

later used for index. Index is a new parameter developed to predict EEG more accurately.

ANOVA test on index yield positive result with p-value of < 0.0001 and group mean with

95% confidence interval evenly space out between normal, epilepsy and pre-ictal signal.

This proves entropies estimators can be used as a tool to interpret epilepsy successfully.

Conclusion

EEG signal generated from the EEG machine tells us about the neurological behaviour of

the person at that time. To interpret these signals, various forms of research had been

undertaken in the past. Research using non-linear analysis has shown promising results.

From the results shown above, non-linear algorithm such as entropies estimators have

shown that it was possible to be used as a feature extraction tool. Results were comparable

with others paper using similar entropies estimators. Classification results also show similar

characteristics too. The use of index is a new method proposed in this paper that is

definitely a new way to interpret EEG signal with accuracy and precision. With this project,

hopefully a new method to assist neurologist in interpreting EEG comes a step closer.

Future Works

For future works, more training data are required to train the classifier to obtain 100%

classification rate. More variation of epilepsy EEG data is also required such as low risk

epilepsy, high-risk epilepsy and very high-risk epilepsy to fully understand the variation of

EEG signal.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

24

Page 30: Chua Boon Jin Capstone Project Final Report

Chapter 5

Reflection

The time has finally come... it’s a long way but certainly a bright future ahead. Before I

step onto the steps of graduation, together with all my peers and mates, there is one last

item left to tackle and this item is my capstone project.

It has come a long way since the beginning of the year when I started my project. I

can still remember when the time has come to choose a project, I was apprehensive at first

if I should attempt it together with my other modules or to attempt it after I finished all my

modules so that I could concentrate on it 100%. In the end, the urge to graduate faster got

the better of me.

The time was December 2009 when I was required to choose a project via the

student portal. Instruction given was given out to all students taking capstone that the

selection of project is based on first come first choose basis. The fastest you log in, the

more projects to choose from. I log in around 1205 hrs and to my amazement, a lot of the

project was snap up. There were people more anxious than I was. In the end, the project I

select was Entropies for Detection of Epilepsy in EEG. This project requires the user to

have knowledge of Matlab.

I started this project with little knowledge of Matlab; only those basic skills which I

learnt in class. Nevertheless, I decided to give it a go. During the first project meeting with

my project supervisor, Dr Raj, he gave me a firm assurance and that helps greatly. First up,

is the project proposal, after which are the interim report and lastly the final project report.

In between these reports, lie the main dish, Matlab, entropies algorithm and more Matlab.

Initially, while doing my project proposal, I had to read up on a couple of journal

papers to understand what entropy is all about. There is also classifier, which I had never

heard of until then. As the project wore on, more entropy was added to increase its accuracy

and predictability.

Throughout the project, other than recalling what I learnt previously, I also pick up

other skills in Matlab that I never thought I could actually used Matlab to do. One such

example was GUI. Matlab GUI was similar to Visual Basic with its drag and drop interface.

The only difference is the programming codes. After some trial and error, I managed to get

my GUI running. It was such a relief and at the same time felt with a sense of satisfaction.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

25

Page 31: Chua Boon Jin Capstone Project Final Report

But the job does not end here, to make it to the finishing line; we still need to finish this

final project report and the presentation that comes after.

Keep going and preserve till the end. Rewards will come after that.

Only those who attempt the absurd will achieve the impossible. – M. C. ESCHER

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

26

Page 32: Chua Boon Jin Capstone Project Final Report

References

[1] A.E. White, M.J. Burin, T.A. Carter, T.S. Hahm, J.A. Krommes, R.J. Maqueda, S.J.

Zweben (2006), Bispectral analysis of low to high confinement mode transitions in

the National Spherical Torus Experiment, American Institute of Physics, doi:

10.1063/1.2215439

[2] A.P. Dempster, N.M. Laird, D.B. Rubin (1977), Maximum likelihood from

incomplete data via the EM algorithm, Journal of the Royal Statistical Society

Series B(Methodological), Vol 39, No. 1. pp 1-38

[3] Amir B. Geva, Dan H. Kerem (1998), Forecasting generalized epileptic seizures

from the EEG signal by wavelet analysis and dynamic unsupervised fuzzy

clustering, IEEE Transactions on Biomedical Engineering, Vol. 45, No. 10

[4] Andrew D. Krystal, Rqquel Prado, Mike West (1999), New methods of time series

analysis of non-stationary EEG data: eigenstructure decompositions of time varying

autoregressions, Clinical Neurophysiology 110, pp 2197-2206

[5] Bertrand Scherrer, 2007, Gaussian Mixture Model Classifiers, February 5

[6] C.E. Shannon (1948), A Mathematical Theory of Communication, Bell System

Technical Journal, Vol. 27, pp. 379–423, 623–656.

[7] Chua KC, et al. (2010), Application of higher order statistics/spectra in biomedical

signals-A review, Med Eng Phys, doi: 10.1016/j.medengphy.2010.04.009

[8] H. Adeli, S. Ghosh-Dastidar, N. Dadmehr (2006), A wavelet-chaos methodology for

analysis of EEGs and EEG sub-bands to detect seizure and epilepsy, IEEE

Transaction on Biomedical Engineering, 10.1109/TBME.2006.88685

[9] J.J. Verbeek, N. Vlassis, B. Kröse (2003), Efficient greedy learning of gaussian

mixture models, Neural Computation 15(2), pp 169-185

[10] J.W. Cooley, J.W. Tukey (1965), An algorithm for machine calculation of complex

fourier series, Mathematics Computation, 19, pp 297-301

[11] Kannathal N, Lim Choo Min, Rajendra Acharya U, Sadasivan P.K (2006),

Entropies for detection of epilepsy in EEG, Comput. Methods Prog. Biomed. Vol.

81 Issue 2, pp. 193

[12] Physio Toolkit

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

27

Page 33: Chua Boon Jin Capstone Project Final Report

http://www. physionet.org/physiotools/ApEn/

[13] Physio Toolkit, Sample Entropy estimation using sampan

http://www.physionet.org/physiotools/sampen/

[14] Pincus SM (1991), Approximate entropy as a measure of system complexity, Proc

Natl Acad Sci USA, Vol. 88, pp. 2297-2301

[15] R. Ghafar, A. Hussain, S.A. Samad, N.M. Tahir (2008) Comparison of FFT and AR

techniques for scalp EEG analysis, IFMBE proceedings, Vol. 21 pp 158-161

[16] Richman, Joshua S. and J. Randall Moormn (2000), Physiological time-series

analysis using approximate and sample entropy, Am J Physiol Heart Circ Physiol

278: H2039-H2049

[17] Sheng-Fu Liang, Hsu-Chuan Wang, Wan-Lin Chang (2010), Combination of EEG

complexity and spectral analysis for epilepsy diagnosis and seizure detection,

Hindawi Publishing Corporation, EURASIP Journal on Advances in Signal

Processing, doi: 10.1155/2010/853434

[18] Shinn-Yih Tseng, Rong-Chi Chen, Fok-Ching Chong, Te-Son Kuo (1995),

Evaluation of parametric methods in EEG signal analysis, Med. Eng. Phys., Vol. 17,

pp. 71-78

[19] The MathWorks, Matlab

http://www.mathworks.com/access/helpdesk/help/toolbox/wavelet/wentropy.html#7

42186

[20] Tomohiro Takagi, Michio Sugeno (1985), Fuzzy identification of systems and its

applications to modeling and control, IEEE Transactions on systems, man, and

cybernetics, Vol. SMC-15, pp 116-132

[21] U.R. Acharya, K.C. Chua, T.C. Lim, Dorithy, J.S. Suri (2009), Automatic

identification of epileptic EEG signals using nonlinear parameters, Journal of

Mechanics in Medicine and Biology, Vol. 9, No. 4 pp. 539-553

[22] Vangelis Sakkalis, Tracey Cassar, Michalis Zervakis, Kenneth P. Camilleri, Simon

G. Fabri, Cristin Bigan, Eleni Karakonstantaki, Sifis Micheloyannis (2008),

Parametric and nonparametric EEG analysis for the evaluation of EEG activity in

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

28

Page 34: Chua Boon Jin Capstone Project Final Report

yong children with controlled epilepsy, Hindawi Publishing Corporation,

Computational Intelligence and Neuroscience, doi:10.1155/2008/462593

[23] Yaochu Jin, Jingping Jiang, Jing Zhu (1995), Neural network based fuzzy

identification and its application to modeling and control of complex systems, IEEE

Transactions on systems, man and cybernetics, Vol. 25, no. 6

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

29

Page 35: Chua Boon Jin Capstone Project Final Report

Appendix A – Entropy Values

Entropy values for Normal Signal

System Bi-Spec 1 Bi-Spec 2 Kalmogorov SampEn Shannon Renyi's ApEn Wentropy

Param01 0.569686031 0.757807651 3.25472E-19 1.230873013 1351267.121 -16.17353793 2.185351863 -55008096.5

Param02 0.589946312 0.767373089 2.3386E-109 1.242090803 1352134.684 -16.07890431 2.268239931 -54512392.61

Param03 0.547980195 0.749041518 1.24577E-08 1.208101931 0 -16.43376952 2.240502907 -49450863.8

Param04 0.522298349 0.750108306 0.047769821 1.246586628 0 -16.68509287 2.308072105 -94041815.03

Param05 0.505885912 0.731923742 2.49845E-05 1.20328337 0 -16.38875007 2.25327774 -50520020.71

Param06 0.597463498 0.776162051 0.000260149 1.32295946 0 -17.00353217 2.266419509 -221303234.9

Param07 0.482822252 0.694217885 0.000140503 1.086324579 0 -17.26260351 2.131867256 -101711724.7

Param08 0.54487598 0.752218248 2.65356E-15 1.218408576 0 -16.20060608 2.217451575 -59562854.3

Param09 0.420154655 0.707584179 1.51931E-11 1.181371312 0 -16.65130592 2.219878339 -96512499.77

Param10 0.382121993 0.734393451 0.013244059 1.229463776 0 -17.35337184 2.261789905 -186148752.6

Param11 0.428825249 0.720366789 0.007610172 1.21661072 0 -17.62203686 2.27415899 -168440419.5

Param12 0.585706038 0.782297161 0.001201899 1.329339621 0 -15.97731415 2.25943792 -36257748.54

Param13 0.555406949 0.763680064 1.60021E-31 1.275042536 0 -16.9829631 2.264210756 -10301824.47

Param14 0.482321699 0.736113623 3.76164E-12 1.215094757 0 -17.71471372 2.272248756 -72916176.12

Param15 0.503528899 0.745074045 0.033430375 1.200797676 0 -17.46365669 2.250150253 -204068248.8

Param16 0.598153657 0.784062814 1.18774E-05 1.328963343 0 -16.82361918 2.27377205 -180152095.2

Param17 0.470282412 0.736349583 0.004862812 1.214207966 0 -17.61685109 2.26768313 -161943338.4

Param18 0.597158075 0.788992712 7.24584E-72 1.393027812 0 -16.21772974 2.271837246 -62129414.4

Param19 0.512391448 0.718322694 0.01933641 1.130833348 0 -17.35263942 2.239717876 -39955084.58

Param20 0.510747235 0.716884761 6.94225E-13 1.188543586 0 -16.59226204 2.29362637 -85270809.24

Param21 0.572801443 0.749767512 0.000721722 1.209448086 0 -16.71424266 2.264640305 -33878181.66

Param22 0.517261452 0.740394276 0.038609849 1.179246488 0 -16.83148747 2.277857336 -69241210.45

Param23 0.504125453 0.731028768 0.000148687 1.210306805 0 -16.00726922 2.274949907 -29666453.7

Param24 0.48823463 0.723233162 7.17645E-33 1.135779722 0 -17.27971197 2.264530988 -31207132.25

Param25 0.525493286 0.735458914 0.018207238 1.153653175 0 -16.69328238 2.262527226 -93140540.58

Param26 0.559988793 0.750802161 1.49998E-18 1.211941986 0 -16.7996421 2.228486384 -6398766.815

Param27 0.511933331 0.725774572 0.019484409 1.187890831 0 -17.22390011 2.293277893 -27625129.63

Param28 0.62706871 0.780948644 1.811E-12 1.288085396 0 -16.9036756 2.269749514 -197690018.8

Param29 0.60602528 0.77763494 2.45343E-05 1.263158714 0 -15.76398 2.256477084 -32441467.39

Param30 0.570120137 0.751704832 0.028534707 1.220517963 0 -16.69469104 2.312120285 -29094237.92

Param31 0.599150685 0.76479051 2.03937E-06 1.290736018 0 -15.98048119 2.315681354 -17725096.96

Param32 0.618609394 0.79239542 0.010991074 1.339440879 0 -15.75800416 2.261005904 -26372249.52

Param33 0.635406524 0.793808978 0.00644109 1.413019553 0 -16.17447116 2.244345257 -57356581.55

Param34 0.54388799 0.769563454 0.000186402 1.290122636 0 -16.61788124 2.285886867 -48643535.81

Param35 0.446686243 0.734938258 2.26183E-16 1.253853655 0 -17.30495282 2.293495934 -172508324.2

Param36 0.455127795 0.763810737 8.6487E-10 1.273478432 0 -15.98621136 2.246897232 -29976959.1

Param37 0.452805035 0.732622397 0.00686793 1.227011525 0 -17.52208515 2.27519583 -143535376.5

Param38 0.485436961 0.738911894 1.49345E-07 1.205612534 0 -17.71891299 2.255685272 -79475981.78

Param39 0.418995494 0.730943951 0.004111545 1.255841925 0 -17.30323888 2.271956203 -170940610.5

Param40 0.439369372 0.731530806 8.35176E-37 1.264401614 0 -16.61406291 2.288800417 -67124727.55

Param41 0.475542099 0.722940204 0.012915931 1.23347122 0 -17.53322824 2.265795218 -146774367.4

Param42 0.6361379 0.781648531 0.006326659 1.316645698 0 -17.14024412 2.263319143 -23900.45728

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

30

Page 36: Chua Boon Jin Capstone Project Final Report

Param43 0.636767658 0.780255494 1.85442E-06 1.311593866 0 -15.58410665 2.281874086 -20692851.87

Param44 0.585870735 0.763906158 0.007953331 1.207926228 0 -15.71271789 2.227471894 -24971211.03

Param45 0.504021969 0.714847425 0.000177527 1.133161255 0 -17.34922702 2.255541551 -43098874.59

Param46 0.528351359 0.731699318 0.003913733 1.134027326 0 -16.7274905 2.259765358 -104547831.2

Param47 0.658081388 0.795678489 3.93545E-05 1.3985659 0 -16.77235464 2.328012413 -171644928.2

Param48 0.594061874 0.756264748 3.298E-151 1.242553933 0 -16.55676579 2.312400903 -27277222.94

Param49 0.588680303 0.75655554 0.023117334 1.176453274 0 -16.06539748 2.202505292 -18715443.33

Param50 0.537259334 0.753630592 1.63216E-79 1.282458828 0 -15.71012922 2.340513942 -20025435.26

Param51 0.611867546 0.77881702 1.15465E-10 1.422994211 0 -17.09762241 2.373552378 -32339.66181

Param52 0.551401973 0.761110343 0.08483018 1.276921636 0 -16.65225619 2.277317427 -1893073.629

Param53 0.540348368 0.740884083 0.037697983 1.146034463 0 -17.0843552 2.247752059 -17744619.35

Param54 0.48074224 0.718719293 0.000177805 1.166926803 0 -16.75350349 2.287809389 -100369912.6

Param55 0.636804619 0.788192754 0.05543793 1.306215389 0 -15.52921983 2.259447123 -24385026.62

Param56 0.518887872 0.737436716 1.27699E-18 1.176114121 0 -16.69296727 2.284923509 -52000964.88

Param57 0.624568593 0.763746256 6.52891E-06 1.238454329 0 -15.61370544 2.257236991 -33749620

Param58 0.667823303 0.814267907 4.5377E-05 1.441878201 0 -17.34979411 2.256203186 -1893264.184

Param59 0.655529773 0.810390371 0.009151698 1.450908725 0 -16.04295337 2.291383203 -34671780.19

Param60 0.665666335 0.802436552 1.69189E-05 1.416248822 0 -16.50387588 2.310328482 -62857034.51

Param61 0.643169896 0.791035451 0.000315712 1.404008292 0 -16.41125089 2.290831104 -52345982.69

Param62 0.646127571 0.803094978 0.000458631 1.469181322 0 -17.38918786 2.306260732 -2579737.583

Param63 0.639489464 0.800712873 2.05149E-79 1.372134459 0 -16.51568066 2.233284354 -62101580.15

Param64 0.618765997 0.779719347 0.00318596 1.304845977 0 -17.34595383 2.261351367 -37061695.98

Param65 0.590023689 0.824817707 6.95657E-06 1.543983891 0 -17.00345457 2.287731744 -127029711

Param66 0.651362099 0.836339463 0.007737245 1.555450831 0 -16.41909902 2.290905353 -65702324.13

Param67 0.650628662 0.802627689 1.40442E-24 1.439658831 0 -17.24431691 2.275803774 -83612686.23

Param68 0.612504141 0.792546414 0.024537033 1.294580352 0 -16.69598483 2.26097425 -95484117.91

Param69 0.578524181 0.779684644 3.77758E-15 1.359171349 0 -16.52510989 2.246493549 -59187238.63

Param70 0.661200988 0.811906714 0.012264696 1.498817094 0 -17.33959753 2.325149402 -1928178.925

Param71 0.688039398 0.820782259 0.008460501 1.456401038 0 -16.00304927 2.270342024 -31103895.89

Param72 0.527017346 0.790209112 2.00422E-27 1.464163375 0 -16.97192353 2.271116348 -123039705.4

Param73 0.61129719 0.78865252 0.023363774 1.426427451 0 -16.18786944 2.270653057 -37655702.41

Param74 0.661237453 0.805857511 0.015543732 1.499511938 0 -17.32194826 2.298366259 -1710382.742

Param75 0.676420712 0.805486467 2.13524E-26 1.49227568 0 -16.08293158 2.307404543 -35700576.78

Param76 0.631499975 0.783336194 4.16038E-07 1.342693505 0 -17.17384578 2.257477777 -18804927.08

Param77 0.606925666 0.806789767 0.001488973 1.503636666 0 -16.85821911 2.280620735 -110194989.9

Param78 0.617277888 0.819089517 1.84E-145 1.500425357 0 -17.18656892 2.258883811 -266037179.2

Param79 0.606363875 0.812175989 0.018987507 1.431037127 0 -16.18900993 2.258551733 -53890947.09

Param80 0.622575501 0.797694534 0.016732456 1.347832978 0 -17.00627436 2.237870709 -80935693.45

Param81 0.648259142 0.794494756 1.01595E-38 1.388539277 0 -16.43490345 2.283446307 -74210359.97

Param82 0.609594472 0.7844065 0.001158203 1.5342162 0 -16.32495859 2.322598684 -46330125.5

Param83 0.679020854 0.806670891 1.82603E-07 1.572622964 0 -17.27458133 2.315595787 -564782.8411

Param84 0.660277812 0.805014936 8.99371E-67 1.501499278 0 -15.8459668 2.296602815 -27787286.42

Param85 0.639846834 0.794146686 1.00634E-16 1.428179953 0 -16.26343479 2.255340465 -46943617.64

Param86 0.623367715 0.785335184 0.015365423 1.36869146 0 -17.05024473 2.263177082 -13020792.44

Param87 0.537383807 0.808172545 1.09461E-05 1.534492016 0 -16.66946502 2.333284094 -92176066.28

Param88 0.604442899 0.786255769 4.51067E-06 1.387763154 0 -16.84353019 2.287272375 -65448953.93

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

31

Page 37: Chua Boon Jin Capstone Project Final Report

Param89 0.674044848 0.796192503 2.56844E-72 1.421479429 0 -16.24287522 2.278477795 -62546488.6

Param90 0.653468402 0.794916949 0.000455356 1.627867009 0 -16.06512115 2.298587595 -35097184.48

Param91 0.613586726 0.790540123 1.11422E-18 1.337808307 0 -16.08581334 2.315329943 -39051328.65

Param92 0.545997637 0.76714435 4.59819E-27 1.301802832 0 -16.57830724 2.288655852 -63322167.28

Param93 0.556167249 0.767651453 0.009642746 1.287617217 0 -16.72904764 2.283903431 -103993544.7

Param94 0.538151851 0.741486649 0.010474047 1.211054936 0 -17.88133016 2.252777075 -98509111.91

Param95 0.46474627 0.734480817 0.007204768 1.231919753 0 -17.50758229 2.251488908 -213700015

Param96 0.525408446 0.760302125 0.000639646 1.290600737 0 -17.02306769 2.269570859 -12389152.87

Param97 0.508636153 0.748649345 4.54351E-07 1.304873512 0 -16.13143183 2.333063264 -34246415.11

Param98 0.552373299 0.767227787 0.010283277 1.305033276 0 -16.90621714 2.281159256 -199025462.4

Param99 0.6389819 0.787381589 0.010032047 1.335544207 0 -16.69974804 2.329959254 -27600428.48

Param100 0.513341269 0.747081961 0.002115133 1.229912236 0 -17.64035041 2.275910304 -167695670.5

Param101 0.55754777 0.762422489 2.66971E-20 1.256471905 0 -15.84657521 2.228619711 -38050836.18

Param102 0.642556814 0.792086604 1.13403E-44 1.331529594 0 -16.86148014 2.293473387 -5492343.956

Param103 0.519553308 0.752062939 1.9063E-20 1.24960585 0 -16.09456711 2.23442541 -58928053.57

Param104 0.676644935 0.827653498 0.007617452 1.54219873 0 -16.02854822 2.276043836 -34297207.67

Param105 0.556886037 0.776020043 0.017266842 1.374873855 0 -16.07632998 2.294781641 -18827286.89

Param106 0.406018601 0.758457747 0.002784126 1.249884151 0 -16.25580148 2.195344853 -11579677.34

Param107 0.625067959 0.795003821 0.008096461 1.3564489 0 -16.06636142 2.257358372 -22669508.07

Param108 0.565346079 0.779913863 0.022007313 1.350747063 0 -15.30085401 2.264593771 -11976990.43

Param109 0.55632798 0.767487101 1.16245E-49 1.269244839 0 -15.282273 2.076956401 -23395875.35

Param110 0.399486902 0.727410521 0.065150399 1.172212561 0 -16.20364388 2.056117502 -12450582.64

Param111 0.53308515 0.756241994 1.45398E-10 1.298645828 0 -15.73306268 2.167036532 -12308188.57

Param112 0.547308962 0.743860248 6.82477E-13 1.245663587 0 -15.79970816 2.176919761 -13645529.38

Param113 0.562968168 0.737483819 9.36935E-32 1.229655293 0 -15.33771423 2.159846926 -24181848.94

Param114 0.445177345 0.702354039 1.83348E-07 1.136068313 0 -15.83452737 2.057505733 -39327917.93

Param115 0.470755652 0.78011834 0.030264387 1.332284353 0 -14.98061851 2.142068151 -7233574.748

Param116 0.424447344 0.755785752 3.99766E-29 1.271152879 0 -16.03479436 2.149218356 -43514803.8

Param117 0.538744894 0.769715491 1.7943E-110 1.371055662 0 -15.19035006 2.211027904 -21974288.42

Param118 0.566723868 0.781959263 2.93333E-10 1.298018112 0 -16.3383236 2.156801453 -76588111.62

Param119 0.496562023 0.741935889 1.31553E-11 1.186449766 0 -15.25826819 2.091320346 -22185593.18

Param120 0.624121319 0.8057627 3.73122E-17 1.41428749 0 -14.88059295 2.190852559 -8782389.87

Param121 0.447849565 0.755614108 1.09591E-90 1.368627488 0 -15.09807391 2.202129211 -9887900.707

Param122 0.486328807 0.748412699 0.001059677 1.308054879 0 -15.11467444 2.214407211 -9844813.406

Param123 0.499911416 0.803271788 9.80337E-05 1.394418603 0 -16.15981305 2.153484895 -50618038.87

Param124 0.699354678 0.865724308 0.00805299 1.704625147 0 -15.51635997 2.262811317 -24029843.43

Param125 0.450722528 0.759015715 1.71457E-56 1.238365674 0 -16.19265121 2.165353104 -53081292.05

Param126 0.542096747 0.810551986 0.027404537 1.410999084 0 -16.42815204 2.15250031 -85007072.75

Param127 0.687114111 0.809405579 3.6739E-06 1.519366706 0 -15.68237379 2.331158486 -35210044.41

Param128 0.50408279 0.746928142 0.010709729 1.286376417 0 -16.49313791 2.225853874 -678750.5514

Param129 0.654908337 0.84131903 0.002619459 1.608787915 0 -15.82206214 2.241687292 -34729021.74

Param130 0.67695079 0.876248048 0.004053588 1.754559783 0 -17.01222404 2.278682758 -221795413.1

Param131 0.60225192 0.762056294 0.033028897 1.317107955 0 -15.12932401 2.230821089 -20418117.63

Param132 0.616621664 0.807045526 0.000995121 1.422773468 0 -14.89301463 2.224730646 -9054952.13

Param133 0.644754685 0.839621198 0.002547355 1.603804484 0 -16.88710897 2.308266616 -194533347.6

Param134 0.511501649 0.812389791 0.009486402 1.534588624 0 -16.19681293 2.248357259 -11493941.84

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

32

Page 38: Chua Boon Jin Capstone Project Final Report

Param135 0.273522381 0.689567879 0.03666155 1.108478161 0 -16.36241571 2.060938145 -65651025.1

Param136 0.531885108 0.779148702 8.01317E-18 1.331670555 0 -16.10337452 2.241154569 -47081518.96

Param137 0.559325032 0.777494421 0.004375856 1.268320042 0 -15.97101088 2.215202367 -41277117.8

Param138 0.674393687 0.825046106 9.88925E-07 1.585349028 0 -17.04624989 2.315826315 -30.86537608

Param139 0.474745894 0.720904761 1.84565E-50 1.13607392 0 -16.36543038 2.087828866 -56002744.03

Param140 0.615832896 0.839136139 0.002735494 1.597423147 0 -16.68912418 2.30766104 -155295382.3

Param141 0.395300485 0.747458838 6.83566E-26 1.258581853 0 -16.02955434 2.175527319 -43331015.71

Param142 0.655839058 0.818074645 2.10807E-34 1.578625008 0 -17.0583858 2.338251995 -1040.055651

Param143 0.649742119 0.812978263 1.3531E-22 1.411049608 0 -15.22092815 2.231596223 -18592804.48

Param144 0.656901721 0.797257847 0.001142341 1.406575962 0 -15.90400549 2.286115971 -36384485.11

Param145 0.623907883 0.792546771 3.8027E-19 1.306425883 0 -15.73431698 2.176388098 -31583925.96

Param146 0.493709271 0.766304206 5.19981E-07 1.390959911 0 -15.88325483 2.254469442 -12353265.03

Param147 0.552111783 0.766369857 0.003404153 1.316086355 0 -16.70317343 2.223771997 -2613012.493

Param148 0.565560202 0.766574765 4.19306E-59 1.30209677 0 -15.8831477 2.271347071 -36007949

Param149 0.67098361 0.809103292 4.14093E-12 1.408961405 0 -16.67037482 2.271251289 -151979294.2

Param150 0.485972882 0.763371943 0.049611335 1.293636088 0 -16.14332022 2.263565427 -49140066.28

Param151 0.522062979 0.799403114 0.002969597 1.502116757 0 -15.69184767 2.305084902 -30907458.07

Param152 0.649932197 0.802099198 1.75991E-16 1.509049013 0 -15.6798567 2.330721423 -35607161.77

Param153 0.50294316 0.765595776 0.00148431 1.241868121 0 -15.20317198 2.181045046 -18989141.47

Param154 0.461843671 0.749115498 1.90994E-51 1.226914739 0 -16.37112844 2.176035934 -26583019.94

Param155 0.655058557 0.802650084 3.6952E-10 1.366588972 0 -16.03169776 2.226486758 -19350047.37

Param156 0.382561844 0.759563575 0.026820322 1.340543682 0 -16.11554741 2.25524622 -49115380.98

Param157 0.41817883 0.728961928 0.013864408 1.210065463 0 -16.13512601 2.204005052 -47308991.29

Param158 0.574608741 0.817219249 0.016241628 1.6142521 0 -15.69134168 2.30124087 -26748361.51

Param159 0.524598666 0.728677885 0.020868538 1.186837589 0 -15.56721319 2.182999902 -16570741.73

Param160 0.567052392 0.750507236 1.43056E-63 1.262079703 0 -16.57193725 2.247518249 -808853.6574

Param161 0.64768695 0.791011207 0.003010281 1.435882168 0 -17.05224607 2.294388843 0

Param162 0.479434542 0.746369507 1.10376E-05 1.186641886 0 -16.24976459 2.143858151 -60907147.75

Param163 0.588593405 0.765861477 0.010162182 1.326879822 0 -15.52346949 2.269922579 -9289612.875

Param164 0.638608 0.812843522 3.81768E-34 1.47656826 0 -16.24748222 2.2944691 -10854404.6

Param165 0.650839833 0.804879384 0.000136567 1.456987323 0 -15.58521595 2.266758057 -32296404.31

Param166 0.607659478 0.781942142 1.8245E-24 1.451422864 0 -14.73817732 2.362081768 -6534125.073

Param167 0.583949056 0.760802202 1.282E-05 1.262944402 0 -16.14733265 2.206672953 -18104993.54

Param168 0.497838381 0.773595646 0.033129192 1.325452549 0 -15.76676327 2.21044982 -29079922.18

Param169 0.41940784 0.757923956 0.016057818 1.312818859 0 -16.1454604 2.279883168 -51842972.96

Param170 0.605384448 0.77106387 1.36369E-63 1.26619741 0 -15.97957905 2.173267476 -40596252.6

Param171 0.433704474 0.742172774 9.37518E-46 1.247876744 0 -16.37789586 2.211390056 -27827145.54

Param172 0.614584198 0.797160383 0.000648446 1.352753292 0 -15.9601958 2.229589304 -44748589.87

Param173 0.618504584 0.781859001 1.1605E-05 1.30653674 0 -16.44052887 2.188719393 -63598.87746

Param174 0.57365867 0.770239743 0.015759142 1.273823545 0 -15.77719942 2.185896523 -38653725.38

Param175 0.55020769 0.765129307 0.014177625 1.283892886 0 -15.90993529 2.238529272 -48128615.83

Param176 0.528087489 0.776455552 5.22583E-05 1.257919153 0 -15.43405686 2.152456862 -16373873.01

Param177 0.496082119 0.764115526 1.12084E-12 1.257973931 0 -16.18826255 2.208169597 -50469650.71

Param178 0.652169686 0.799630237 1.5817E-05 1.477511284 0 -15.64469185 2.30031534 -33841032

Param179 0.606139709 0.795394453 0.01153601 1.373160028 0 -15.59079252 2.277538348 -27519325.44

Param180 0.635029701 0.788945504 0.019127693 1.429554576 0 -16.4001298 2.289244356 -5407.932806

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

33

Page 39: Chua Boon Jin Capstone Project Final Report

Param181 0.603480403 0.772567118 2.71584E-35 1.337770613 0 -15.70556272 2.279366417 -32068364.41

Param182 0.627678241 0.810538791 1.35707E-71 1.452196061 0 -16.09457029 2.28142312 -53809220.64

Param183 0.537989395 0.771952836 0.041287977 1.389549535 0 -16.48586104 2.33379066 -176814.4584

Param184 0.567928687 0.766595723 3.0091E-36 1.314289954 0 -15.61635365 2.26705001 -21583086.66

Param185 0.580807938 0.794984091 0.036526892 1.351276949 0 -15.94205584 2.193445897 -42480114.51

Param186 0.550854954 0.771583824 5.01099E-20 1.29902214 0 -16.67503472 2.218600869 -1780816.023

Param187 0.594535852 0.801730436 0.000153707 1.444059783 0 -15.58517488 2.278214272 -25942293.27

Param188 0.60925192 0.783914102 0.061267988 1.353528196 0 -15.83206741 2.230915623 -32284454.69

Param189 0.549898606 0.768919243 0.015147573 1.253310874 0 -15.98000554 2.210934248 -4815559.066

Param190 0.663713081 0.813609265 0.013698092 1.434185864 0 -16.07814172 2.278825358 -52471084.72

Param191 0.567737024 0.781323972 0.017359146 1.411791798 0 -16.24993551 2.296073968 -10241611.22

Param192 0.556133465 0.76720612 0.023077504 1.265340212 0 -15.72661525 2.206139386 -22999638.05

Param193 0.640883185 0.799447535 3.07895E-14 1.417974454 0 -15.89160927 2.317113957 -28067488

Param194 0.570686527 0.764313303 1.01997E-18 1.231237848 0 -16.22399484 2.200351427 -43585037.78

Param195 0.614450683 0.775125256 5.6729E-154 1.261342889 0 -15.95747022 2.21514791 -41711173.78

Param196 0.624347688 0.778721831 0.002540215 1.325925405 0 -16.74223482 2.282109132 -3964522.199

Param197 0.572271079 0.775495676 1.13645E-23 1.277463946 0 -15.76174208 2.224596896 -23824887.93

Param198 0.570234951 0.770897039 7.26177E-06 1.311362021 0 -15.98221991 2.258256226 -12712795.84

Param199 0.662103228 0.803119379 4.90494E-08 1.339421907 0 -16.03664077 2.230009885 -19468298.97

Param200 0.557037354 0.78087344 0.064832385 1.355294039 0 -16.17111505 2.259009433 -10731136.93

Entropy values for Epilepsy Signal

System Bispec1 Bispec2 Kalmogorov Sample Shannon Renyi's AppEn Wentropy

Param1 0.660152962 0.78096093 5.21552E-09 0.808348319 858185.2769 -20.66890234 1.959119931 -4322420996

Param2 0.640312009 0.778272466 0.000394384 1.12376066 0 -20.77288716 2.180516391 -6169330931

Param3 0.665330149 0.790897728 7.75542E-09 0.992562342 0 -20.1735575 2.112414084 -3462060971

Param4 0.193213893 0.688317589 0.001871851 1.075116653 0 -18.46823443 2.011155926 -613601710.5

Param5 0.521008894 0.735306369 1.52518E-20 0.921185615 0 -19.9325194 1.942726522 -2412433983

Param6 0.41133349 0.717408765 0.017942703 1.032418321 0 -17.99617434 2.141787495 -346662961.4

Param7 0.586595596 0.81955884 0.000758951 0.670957367 0 -19.35019505 1.418179803 -1314790827

Param8 0.128853768 0.598578958 0.000118889 0.900294546 0 -20.34062804 1.713924121 -3860343070

Param9 0.385914163 0.715523646 0.006270654 1.016586558 0 -19.93995593 2.111238243 -3205100553

Param10 0.693187379 0.811157395 0.032070731 0.956926865 0 -20.92970301 1.953643246 -5780273240

Param11 0.654399288 0.789606971 0.004093639 0.891614869 0 -20.10190646 2.015517994 -4941471531

Param12 0.544034697 0.715505952 9.69803E-47 0.725131571 0 -20.67035306 1.652238994 -8183566647

Param13 0.465729356 0.730082675 3.14446E-47 0.793891872 0 -20.90364844 1.637112941 -8255361970

Param14 0.605149616 0.741291393 0.15547003 0.903795012 0 -18.37013544 2.010985707 -123294255

Param15 0.524321381 0.734217343 1.67173E-46 0.853810383 0 -19.04636626 1.765343352 -1130042095

Param16 0.413882479 0.663325353 0.275047346 0.708856049 0 -17.64178866 1.482936973 -288679671

Param17 0.633537705 0.786814984 0.000290136 1.119684123 0 -21.08583063 2.182169417 -7991470850

Param18 0.568228912 0.778346143 8.86865E-36 0.798224003 0 -18.31110341 1.642810541 -463663808.2

Param19 0.566877855 0.731971789 2.5842E-232 0.848299359 0 -20.54983695 1.827125019 -6767896875

Param20 0.198332722 0.690601246 1.53439E-69 1.007580959 0 -18.85122538 1.975266122 -897212097.3

Param21 0.544993842 0.715111935 8.33614E-05 0.788793437 0 -17.95839117 1.81616136 -444200283.9

Param22 0.619758226 0.771242023 2.29525E-75 0.836176779 0 -18.87040652 1.998767744 -320114026

Param23 0.611640109 0.765171219 1.90551E-25 0.871830115 0 -19.05827054 2.010310715 -584739203.2

Param24 0.623221012 0.758535657 5.47293E-20 1.158141724 0 -19.69393264 2.272426738 -1715557807

Param25 0.524799674 0.722672089 1.00086E-42 0.79996684 0 -20.10789566 1.748394148 -2484742156

Param26 0.335019938 0.693115316 1.2523E-112 0.9481852 0 -19.12931945 1.977778126 -1271574170

Param27 0.656028562 0.781131562 0.011653099 1.136806717 0 -20.88592402 2.197393725 -5346387677

Param28 0.498471781 0.715321583 9.24636E-33 0.990881557 0 -20.65557169 1.994964644 -7600333752

Param29 0.389875226 0.674532205 1.128E-133 0.841853307 0 -18.8420898 1.731072257 -461781079.5

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

34

Page 40: Chua Boon Jin Capstone Project Final Report

Param30 0.656320435 0.789073076 0.118036297 0.986233679 0 -20.6149275 2.151379683 -6521442028

Param31 0.247264381 0.681767725 0.002868347 0.760663681 0 -19.63332331 1.621467646 -1750366856

Param32 0.544972726 0.731267489 6.52311E-06 0.78750866 0 -17.87768467 1.701849856 -177911822.1

Param33 0.497547093 0.694704483 0.342392445 0.826391681 0 -20.0424194 1.875366833 -1893208191

Param34 0.657559722 0.790956178 0.087416204 1.067396312 0 -20.19347399 2.159907686 -5189251929

Param35 0.624092664 0.786009609 0.007113149 1.260820558 0 -20.85575034 2.191915383 -7163314341

Param36 0.319879678 0.673641528 0.000171558 0.954784908 0 -18.79855679 2.086115398 -863826291.8

Param37 0.669993308 0.789453095 0.000857988 0.806050791 0 -21.08159723 1.953127172 -5380659811

Param38 0.566015242 0.724277822 1.16643E-08 0.830699003 0 -18.57758378 1.866986569 -827786968.4

Param39 0.244333496 0.662088832 1.10721E-06 1.064263465 0 -17.65330343 2.086388802 -227318904.6

Param40 0.410540453 0.738780444 0.000443997 0.812853756 0 -18.9207249 1.680457374 -923639884.5

Param41 0.570742664 0.755877099 0.108088016 0.853823074 0 -20.4635943 1.920459532 -3595533125

Param42 0.203566617 0.69325988 4.26354E-06 1.050230046 0 -19.908162 1.904808676 -1949981985

Param43 0.555995871 0.723262963 0.028854853 1.119455797 0 -17.72720913 2.209488183 -190123718.4

Param44 0.487270811 0.716087733 2.39112E-05 1.043866191 0 -20.24482127 2.169571987 -5679402416

Param45 0.37221263 0.723573741 4.6909E-26 0.695461373 0 -18.85377785 1.494583932 -1316196148

Param46 0.358208836 0.731981973 1.09801E-06 0.887416587 0 -19.59984323 1.999221537 -2130438705

Param47 0.687059052 0.80584748 1.65343E-22 0.868989825 0 -21.09122888 1.914540237 -5702808513

Param48 0.255565345 0.713105846 0.028480556 0.952908958 0 -19.33757982 2.072850723 -1920577415

Param49 0.648296521 0.79687507 5.67302E-07 0.975319493 0 -20.72770534 2.128094952 -4815055716

Param50 0.417463199 0.699289746 0.137042143 0.899923632 0 -19.52727383 1.971138526 -1948139938

Param51 0.582687975 0.745592492 2.72718E-43 0.835352811 0 -18.05788065 1.871492712 -230256000.9

Param52 0.670505056 0.800101367 4.21816E-19 1.138913146 0 -19.3700228 2.224297027 -1430468247

Param53 0.503736272 0.743299156 1.3738E-102 0.848154864 0 -19.20315316 1.781388986 -1236349495

Param54 0.242190327 0.675095517 3.35811E-08 0.96823158 0 -19.37821393 1.923056603 -1566498776

Param55 0.564995244 0.71441595 1.02008E-07 1.062830833 0 -18.26511136 2.118248491 -436600576.4

Param56 0.590150264 0.739811229 0.269828324 0.644062227 0 -18.47170894 1.447747955 -944749583.9

Param57 0.211069908 0.67440218 0.059967007 0.970285795 0 -19.52351307 1.890787365 -1230048006

Param58 0.534819645 0.738280989 5.53143E-18 0.935693979 0 -19.79764512 1.976133094 -3528427406

Param59 0.55221545 0.728291522 0.11834955 0.922479096 0 -21.15330347 1.873792832 -12358007733

Param60 0.535897679 0.757498729 0.000500833 0.656499822 0 -20.72167099 1.680687383 -3183720948

Param61 0.177956789 0.644963262 0.003176158 1.108207169 0 -19.38997114 1.968153765 -1331797648

Param62 0.610273288 0.754896379 3.59003E-61 0.961824563 0 -19.67936181 2.042072064 -2361192715

Param63 0.421589395 0.713925589 0.004551641 0.994445351 0 -18.03267274 2.124273773 -219198015.6

Param64 0.594609042 0.73484227 0.12561631 0.96887997 0 -18.17039143 2.094796611 -468563943.7

Param65 0.547561239 0.704070322 0.203926578 0.700477841 0 -20.18625685 1.683946128 -5370757213

Param66 0.526645724 0.731900337 0.094725745 1.014209411 0 -19.61601042 2.088817012 -1566124518

Param67 0.416247875 0.738100313 2.3835E-07 0.970194811 0 -20.71241914 2.123203833 -5332697004

Param68 0.608452234 0.785901315 2.4593E-13 0.94136251 0 -20.96226756 2.082132798 -5457477184

Param69 0.48363852 0.736544704 1.45338E-08 0.839914759 0 -19.23076953 1.751804751 -1217570143

Param70 0.258613336 0.671106627 4.49716E-06 1.028832778 0 -18.90722813 2.114247534 -520568007

Param71 0.580993539 0.729162432 7.54655E-19 0.915081832 0 -18.36460688 1.884670872 -692598409.1

Param72 0.208068233 0.689964304 0.234493531 0.996488578 0 -19.38772213 1.95271231 -1758525138

Param73 0.570800446 0.720912018 0.000683424 0.939182178 0 -19.90929322 2.063745194 -4308816980

Param74 0.550178329 0.77295189 1.2312E-128 0.863262061 0 -17.89054225 1.859070753 -76687646.63

Param75 0.302039686 0.674907052 5.08866E-05 0.956582041 0 -18.92824338 2.046713821 -594101981.1

Param76 0.6697321 0.794273271 9.63522E-06 0.910706239 0 -20.72002345 2.017347222 -4288228612

Param77 0.600114942 0.738746869 0.000189456 0.990876852 0 -17.86745805 2.127812832 -105399987.5

Param78 0.609653006 0.760096013 9.06362E-12 0.889902998 0 -18.04959389 1.966974023 -208559127.9

Param79 0.509449785 0.751302531 2.05435E-05 0.792180106 0 -20.79849357 1.755621645 -8254843979

Param80 0.174867236 0.622830312 0.321252886 0.804578393 0 -20.82249231 1.357030559 -5964126236

Param81 0.559100813 0.756399629 0.000906315 0.859377962 0 -20.55965241 1.911883469 -4343060243

Param82 0.482682993 0.709606453 6.35363E-08 0.950207127 0 -20.29387118 1.939932152 -4515764138

Param83 0.289751555 0.762453924 9.7847E-144 1.150306965 0 -17.70201727 2.174167365 -41818578.94

Param84 0.457791645 0.714539875 3.84399E-06 0.629647299 0 -18.20465297 1.346248033 -264892350.5

Param85 0.665016563 0.787895474 3.50456E-17 0.87213719 0 -20.53202833 2.003513661 -3717507289

Param86 0.632727808 0.797530384 0.012946316 1.106196478 0 -18.6746942 2.162536289 -702504596.8

Param87 0.506882153 0.696363499 0.232479268 0.816267429 0 -20.17455817 1.865654164 -2812687821

Param88 0.338625711 0.688181398 0.150918297 0.958837464 0 -18.76621108 2.022057791 -526257391.9

Param89 0.374675307 0.682649563 2.07735E-08 0.853900141 0 -18.86086206 1.697435058 -1301535454

Param90 0.695818595 0.819816083 0.000451481 1.402840199 0 -19.55757794 2.266608334 -1443790492

Param91 0.537396722 0.743193851 0.062033797 0.989236928 0 -20.37737853 2.075590106 -3639786693BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

35

Page 41: Chua Boon Jin Capstone Project Final Report

Param92 0.596711794 0.755289424 0.001760973 1.044238711 0 -19.48058727 2.136625812 -1793244901

Param93 0.50573945 0.764455126 4.8145E-05 0.677894578 0 -20.73155639 1.728960936 -4350684020

Param94 0.209828555 0.691672646 1.18414E-06 1.007301083 0 -19.72157635 1.881687846 -1491235313

Param95 0.199253426 0.692687366 0.001103656 1.075138623 0 -19.16883723 2.017985325 -1397640148

Param96 0.50400854 0.717842104 4.96722E-09 1.049618259 0 -17.84806413 2.231689907 -131544577.2

Param97 0.214620502 0.644434904 5.84956E-64 0.759320189 0 -20.94788335 1.351867076 -6377608544

Param98 0.194163681 0.651026868 2.76145E-09 1.027429175 0 -19.68160303 1.881513306 -1662960539

Param99 0.579851566 0.786691115 0.000821253 0.749289552 0 -20.2027611 1.883168633 -6020712633

Param100 0.51103737 0.717072026 0.093281202 1.071764765 0 -19.43380478 2.139690857 -1793790541

Entropy values for Pre-Ictal Signal

System Bispec1 Bispec2 Kalmogorov Sample Shannon Renyi's AppEn Wentropy

Param1 0.439538677 0.678324856 1.30274E-35 1.140326406 1358160.409 -15.71781404 1.918114991 -52470390.27

Param2 0.356565042 0.615705589 0 0.543176551 1366764.374 -18.16098498 0.937171624 -760567434.9

Param3 0.449302499 0.689452652 1.96419E-55 0.956769446 0 -16.98427159 1.9432013 -54146109.98

Param4 0.507189396 0.676163372 0.026261414 1.017012816 0 -16.20847003 1.940057403 -3615760.565

Param5 0.520701458 0.731327547 1.2188E-137 0.963243116 0 -17.21989841 2.029114219 -122976943.1

Param6 0.499363394 0.680643079 1.28268E-05 1.148202784 0 -15.73139395 2.064756712 -293351.6649

Param7 0.52996767 0.737611239 0.039731705 1.263223976 0 -16.04291273 2.122888882 -7960440.33

Param8 0.411952233 0.632950541 1.78454E-55 0.579376476 0 -17.62923 1.089845521 -314426203

Param9 0.385817728 0.640046389 0.256582076 0.381895475 0 -20.49184524 0.54299444 -9496832031

Param10 0.392964552 0.626316752 2.1064E-95 0.553669649 0 -18.22218711 1.014651823 -795878326.5

Param11 0.314194005 0.64697957 9.18394E-41 0.854363956 0 -16.67757669 1.762570984 -11718618.96

Param12 0.541542411 0.692406644 6.71882E-13 1.000461163 0 -15.78285827 1.992236584 -25763550.66

Param13 0.543718116 0.701833745 3.5466E-110 1.180328394 0 -15.03316583 2.138430477 -21395139.92

Param14 0.513931423 0.679685546 6.30502E-31 1.131160262 0 -15.34008598 2.104259062 -4377456.637

Param15 0.466701214 0.663091951 1.40771E-09 1.071115313 0 -15.49354033 2.049771857 -36886279.24

Param16 0.508817571 0.72391298 0.020383866 1.170208847 0 -16.23834693 2.06483132 -48861280.36

Param17 0.494071379 0.655565403 0.075642837 1.030062612 0 -15.56606046 2.108729844 -16703816.25

Param18 0.553931387 0.713165894 0.059495882 1.179419812 0 -16.62668921 2.206699552 -76151979

Param19 0.456001967 0.693607903 1.65711E-08 0.967973839 0 -15.83062982 1.967777899 -1517006.377

Param20 0.47165031 0.649665871 1.2492E-121 0.935717879 0 -15.73866737 1.803351142 -46397692.95

Param21 0.534219173 0.730446059 0.010252928 0.847247255 0 -18.26796626 1.703459884 -302133575.6

Param22 0.426756069 0.661903961 2.86603E-25 0.959047281 0 -16.8651613 1.878453489 -62349049.18

Param23 0.545689123 0.701558431 3.4508E-138 1.12177762 0 -16.68640525 2.173271186 -62781204.67

Param24 0.523568039 0.713045149 1.63583E-26 1.136320754 0 -17.03157259 2.042546704 -142911342.6

Param25 0.468528067 0.681069265 0.010375913 0.999842621 0 -17.34774728 1.920500946 -183128512

Param26 0.514879202 0.70471661 1.23061E-05 1.071435498 0 -14.39526505 1.885794583 -7600790.063

Param27 0.445798288 0.639232204 5.1467E-05 1.008927728 0 -16.93377042 1.709621605 -25272448.04

Param28 0.521048838 0.70131235 1.12113E-07 1.022153417 0 -16.24342613 2.019768871 -2714962.247

Param29 0.3393317 0.603927166 1.1763E-205 0.578217534 0 -17.62017182 1.010637675 -306439718

Param30 0.350269273 0.655443875 1.75495E-09 0.553012879 0 -18.32736749 0.927212906 -622249900.4

Param31 0.557465477 0.758708243 2.325E-196 0.992413953 0 -17.30842747 2.06682786 -154680289.6

Param32 0.336107655 0.691356981 0.122899544 0.91461549 0 -17.19112018 1.824482026 -72033907.67

Param33 0.548634999 0.696759072 0.007625511 0.985009621 0 -15.8391012 2.012123713 -17011780.12

Param34 0.537371205 0.693724357 2.77928E-05 1.179079943 0 -14.70954055 2.126203261 -9200057.968

Param35 0.489448849 0.653541156 0.001623935 1.01808952 0 -15.82303402 2.109099844 -16654091.27

Param36 0.501844774 0.662337858 5.7063E-144 0.971969908 0 -15.5722059 1.96917638 -17472591.53

Param37 0.484491934 0.72318961 0.059146645 1.261574357 0 -16.26114618 2.190367345 -83220423.35

Param38 0.480662455 0.667695103 6.6133E-114 1.015189364 0 -16.36533792 1.95798411 -34068328.04

Param39 0.442125388 0.616724686 0.185816644 0.871602245 0 -16.63331336 1.683025914 -47468905.51

Param40 0.421126163 0.69819765 0.021407083 1.063440219 0 -15.14724472 1.929369204 -15080648.56

Param41 0.450296567 0.629056134 9.94124E-05 0.6378656 0 -16.96321226 1.154619864 -71295653.71

Param42 0.447481596 0.701111619 0.105254702 1.066696487 0 -15.07115765 1.9345719 -22387241.16

Param43 0.531236779 0.693612905 1.51668E-26 1.17767871 0 -16.77093414 2.261186647 -131946970.3

Param44 0.523098299 0.690179883 1.63502E-21 0.98745293 0 -17.29948954 1.979732345 -2364399.552

Param45 0.496617233 0.727469964 4.70362E-07 1.161412081 0 -16.01453341 2.038987585 -24165750.28

Param46 0.452085968 0.707223077 0.014174358 1.195746127 0 -16.21981163 2.155130204 -80991446.08

Param47 0.494195672 0.719427744 1.27019E-06 1.163236839 0 -17.06264924 2.061541231 -230579846.7

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

36

Page 42: Chua Boon Jin Capstone Project Final Report

Param48 0.470611513 0.704013866 3.06695E-05 1.154693016 0 -16.64693672 2.048008517 -98049145.37

Param49 0.42731342 0.673512136 9.749E-118 0.906869506 0 -15.75289619 1.772966429 -21400695.16

Param50 0.381718995 0.577997279 0.086891449 0.830154141 0 -16.72088893 1.593830538 -93455879.3

Param51 0.447340046 0.692002003 5.70508E-41 0.971272857 0 -16.92041544 1.974374011 -80440357.51

Param52 0.485513715 0.663650908 0.012731477 0.939917931 0 -15.79334799 1.875517623 -12157046.31

Param53 0.369597856 0.609437219 0.035232164 0.894920271 0 -16.00979749 1.649123422 -31162517.67

Param54 0.55057608 0.704740127 1.87654E-20 1.132942437 0 -16.76670342 2.177545635 -50554542.86

Param55 0.484425803 0.673929702 6.66026E-55 0.945765349 0 -16.4871148 1.898654134 -60815857.91

Param56 0.510853382 0.726620656 0.125796878 1.100218354 0 -15.722086 2.045315357 -39010049.45

Param57 0.399593783 0.603828277 1.0761E-107 0.883806308 0 -16.39369123 1.695480728 -101510040.2

Param58 0.499831122 0.670510482 0.03454652 1.116970863 0 -15.35168184 2.11734137 -12548683.59

Param59 0.500768758 0.66574056 1.00343E-05 0.972558103 0 -15.92028061 1.909829214 -25713976.64

Param60 0.46650443 0.676135394 1.11209E-50 0.826769701 0 -19.82785362 1.602757313 -2427090682

Param61 0.426573516 0.678553356 7.28448E-87 0.842348095 0 -17.60314129 1.682427386 -242499915.9

Param62 0.390881917 0.604511058 0.002294768 0.846037819 0 -16.53829941 1.667884357 -49945770.09

Param63 0.435751961 0.667686452 0.010267559 0.873852033 0 -15.96024651 1.724924216 -36698287.79

Param64 0.489528027 0.699415149 1.48846E-07 0.832972958 0 -16.80674448 1.674852053 -53188378.6

Param65 0.571853365 0.743751304 1.70964E-73 1.269651114 0 -16.29427304 2.179933904 -32360143.54

Param66 0.297311209 0.62943997 0.006718258 0.866022428 0 -16.39747026 1.773283513 -17526639.64

Param67 0.491042772 0.662009003 0.044094585 0.95236652 0 -16.18765184 1.863313668 -23683835.42

Param68 0.496940179 0.67631742 0.000290498 1.096357143 0 -15.9061006 2.097137982 -62628780.93

Param69 0.498441218 0.689007422 3.3821E-102 1.020790253 0 -16.04636547 1.926330816 -754962.0119

Param70 0.407181009 0.695167469 0.025011553 0.757665878 0 -17.76704074 1.582664779 -403441239.2

Param71 0.485837675 0.673725261 4.12711E-16 1.016824825 0 -14.84503961 1.911353955 -5017011.687

Param72 0.521575063 0.725062352 2.20618E-38 1.155491652 0 -15.17376341 2.011077935 -9752488.029

Param73 0.479140514 0.654828897 0.229054303 0.85271051 0 -18.79609534 1.678311818 -673572671.1

Param74 0.549835889 0.729621064 2.6835E-39 1.177460268 0 -16.72437417 2.093482766 -83663408.67

Param75 0.482012877 0.69116311 4.95035E-43 1.161077227 0 -15.54459519 2.125601915 -42978931.02

Param76 0.3750712 0.658541755 2.00701E-10 0.459417486 0 -19.19013479 0.757937629 -1830669135

Param77 0.585619878 0.74622887 0.006805575 1.301291984 0 -16.42072018 2.215474769 -15916046.05

Param78 0.482844345 0.719822122 1.40067E-52 1.159791591 0 -15.96133973 2.107416179 -28070040.02

Param79 0.428606526 0.614678058 6.1552E-143 0.945770587 0 -16.79933253 1.65181266 -11743640.45

Param80 0.51558416 0.728622724 0.010937269 1.258842845 0 -16.00333778 2.180734473 -26098146.71

Param81 0.480163946 0.690781511 0.070645941 1.217778049 0 -15.33354806 2.17285236 -33446001.74

Param82 0.409942325 0.622902641 2.0426E-34 0.86852982 0 -17.19582817 1.637108978 -53184882.44

Param83 0.481941959 0.698204097 2.00429E-71 1.191623021 0 -15.9363692 2.096965157 -123134.0778

Param84 0.473704427 0.671442541 0.134619323 0.975550991 0 -16.06733348 1.891780842 -53498164.99

Param85 0.591872686 0.742731633 5.3736E-10 1.37338448 0 -15.94994122 2.283366683 -32960.85479

Param86 0.4128234 0.638554207 2.5115E-140 0.84825946 0 -18.25928507 1.667041137 -549535678.8

Param87 0.447462092 0.66445246 8.11553E-59 1.028960604 0 -15.51450595 1.93474141 -40562359.64

Param88 0.543216898 0.716567634 2.47965E-86 1.130024769 0 -14.37777826 2.038284716 -6160640.936

Param89 0.518152292 0.730190918 1.70749E-19 1.111143453 0 -17.13004803 2.034808843 -246394687.1

Param90 0.442812845 0.643372998 0.13988212 0.889580643 0 -17.15302619 1.785548577 -63175948.07

Param91 0.481998628 0.671306488 0.033648774 1.037645188 0 -17.27936053 1.964704928 -167196011.6

Param92 0.38643222 0.696041415 0.000512162 0.815173795 0 -16.86278164 1.859811678 -22970951.69

Param93 0.412324464 0.665823794 3.15106E-37 1.071331609 0 -15.18080062 1.744197925 -11357113.45

Param94 0.545433646 0.726495098 1.54132E-05 1.038571658 0 -16.56972169 2.048058423 -2792807.71

Param95 0.431446777 0.639030446 0.065061106 1.018809323 0 -16.6257101 1.746427261 -72287281.7

Param96 0.510077122 0.720528092 0.046044562 1.100271797 0 -16.72080169 2.014965912 -109918015.3

Param97 0.527618338 0.725772837 7.3242E-122 1.161719426 0 -17.31712108 2.074251217 -297355116.5

Param98 0.432440684 0.633381137 0.22943327 0.717748256 0 -17.07992185 1.628839106 -97452486.57

Param99 0.529209227 0.687426522 9.5171E-128 1.057275095 0 -14.91561041 1.996192922 -5012882.904

Param100 0.520030091 0.705117929 0.084165798 1.14615119 0 -15.99636069 2.081375425 -583343.4057

Param101 0.511748021 0.660982546 0.007254019 0.978074468 0 -16.23724788 1.943581085 -19385280.51

Param102 0.472545164 0.652304956 0.083058826 0.907542907 0 -16.72219127 1.822985975 -82499499.36

Param103 0.482171256 0.684248442 3.98437E-13 1.012356648 0 -16.06214902 1.927882727 -19363071.27

Param104 0.471601782 0.676129916 4.92012E-67 1.023856707 0 -16.30031854 1.873653666 -92318912.53

Param105 0.479214574 0.756405517 1.0978E-156 1.239567295 0 -17.97940006 2.091787776 -421005958.1

Param106 0.478704963 0.667665792 2.73305E-29 0.877401082 0 -16.3998602 1.789230716 -73080615.3

Param107 0.488851413 0.662384 1.4455E-148 0.974761534 0 -16.05636364 1.735400632 -37259365.65

Param108 0.428249738 0.670140075 0.00877908 1.030231454 0 -16.30126909 1.837745796 -2333660.617

Param109 0.495593656 0.673135395 0.136859587 1.029066566 0 -16.78414914 1.941582427 -149047495.2BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

37

Page 43: Chua Boon Jin Capstone Project Final Report

Param110 0.474325776 0.680218467 1.44204E-05 0.983578169 0 -15.52230564 1.897966381 -14315741.09

Param111 0.458405405 0.668788537 3.58949E-68 1.077343225 0 -14.59640668 1.887556536 -4969120.749

Param112 0.488349503 0.665716549 0.002559286 0.898286206 0 -16.51434112 1.817628173 -41088318.77

Param113 0.380052516 0.648495711 0.193655037 0.916181112 0 -15.74279882 1.744930487 -45390206.03

Param114 0.484547525 0.6996489 0.069573294 1.032124028 0 -16.82979566 1.965728886 -658009.7843

Param115 0.477920957 0.714833776 1.17386E-39 1.208285241 0 -16.84702075 2.013030121 -84899316.5

Param116 0.41346988 0.655318733 1.59535E-64 0.910031085 0 -16.23644573 1.739463731 -72469670.67

Param117 0.523768057 0.737547449 2.60017E-27 1.258961984 0 -17.2152661 2.101258458 -21754424.97

Param118 0.562064287 0.695554786 0.137161465 1.041373771 0 -15.7971521 2.04742516 -51567490.19

Param119 0.402280299 0.6399557 0.046688927 0.953520104 0 -16.59246847 1.743446855 -126265203.8

Param120 0.55048711 0.688121117 0.001559855 1.028765239 0 -16.24333209 1.940582636 -2354162.655

Param121 0.456321292 0.650976197 0.001664859 0.936074123 0 -16.2915659 1.747555255 -37231091.77

Param122 0.49392707 0.668517779 7.0391E-127 0.926975284 0 -16.30579414 1.85649161 -21289241.85

Param123 0.312077426 0.65413125 1.22824E-71 1.1026273 0 -14.93811115 1.776533759 -7056625.198

Param124 0.478527328 0.695138136 2.4413E-06 1.060818506 0 -16.75423318 1.893225659 -103271227.8

Param125 0.509118711 0.667086431 2.9922E-131 1.009486384 0 -15.98083514 1.993192972 -13828318.36

Param126 0.455414665 0.63995402 4.25072E-10 0.974799771 0 -15.06915371 1.747052071 -3398467.348

Param127 0.506465443 0.687848798 0.028865505 1.08970651 0 -15.02551215 2.002044498 -14811492.21

Param128 0.450035994 0.664512234 1.65727E-33 1.151401501 0 -14.28481769 1.965124745 -2460529.064

Param129 0.432038192 0.643139794 1.17465E-22 0.91977602 0 -16.58017503 1.687693371 -122050995.1

Param130 0.426300574 0.65736625 4.5744E-143 0.947441885 0 -16.54172335 1.738289539 -13949529.48

Param131 0.506878333 0.659748473 1.0314E-102 1.01336882 0 -15.88224293 2.04718052 -30303227.03

Param132 0.467512946 0.66035135 0.101335 0.991736275 0 -16.24315711 1.869516256 -3280831.965

Param133 0.423776524 0.596454841 1.79098E-05 0.88948339 0 -16.7564987 1.631640235 -66736349.04

Param134 0.341450253 0.573314411 0.034863865 0.847390343 0 -16.75500184 1.595787324 -67571724.22

Param135 0.49580255 0.665527794 5.18939E-96 1.008324904 0 -16.38472795 1.928582496 -4692267.94

Param136 0.46073727 0.602222239 0.038248308 0.858974156 0 -16.55812243 1.662413831 -62592560.29

Param137 0.430653524 0.676309681 6.07505E-05 0.922438536 0 -16.34520158 1.784866505 -21578203.71

Param138 0.435657555 0.682269842 5.33129E-36 1.012873354 0 -16.29637672 1.776865315 -89240119.77

Param139 0.455074377 0.693889622 9.43875E-12 1.145489486 0 -16.52584255 2.028835167 -80279293.18

Param140 0.45281663 0.646138757 6.92407E-19 0.930676989 0 -16.43155065 1.747594452 -37301625.8

Param141 0.378495114 0.617399772 1.15175E-15 1.088598066 0 -15.08495167 1.771729773 -9389839.66

Param142 0.447387269 0.687161501 0.086115606 1.043992242 0 -16.90440762 1.870145334 -77669524.06

Param143 0.426661518 0.676556291 2.5842E-11 1.075422211 0 -16.72466383 1.941361555 -61433697.62

Param144 0.384674438 0.661725015 2.03556E-26 0.986085922 0 -15.99837868 1.824837298 -28176968.57

Param145 0.500588798 0.679634351 9.756E-145 0.994496269 0 -16.68587165 1.943852886 -3608526.225

Param146 0.358710272 0.645107522 0.012064447 1.00623807 0 -15.21736793 1.707809189 -7159110.928

Param147 0.494364139 0.671216319 1.67791E-50 1.025755548 0 -16.77381372 1.946757549 -58768188.89

Param148 0.631481863 0.791404778 3.36317E-22 1.358972972 0 -16.29234908 2.254592688 -39653870.37

Param149 0.501078675 0.711724267 1.6134E-137 1.055887947 0 -16.76792914 2.015831216 -169781683.4

Param150 0.410486321 0.697585438 0.056364081 1.223689922 0 -17.44922262 1.953756402 -199314409

Param151 0.486951482 0.660037889 0.023984996 0.906593935 0 -16.91721825 1.797439403 -127556857.7

Param152 0.571248394 0.778192881 0.034503037 1.380496541 0 -16.7666011 2.208208463 -100684423

Param153 0.472888642 0.665806058 2.4022E-17 0.937301572 0 -16.69565671 1.84720311 -23935758.5

Param154 0.418264904 0.65084327 1.34943E-20 0.901590509 0 -16.6024362 1.656645922 -58780432.12

Param155 0.5138802 0.668316304 4.68237E-05 1.041957991 0 -15.80502821 2.021583937 -10118772.95

Param156 0.48664032 0.722942591 4.38385E-19 1.19413893 0 -16.829265 2.02796027 -80330153.73

Param157 0.455371653 0.673343837 0.003638052 1.203382433 0 -14.3972104 2.026307297 -2191844.981

Param158 0.439929674 0.646719807 0.098895568 0.851912158 0 -16.6776811 1.675453043 -7033646.641

Param159 0.50375386 0.696085908 1.3077E-100 1.214660566 0 -14.34966259 1.981008625 -1662402.575

Param160 0.498546478 0.671089893 0.093464589 0.937527006 0 -16.79549082 1.834285952 -66624442.68

Param161 0.531771953 0.704698048 9.183E-147 1.065043004 0 -15.21141386 1.9777839 -11287552.06

Param162 0.478163355 0.688216808 1.0466E-102 1.111770991 0 -15.47578587 1.961984637 -32820570.64

Param163 0.558347412 0.705856617 1.4628E-83 1.062575793 0 -15.51893596 2.041672056 -6151081.838

Param164 0.496209053 0.665805848 4.86261E-47 0.951889662 0 -16.1267609 1.912983206 -31078110.75

Param165 0.420835204 0.664738271 4.2738E-99 0.902469979 0 -15.98686732 1.752067824 -7954744.576

Param166 0.434415761 0.577843016 2.71937E-13 0.816495319 0 -16.97023776 1.583842881 -84485754.6

Param167 0.455858181 0.675465942 2.4757E-117 1.127086663 0 -15.16755348 1.892607583 -4839327.044

Param168 0.448295954 0.705681996 6.35659E-06 1.21803863 0 -17.19399603 1.963446496 -50683553.25

Param169 0.530056134 0.68909372 1.12634E-10 1.004894061 0 -15.84860969 1.988458507 -38862190.97

Param170 0.56082447 0.706137947 1.50923E-36 0.996421217 0 -16.32881944 2.023530549 -91169633.44

Param171 0.388552709 0.644886017 3.2457E-15 1.03791955 0 -17.14913345 1.809835511 -102350408.9BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

38

Page 44: Chua Boon Jin Capstone Project Final Report

Param172 0.517407437 0.658398713 1.61954E-07 0.940273811 0 -16.02664505 1.897348354 -26316834.51

Param173 0.484544421 0.685719805 0.000188684 1.000772641 0 -15.87667241 1.893493468 -14981035

Param174 0.477510708 0.684092996 1.4225E-63 1.063618499 0 -14.4237614 1.817039269 -4455467.249

Param175 0.485296421 0.673288455 7.2595E-131 1.031246908 0 -16.26653083 1.890972144 -84660181.01

Param176 0.439830268 0.668558056 7.90008E-06 0.996043045 0 -16.37584498 1.815787222 -11973489.55

Param177 0.553943838 0.76789716 6.53609E-05 1.382119025 0 -17.48978013 2.203115922 -9471998.621

Param178 0.389135399 0.670122504 5.36825E-58 1.093456134 0 -16.85444058 1.875674311 -101307451.6

Param179 0.453415086 0.675414506 3.92807E-42 1.073821637 0 -16.91441823 1.997264707 -111423470.5

Param180 0.491447651 0.723925304 0.045613121 1.272426595 0 -17.59219347 2.056987773 -23294460.8

Param181 0.432725805 0.65911522 0.113280026 1.108294958 0 -15.35864241 1.892388266 -30226993.8

Param182 0.514992908 0.698573006 2.7104E-06 1.073819452 0 -16.16334326 1.924587854 -80709863.55

Param183 0.523963112 0.700998784 0.001029816 1.225824466 0 -17.04289631 2.042902409 0

Param184 0.536649363 0.702023618 0.130440612 0.974529296 0 -15.74682311 1.917660895 -19353155.83

Param185 0.576507524 0.768362088 0.019474329 1.294575067 0 -16.43096772 2.161249045 -45187132.37

Param186 0.578708099 0.719885697 8.03444E-10 1.1232834 0 -15.54469491 2.092033566 -7529776.557

Param187 0.507567203 0.67940094 0.087102972 0.956210383 0 -15.52070219 1.851176574 -38790548.71

Param188 0.539646991 0.697763438 2.8731E-108 1.077640422 0 -15.43769469 2.04308637 -30499930.97

Param189 0.399500985 0.565911974 2.82695E-48 0.808532038 0 -17.02948644 1.510842449 -20655454.84

Param190 0.409091097 0.662466071 4.40506E-62 1.019093611 0 -15.34063578 1.823210724 -6792600.346

Param191 0.50499529 0.750598269 0.036360916 1.258417157 0 -17.4137788 2.163426446 -171166864.1

Param192 0.450863096 0.711332871 2.31092E-07 1.260626695 0 -17.16785801 2.052387159 -46834882.19

Param193 0.462162897 0.637474021 0.017762794 1.006758983 0 -14.99931688 1.768628625 -4882379.884

Param194 0.453906769 0.663617564 0.102288932 1.0356017 0 -17.02501788 1.965001154 -91421676.1

Param195 0.432989334 0.601664591 1.2746E-84 0.880470204 0 -16.82016179 1.617613541 -93069412.82

Param196 0.501071453 0.741243669 4.33174E-17 1.26482824 0 -16.8364361 2.093464539 -92706247.73

Param197 0.443551421 0.668489218 0.025887381 1.198196233 0 -17.0523978 2.05053601 0

Param198 0.51338921 0.70829459 2.23398E-05 1.112430712 0 -16.75223146 1.941757276 -26452983

Param199 0.344166183 0.56726236 1.25968E-53 0.838693263 0 -16.72968483 1.577302382 -83929726.38

Param200 0.438625635 0.653893156 4.70033E-14 0.935487786 0 -16.19816833 1.716223051 -35694427.68

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

39

Page 45: Chua Boon Jin Capstone Project Final Report

Appendix B – Entropy Codes

Bi-Spectral Entropy Codes

function [t, t1] = bisp_entropy_start(data) nfft = 2048; %length of data t = bisp_entropy(data,nfft); t1 = bisp_entropy1(data,nfft); Bi_entropies=[t t1];

%bispectrum plot%function bisp_plot(input,Xsize)%input = data points%Xsize = length of datafunction ent= bisp_entropy(input,Xsize) Fx_input = fft(input,Xsize); %convert to freq domain from time domain, the discrete fourier transform of signal "input" is found by taking the fast fourier transform Fx_input(1) = 0 + i*0; %set dc = 0 else interpolation will cause dc dependenceFx_input(Xsize/2+2) = 0 + i*0; %set = 0 else interpolation will cause problem %bispectrum in the third cumulant functionB_input = zeros(Xsize/2, Xsize/4); %to form the trianglefor k1 = 1:Xsize/2; for k2 = 1:min(k1,Xsize/2-k1) %returns an array the same size as k1 and Xsize/2-k1 with the smallest elements taken from k1 or Xsize/2-k1 B_input(k1,k2) = Fx_input(k1) * Fx_input(k2) * conj(Fx_input(k1+k2-1)); %complex conjugate: real - i*imag endend %normalized bispectral entropy P1x1 = B_input(find(B_input)); %return value that is non-zer0x2 = conj(x1); % conjugate of x1B_ent = x1.*x2; B_ent = B_ent./sum(B_ent); %computing the probability[m,n] = size(B_ent); ent = -sum(B_ent.*log(eps+B_ent))/log(m); %log(m): average to obtain relative estimate of bispectrum

%bispectrum plot%function bisp_plot(input,Xsize)function ent= bisp_entropy1(input,Xsize) Fx_input = fft(input,Xsize); %direct method Fx_input(1) = 0 + i*0; %set dc = 0 else interpolation will cause dc dependenceFx_input(Xsize/2+2) = 0 + i*0; %set = 0 else interpolation will cause problem B_input = zeros(Xsize/2, Xsize/4); %to form the trianglefor k1 = 1:Xsize/2;BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

40

Page 46: Chua Boon Jin Capstone Project Final Report

for k2 = 1:min(k1,Xsize/2-k1) B_input(k1,k2) = Fx_input(k1) * Fx_input(k2) * conj(Fx_input(k1+k2-1)); endend %normalized bispectral entropy P2x1 = B_input(find(B_input)); %return value that is non-zer0x2 = conj(x1); % conjugate of x1B_ent = sqrt(x1.*x2);B_ent = B_ent./sum(B_ent); %computing the probability[m,n] = size(B_ent);ent = -sum(B_ent.*log(eps+B_ent))/log(m);

Approximate Entropy Codes

% to find the standard deviation of variable 'datapoints'function ApEn = apen_load(data) filterfactor = 0.2*std(data); % to get the pattern length of datapoints for i=1:length(data) datalength(i+5) = data(i); end % function approx ApEn = apen(data, datalength, filterfactor);

%Given a sequence of data and ApEn(data,m,r), 2 parameters m and r are to %be compute. m specifies the pattern length and r defines the similarity %comparison value (std dev of (r). Beginning at k, we denote a subsequence %of m (pattern 1) by vector data(k). 2 patterns, data(k) and data(j) %(pattern 2)are similiar if their pattern differences is less than r. %Precount is the number of similiar patterns in data(k). Prevalue calculate%the log value of subsequence. Repeat the whole cycle for postcount and %postvalue with subsequence data+1.

% Computer Approximate Entropy(ApEn) a la Steve Pincus% -------------------------------------------------------------------------% function entropy calling function approx with input argument datapoints,% datalength, filterfactorfunction entropy = apen(data, datalength, filterfactor) % to determine the number(size) of samples[N,p] = size(data); % how many pairs of points are closer than r in the pre spaceprevalue = 0;% how many are closer than r in the post spacepostvalue = 0; % will be used in distance calculation

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

41

Page 47: Chua Boon Jin Capstone Project Final Report

dist = zeros(N,p); % Loop over all the pointsfor k=1:N % fill in matrix dist with many replications of the datapoints for j=1:p dist(:,j) = data(k,j); end % To calculate how many of dist are similiar to datapoints % calculate the distance (until here); distcal = (abs( dist - data ) <= filterfactor ); % which ones of them are closer than filterfactor using the max norm; % return value of 1 else 0 if p == 1 closerpre = distcal; % will yield all ones else closerpre = all(distcal); % will yield all zeros end % to count the total number of similiarity between dist and datapoints % total number of similiarity between data(k) and data(j) in pre space precount = sum(closerpre); prevalue = prevalue + log(precount); % total number of similiarity in post space postcount = sum( abs( datalength(closerpre) - datalength(k) ) < filterfactor ); postvalue = postvalue + log(postcount);end entropy = abs(prevalue - postvalue)/N; % define prevalue as mean of prevalue

Wen Entropy Codes

function spentropy = loadwentropy(b)

spentropy=wentropy(b,'shannon');

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

42

Page 48: Chua Boon Jin Capstone Project Final Report

Sample Entropy Codes

function entropysample = LoadSamEn(datapoints) M=4; r=0.2; e = samp_en(datapoints,M,r); entropysample = mean(e); %calculate the average of e %Sample Entropy is the negative natural logarithm of an estimate of the%conditional probability that subseries of length m that match pointwise%within a tolerance r also match at the next point. %The algorithm (1)builds up run of points that match within the tolerance r%until there is no match. The algorithm (2)start by finding all points that %match the first point within the tolerance r. The (3)points that match begin%a run of length of 1 and those that don't match have runs of lenght 0. if%(4)the points after those with runs of length 1 match the second point, the%runs are now of length 2; otherwise, the run is ended. If the points with%runs of length 0 match the second point, the runs are now of length 1.%This procedure runs until the end of the data. The matches are keep track%in counters A(k) and B(k). %(5)Once all matches are counted, Sample entropy values are calclated by SampEn(k,r,N)=-ln(A(k)/B(k-1)) for %k=0,1,...,m-1 with B(0)=N, the length of input series.

function [e,se,A,B]=samp_en(y,M,r)% For Simple function e=sampen(y,M,r);%%Input Parameters%%y input signal vector (y=datapoints)%M maximum template length (default M=5) (M=4)%r matching threshold (default r=0.2) (r=0.2)%%Output Parameters%%e sample entropy estimates for m=0,1,...,M-1%'off';'MATLAB:dispatcher:InexactMatch'; if ~exist('M')|isempty(M) %if not exist('m') or isempty(m) m = 5;end if ~exist('r')|isempty(r) %if not exist('r') or isempty(r) r = 0.2;end y = y(:); %all the elements of y to y, regarded as a single columnn = length(y); %determine the length of y to n

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

43

Page 49: Chua Boon Jin Capstone Project Final Report

y = y-mean(y);s = sqrt(mean(y.^2)); %Array power (to find magnitude)y = y/s; %normalize the time series prior to the estimation of sample entropyR=zeros(n-1,1); for j=1:(n-1) i=1:(n-j); d=abs(y(i+j)-y(i)); a=d<r; a1=[0;a]; a2=[a;0]; aa=find(a1~=a2); kk=length(aa)/2; rr=diff(reshape(aa,2,kk)); for i=1:kk k=rr(i); R(k)=R(k)+1; if k>50 [j k aa(2*i-1) aa(2*i)]; end end end k=max(find(R>0));R=R(1:k);match=zeros(k,1); for i=1:k match(i)=R(i); for j=(i+1):k match(i)=match(i)+(j+1-i)*R(j); end end match = double(match);k = length(match); %determine the length of match if k<M % if k is less than 4 match((k+1):M) = 0; %fill the remaining empty spaces with 0end N = n*(n-1)/2;A = match(1:M); %first element of match to M to AB = [N;A(1:(M-1))];p = A./B; %A right array divide of Be = -log(p); %to calculate entropy value

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

44

Page 50: Chua Boon Jin Capstone Project Final Report

Shannon Spectral Entropy Codes

function shannon_entropy = LoadShannon(datapoints) shannon_entropy = sha_entropy(datapoints);

function y=sha_entropy(x) [M,N]=size(x);y=zeros(1,N); for l=1:N Pf = x(:,l); Pff = log(x(:,l)); sum1=sum(Pf.*Pff); sum2=-1*sum1; y(l,1)=sum2;end %SEN = sumPflog(1/Pf)%Pf = Pf/Pt where Pt=total power%if we assume DATA to be a matrix by M*N . %then the format should be sum(DATA(:,i))=1,for i=1:N, and N is the length of the time series

Renyi’s Entropy Codes

function renyi = LoadRenyi(datapoints) a=2; renyi = renyi_entropy(datapoints,a);

function y=renyi_entropy(DATA,q) [M,N]=size(DATA);y=zeros(1,N); for n=1:N y = log(sum(DATA(:,n).^q))/(1-q);end %REN(a)=a*sum(logPk^a)/1-a%a not equal to 1

Kalmogorov Sinai Entropy Codes

function KS_entropy = ks_entropy_load(data) % to find the standard deviation of variable 'datapoints' filterfactor = 0.15*std(data); % to get the pattern length of datapoints for i=1:length(data) datalength(i+2) = data(i); end KS_entropy = ks_entropy(data, datalength, filterfactor);

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

45

Page 51: Chua Boon Jin Capstone Project Final Report

function entropy = ks_entropy(data, datalength, filterfactor) % to determine the number(size) of samples[N,p] = size(data); % how many pairs of points are closer than r in the pre spaceprevalue = 0;% how many are closer than r in the post spacepostvalue = 0; % will be used in distance calculationdist = zeros(N,p); % Loop over all the pointsfor h=1:N % fill in matrix dist with many replications of the datapoints for j=1:p dist(:,j) = data(h,j); end % To calculate how many of dist are similiar to datapoints % calculate the distance (until here); distcal = (abs( dist - data ) <= filterfactor ); % which ones of them are closer than filterfactor using the max norm; % return value of 1 else 0 if p == 1 closerpre = distcal; % will yield all ones else closerpre = all(distcal); % will yield all zeros end % to count the total number of similiarity between dist and datapoints % total number of similiarity in pre space precount = sum(closerpre); prevalue = (2*(prevalue + precount))/N; % total number of similiarity in post space postcount = sum( abs( datalength(closerpre) - datalength(h) ) < filterfactor ); postvalue = (2*(postvalue + postcount))/N;end k = prevalue / postvalue; % to calculate k-valueentropy = 2^-k; % to calculate entropy

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

46

Page 52: Chua Boon Jin Capstone Project Final Report

Appendix C - GUI

GUI Main Screen Codes

function varargout = EEG(varargin)% EEG M-file for EEG.fig% EEG, by itself, creates a new EEG or raises the existing% singleton*.%% H = EEG returns the handle to a new EEG or the handle to% the existing singleton*.%% EEG('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in EEG.M with the given input arguments.%% EEG('Property','Value',...) creates a new EEG or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before EEG_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to EEG_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help EEG % Last Modified by GUIDE v2.5 02-Oct-2010 15:32:55 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @EEG_OpeningFcn, ... 'gui_OutputFcn', @EEG_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT % --- Executes just before EEG is made visible.function EEG_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to EEG (see VARARGIN)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

47

Page 53: Chua Boon Jin Capstone Project Final Report

% Choose default command line output for EEGhandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes EEG wait for user response (see UIRESUME)% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.function varargout = EEG_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout{1} = handles.output; % --- Executes on button press in Enter.function Enter_Callback(hObject, eventdata, handles)% hObject handle to Enter (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)a = str2num(get(handles.Screen, 'String')); if (isempty(a)) EEG_output();else [b1, b2] = bisp_entropy_start(a); set(handles.bi1,'String',b1); set(handles.bi2,'String',b2); b3 = apen_load(a); set(handles.app,'String',b3); b4 = ks_entropy_load(a); set(handles.kal,'String',b4); b5 = loadsamen(a); set(handles.sam,'String',b5); b6 = loadshannon(a); set(handles.sha,'String',b6); b7 = loadrenyi(a); set(handles.ren,'String',b7); b8 = loadwentropy(a); set(handles.wen,'String',b8);end a = str2num(get(handles.app,'string'));b = str2num(get(handles.bi1,'string'));c = str2num(get(handles.ren,'string'));d = str2num(get(handles.sam,'string'));e = (c+a+b+d)/(c-a-b-d);

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

48

Page 54: Chua Boon Jin Capstone Project Final Report

set(handles.text12,'string',e);if ((e >= 0.5934) && (e <= 0.6093)) set(handles.edit_result,'string','Normal');elseif ((e >= 0.6999) && (e <= 0.7157)) set(handles.edit_result,'string','Epilepsy');elseif ((e >= 0.6552) && (e <= 0.6720)) set(handles.edit_result,'string','Background');else set(handles.edit_result,'string','Unknown');endguidata(hObject, handles); % --- Executes on button press in Browse.function Browse_Callback(hObject, eventdata, handles)% hObject handle to Browse (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)w = cd();[filename, pathname] = uigetfile('*.txt', 'Open an EEG data');cd(pathname);data = load(filename);set(handles.Screen,'String',data);cd(w);plot(handles.graph, data);guidata(hObject, handles); % --- Executes on button press in Exit.function Exit_Callback(hObject, eventdata, handles)% hObject handle to Exit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clc;clear all;close; % --- Executes on button press in Clear.function Clear_Callback(hObject, eventdata, handles)% hObject handle to Clear (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.Screen,'String','');set(handles.bi1,'String','');set(handles.bi2,'String','');set(handles.app,'String','');set(handles.kal,'String','');set(handles.sam,'String','');set(handles.sha,'String','');set(handles.ren,'String','');set(handles.wen,'String','');set(handles.index_txt,'String','');set(handles.edit_result,'String','');set(handles.text12,'String','');cla(handles.graph);guidata(hObject, handles); % --- Executes on selection change in Screen.function Screen_Callback(hObject, eventdata, handles)% hObject handle to Screen (see GCBO)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

49

Page 55: Chua Boon Jin Capstone Project Final Report

% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns Screen contents as cell array% contents{get(hObject,'Value')} returns selected item from Screen function bi1_Callback(hObject, eventdata, handles)% hObject handle to bi1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of bi1 as text% str2double(get(hObject,'String')) returns contents of bi1 as a double % --- Executes during object creation, after setting all properties.function bi1_CreateFcn(hObject, eventdata, handles)% hObject handle to bi1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function sha_Callback(hObject, eventdata, handles)% hObject handle to sha (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of sha as text% str2double(get(hObject,'String')) returns contents of sha as a double % --- Executes during object creation, after setting all properties.function sha_CreateFcn(hObject, eventdata, handles)% hObject handle to sha (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

50

Page 56: Chua Boon Jin Capstone Project Final Report

function ren_Callback(hObject, eventdata, handles)% hObject handle to ren (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ren as text% str2double(get(hObject,'String')) returns contents of ren as a double % --- Executes during object creation, after setting all properties.function ren_CreateFcn(hObject, eventdata, handles)% hObject handle to ren (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function app_Callback(hObject, eventdata, handles)% hObject handle to app (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of app as text% str2double(get(hObject,'String')) returns contents of app as a double % --- Executes during object creation, after setting all properties.function app_CreateFcn(hObject, eventdata, handles)% hObject handle to app (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function wen_Callback(hObject, eventdata, handles)% hObject handle to wen (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of wen as text% str2double(get(hObject,'String')) returns contents of wen as a double

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

51

Page 57: Chua Boon Jin Capstone Project Final Report

% --- Executes during object creation, after setting all properties.function wen_CreateFcn(hObject, eventdata, handles)% hObject handle to wen (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function sam_Callback(hObject, eventdata, handles)% hObject handle to sam (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of sam as text% str2double(get(hObject,'String')) returns contents of sam as a double % --- Executes during object creation, after setting all properties.function sam_CreateFcn(hObject, eventdata, handles)% hObject handle to sam (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function kal_Callback(hObject, eventdata, handles)% hObject handle to kal (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of kal as text% str2double(get(hObject,'String')) returns contents of kal as a double % --- Executes during object creation, after setting all properties.function kal_CreateFcn(hObject, eventdata, handles)% hObject handle to kal (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

52

Page 58: Chua Boon Jin Capstone Project Final Report

% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function bi2_Callback(hObject, eventdata, handles)% hObject handle to bi2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of bi2 as text% str2double(get(hObject,'String')) returns contents of bi2 as a double % --- Executes during object creation, after setting all properties.function bi2_CreateFcn(hObject, eventdata, handles)% hObject handle to bi2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function edit_result_Callback(hObject, eventdata, handles)% hObject handle to edit_result (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_result as text% str2double(get(hObject,'String')) returns contents of edit_result as a double % --- Executes during object creation, after setting all properties.function edit_result_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_result (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end % --- Executes during object creation, after setting all properties.function Screen_CreateFcn(hObject, eventdata, handles)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

53

Page 59: Chua Boon Jin Capstone Project Final Report

% hObject handle to Screen (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function index_txt_Callback(hObject, eventdata, handles)% hObject handle to index_txt (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of index_txt as text% str2double(get(hObject,'String')) returns contents of index_txt as a double % --- Executes during object creation, after setting all properties.function index_txt_CreateFcn(hObject, eventdata, handles)% hObject handle to index_txt (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end % --- Executes on button press in index_button.function index_button_Callback(hObject, eventdata, handles)% hObject handle to index_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)e = (get(handles.text12, 'String'));set(handles.index_txt,'String',e);guidata(hObject, handles); % --- Executes during object creation, after setting all properties.function text12_CreateFcn(hObject, eventdata, handles)% hObject handle to text12 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

GUI Sub Screen Codes

function varargout = EEG_Output(varargin)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

54

Page 60: Chua Boon Jin Capstone Project Final Report

% EEG_OUTPUT M-file for EEG_Output.fig% EEG_OUTPUT, by itself, creates a new EEG_OUTPUT or raises the existing% singleton*.%% H = EEG_OUTPUT returns the handle to a new EEG_OUTPUT or the handle to% the existing singleton*.%% EEG_OUTPUT('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in EEG_OUTPUT.M with the given input arguments.%% EEG_OUTPUT('Property','Value',...) creates a new EEG_OUTPUT or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before EEG_Output_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to EEG_Output_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help EEG_Output % Last Modified by GUIDE v2.5 21-Aug-2010 21:15:28 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @EEG_Output_OpeningFcn, ... 'gui_OutputFcn', @EEG_Output_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT % --- Executes just before EEG_Output is made visible.function EEG_Output_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to EEG_Output (see VARARGIN)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

55

Page 61: Chua Boon Jin Capstone Project Final Report

% Choose default command line output for EEG_Outputhandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes EEG_Output wait for user response (see UIRESUME)% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.function varargout = EEG_Output_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout{1} = handles.output; % --- Executes on selection change in EEG_data.function EEG_data_Callback(hObject, eventdata, handles)% hObject handle to EEG_data (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(varargin);% Hints: contents = get(hObject,'String') returns EEG_data contents as cell array% contents{get(hObject,'Value')} returns selected item from EEG_data % --- Executes during object creation, after setting all properties.function EEG_data_CreateFcn(hObject, eventdata, handles)% hObject handle to EEG_data (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end % --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close;

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

56

Page 62: Chua Boon Jin Capstone Project Final Report

Appendix D - Classifier

Fuzzy Classifier Codes

clear all;clc;load normalisedtraining3woappload normalisedtesting3woappload class %featuresp1 = training(:,1);p2 = training(:,2);p3 = training(:,3);p4 = training(:,4);%p5 = training(:,5);%p6 = training(:,6);%p7 = training(:,7);%p8 = training(:,8); %classest1 = class(:,1);t2 = class(:,2);t3 = class(:,3); p = [p1';p2';p3';p4'];t = [t1';t2';t3']; %featurestest1 = testing(:,1);test2 = testing(:,2);test3 = testing(:,3);test4 = testing(:,4);%test5 = testing(:,5);%test6 = testing(:,6);%test7 = testing(:,7);%test8 = testing(:,8); test = [test1';test2';test3';test4'];ptest=test'; fismat = genfis2(p',t',0.5,[0 0 0 0 0 0 0; 1 1 1 1 1 1 1]); %Generate Fuzzy Inference System structure from data using subtractive clusteringy=evalfis(ptest,fismat); %Perform fuzzy inference calculationsoutres=y'; yj=outres';for i=1:length(yj) a=yj(i,:); maxi=max(a); %largest elements in array for j=1:3 if yj(i,j)==maxi yj(i,j)=1; else yj(i,j)=0; end endendyjxlswrite('Fuzzywoapp.xls', yj, 'Fuzzy3', 'A1'); %to create excel file

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

57

Page 63: Chua Boon Jin Capstone Project Final Report

Gaussian Mixture Model Classifier Codes

%DEMGMMC Demo of GMM used for classification: version to produce figure%DONE**** to make sure reading confusion matrix right try absolute dataclcclear allclose all %load data fileload training3woksload testing3woks % Work with 2-d datanin = 4; % No of inputsclass =3; % which layer (R,G or B) and if its area or peri % Fix the seeds rand('state', 4231);randn('state', sum(100*clock)); % Now fit a mixture of Gaussians to each class. Use spherical % Gaussians as we assume we don't know the data structure.ncentres = 1; % Variable mix1 = gmm(nin, ncentres, 'full');mix2 = gmm(nin, ncentres, 'full'); mix3 = gmm(nin, ncentres, 'full'); data = training(:,1:4); %No.of inputs (columns)label = training(:,5); %class % Initialise modelsoptions = foptions;options(14) = 50; % Initialise the model parameters from the data %(No. of Mix = No. of outputs)% mix1 = normal, mix2 = mild, mod,severe and prolifmix1 = gmminit(mix1, data(label==1, :), options); % mixture model 1mix2 = gmminit(mix2, data(label==2, :), options); % mixture model 2mix3 = gmminit(mix3, data(label==3, :), options); % mixture model 3 % Now train each modeloptions(1) = 1; % Print error valuesoptions(5) = 1; % Prevent collapse of variancesoptions(14) = 1000; % Number of iterationsmix1 = gmmem(mix1, data(label==1, :), options);mix2 = gmmem(mix2, data(label==2, :), options);mix3 = gmmem(mix3, data(label==3, :), options); % Generate test data%[test, test_label] = gmmsamp(mix, n);test = testing(:,1:4);test_label = testing(:,5); % Priors are equal and normalising constant is the same for both % classes, so cannot affect classificationtest_probs = [gmmprob(mix1, test) gmmprob(mix2, test) gmmprob(mix3, test)];

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

58

Page 64: Chua Boon Jin Capstone Project Final Report

% Convert to 1 of N encodingtarget = [ test_label==1 test_label==2 test_label==3]; %No. of outputsfh1 = conffig(test_probs, target);

function plotmat(matrix, textcolour, gridcolour, fontsize)%PLOTMAT Display a matrix.%% Description% PLOTMAT(MATRIX, TEXTCOLOUR, GRIDCOLOUR, FONTSIZE) displays the matrix% MATRIX on the current figure. The TEXTCOLOUR and GRIDCOLOUR% arguments control the colours of the numbers and grid labels% respectively and should follow the usual Matlab specification. The% parameter FONTSIZE should be an integer.%% See also% CONFFIG, DEMMLP2% % Copyright (c) Ian T Nabney (1996-2001) [m,n]=size(matrix);for rowCnt=1:m, for colCnt=1:n, numberString=num2str(matrix(rowCnt,colCnt)); text(colCnt-.5,m-rowCnt+.5,numberString, ... 'HorizontalAlignment','center', ... 'Color', textcolour, ... 'FontWeight','bold', ... 'FontSize', fontsize); end;end; set(gca,'Box','on', ... 'Visible','on', ... 'xLim',[0 n], ... 'xGrid','on', ... 'xTickLabel',[], ... 'xTick',0:n, ... 'yGrid','on', ... 'yLim',[0 m], ... 'yTickLabel',[], ... 'yTick',0:m, ... 'DataAspectRatio',[1, 1, 1], ... 'GridLineStyle',':', ... 'LineWidth',3, ... 'XColor',gridcolour, ... 'YColor',gridcolour);

function [centres, options, post, errlog] = kmeans(centres, data, options)%KMEANS Trains a k means cluster model.%% Description% CENTRES = KMEANS(CENTRES, DATA, OPTIONS) uses the batch K-means% algorithm to set the centres of a cluster model. The matrix DATA% represents the data which is being clustered, with each row% corresponding to a vector. The sum of squares error function is used.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

59

Page 65: Chua Boon Jin Capstone Project Final Report

% The point at which a local minimum is achieved is returned as% CENTRES. The error value at that point is returned in OPTIONS(8).%% [CENTRES, OPTIONS, POST, ERRLOG] = KMEANS(CENTRES, DATA, OPTIONS)% also returns the cluster number (in a one-of-N encoding) for each% data point in POST and a log of the error values after each cycle in% ERRLOG. The optional parameters have the following% interpretations.%% OPTIONS(1) is set to 1 to display error values; also logs error% values in the return argument ERRLOG. If OPTIONS(1) is set to 0, then% only warning messages are displayed. If OPTIONS(1) is -1, then% nothing is displayed.%% OPTIONS(2) is a measure of the absolute precision required for the% value of CENTRES at the solution. If the absolute difference between% the values of CENTRES between two successive steps is less than% OPTIONS(2), then this condition is satisfied.%% OPTIONS(3) is a measure of the precision required of the error% function at the solution. If the absolute difference between the% error functions between two successive steps is less than OPTIONS(3),% then this condition is satisfied. Both this and the previous% condition must be satisfied for termination.%% OPTIONS(14) is the maximum number of iterations; default 100.%% See also% GMMINIT, GMMEM% % Copyright (c) Ian T Nabney (1996-2001) [ndata, data_dim] = size(data);[ncentres, dim] = size(centres); if dim ~= data_dim error('Data dimension does not match dimension of centres')end if (ncentres > ndata) error('More centres than data')end % Sort out the optionsif (options(14)) niters = options(14);else niters = 100;end store = 0;if (nargout > 3) store = 1; errlog = zeros(1, niters);end % Check if centres and posteriors need to be initialised from dataif (options(5) == 1) % Do the initialisation perm = randperm(ndata);

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

60

Page 66: Chua Boon Jin Capstone Project Final Report

perm = perm(1:ncentres); % Assign first ncentres (permuted) data points as centres centres = data(perm, :);end% Matrix to make unit vectors easy to constructid = eye(ncentres); % Main loop of algorithmfor n = 1:niters % Save old centres to check for termination old_centres = centres; % Calculate posteriors based on existing centres d2 = dist2(data, centres); % Assign each point to nearest centre [minvals, index] = min(d2', [], 1); post = id(index,:); num_points = sum(post, 1); % Adjust the centres based on new posteriors for j = 1:ncentres if (num_points(j) > 0) centres(j,:) = sum(data(find(post(:,j)),:), 1)/num_points(j); end end % Error value is total squared distance from cluster centres e = sum(minvals); if store errlog(n) = e; end if options(1) > 0 fprintf(1, 'Cycle %4d Error %11.6f\n', n, e); end if n > 1 % Test for termination if max(max(abs(centres - old_centres))) < options(2) & ... abs(old_e - e) < options(3) options(8) = e; return; end end old_e = e;end % If we get here, then we haven't terminated in the given number of % iterations.options(8) = e;if (options(1) >= 0) disp(maxitmess);end

function prob = gmmprob(mix, x)%GMMPROB Computes the data probability for a Gaussian mixture model.%% Description% This function computes the unconditional data density P(X) for a

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

61

Page 67: Chua Boon Jin Capstone Project Final Report

% Gaussian mixture model. The data structure MIX defines the mixture% model, while the matrix X contains the data vectors. Each row of X% represents a single vector.%% See also% GMM, GMMPOST, GMMACTIV% % Copyright (c) Ian T Nabney (1996-2001) % Check that inputs are consistenterrstring = consist(mix, 'gmm', x);if ~isempty(errstring) error(errstring);end % Compute activationsa = gmmactiv(mix, x); % Form dot product with priorsprob = a * (mix.priors)';

function [post, a] = gmmpost(mix, x)%GMMPOST Computes the class posterior probabilities of a Gaussian mixture model.%% Description% This function computes the posteriors POST (i.e. the probability of% each component conditioned on the data P(J|X)) for a Gaussian mixture% model. The data structure MIX defines the mixture model, while the% matrix X contains the data vectors. Each row of X represents a% single vector.%% See also% GMM, GMMACTIV, GMMPROB% % Copyright (c) Ian T Nabney (1996-2001) % Check that inputs are consistenterrstring = consist(mix, 'gmm', x);if ~isempty(errstring) error(errstring);end ndata = size(x, 1); a = gmmactiv(mix, x); post = (ones(ndata, 1)*mix.priors).*a;s = sum(post, 2);if any(s==0) warning('Some zero posterior probabilities') % Set any zeros to one before dividing zero_rows = find(s==0); s = s + (s==0); post(zero_rows, :) = 1/mix.ncentres;endpost = post./(s*ones(1, mix.ncentres));

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

62

Page 68: Chua Boon Jin Capstone Project Final Report

function mix = gmminit(mix, x, options)%GMMINIT Initialises Gaussian mixture model from data%% Description% MIX = GMMINIT(MIX, X, OPTIONS) uses a dataset X to initialise the% parameters of a Gaussian mixture model defined by the data structure% MIX. The k-means algorithm is used to determine the centres. The% priors are computed from the proportion of examples belonging to each% cluster. The covariance matrices are calculated as the sample% covariance of the points associated with (i.e. closest to) the% corresponding centres. For a mixture of PPCA model, the PPCA% decomposition is calculated for the points closest to a given centre.% This initialisation can be used as the starting point for training% the model using the EM algorithm.%% See also% GMM% % Copyright (c) Ian T Nabney (1996-2001) [ndata, xdim] = size(x); % Check that inputs are consistenterrstring = consist(mix, 'gmm', x);if ~isempty(errstring) error(errstring);end % Arbitrary width used if variance collapses to zero: make it 'large' so% that centre is responsible for a reasonable number of points.GMM_WIDTH = 1.0; % Use kmeans algorithm to set centresoptions(5) = 1; [mix.centres, options, post] = kmeans(mix.centres, x, options); % Set priors depending on number of points in each clustercluster_sizes = max(sum(post, 1), 1); % Make sure that no prior is zeromix.priors = cluster_sizes/sum(cluster_sizes); % Normalise priors switch mix.covar_typecase 'spherical' if mix.ncentres > 1 % Determine widths as distance to nearest centre % (or a constant if this is zero) cdist = dist2(mix.centres, mix.centres); cdist = cdist + diag(ones(mix.ncentres, 1)*realmax); mix.covars = min(cdist); mix.covars = mix.covars + GMM_WIDTH*(mix.covars < eps); else % Just use variance of all data points averaged over all % dimensions mix.covars = mean(diag(cov(x))); end case 'diag' for j = 1:mix.ncentres % Pick out data points belonging to this centre c = x(find(post(:, j)),:); diffs = c - (ones(size(c, 1), 1) * mix.centres(j, :)); mix.covars(j, :) = sum((diffs.*diffs), 1)/size(c, 1);

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

63

Page 69: Chua Boon Jin Capstone Project Final Report

% Replace small entries by GMM_WIDTH value mix.covars(j, :) = mix.covars(j, :) + GMM_WIDTH.*(mix.covars(j, :)<eps); end case 'full' for j = 1:mix.ncentres % Pick out data points belonging to this centre c = x(find(post(:, j)),:); diffs = c - (ones(size(c, 1), 1) * mix.centres(j, :)); mix.covars(:,:,j) = (diffs'*diffs)/(size(c, 1)); % Add GMM_WIDTH*Identity to rank-deficient covariance matrices if rank(mix.covars(:,:,j)) < mix.nin mix.covars(:,:,j) = mix.covars(:,:,j) + GMM_WIDTH.*eye(mix.nin); end end case 'ppca' for j = 1:mix.ncentres % Pick out data points belonging to this centre c = x(find(post(:,j)),:); diffs = c - (ones(size(c, 1), 1) * mix.centres(j, :)); [tempcovars, tempU, templambda] = ... ppca((diffs'*diffs)/size(c, 1), mix.ppca_dim); if length(templambda) ~= mix.ppca_dim error('Unable to extract enough components'); else mix.covars(j) = tempcovars; mix.U(:, :, j) = tempU; mix.lambda(j, :) = templambda; end end otherwise error(['Unknown covariance type ', mix.covar_type]);end

function [mix, options, errlog] = gmmem(mix, x, options)%GMMEM EM algorithm for Gaussian mixture model.%% Description% [MIX, OPTIONS, ERRLOG] = GMMEM(MIX, X, OPTIONS) uses the Expectation% Maximization algorithm of Dempster et al. to estimate the parameters% of a Gaussian mixture model defined by a data structure MIX. The% matrix X represents the data whose expectation is maximized, with% each row corresponding to a vector. The optional parameters have% the following interpretations.%% OPTIONS(1) is set to 1 to display error values; also logs error% values in the return argument ERRLOG. If OPTIONS(1) is set to 0, then% only warning messages are displayed. If OPTIONS(1) is -1, then% nothing is displayed.%% OPTIONS(3) is a measure of the absolute precision required of the% error function at the solution. If the change in log likelihood% between two steps of the EM algorithm is less than this value, then% the function terminates.%% OPTIONS(5) is set to 1 if a covariance matrix is reset to its% original value when any of its singular values are too small (less% than MIN_COVAR which has the value eps). With the default value of% 0 no action is taken.%

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

64

Page 70: Chua Boon Jin Capstone Project Final Report

% OPTIONS(14) is the maximum number of iterations; default 100.%% The optional return value OPTIONS contains the final error value% (i.e. data log likelihood) in OPTIONS(8).%% See also% GMM, GMMINIT% % Copyright (c) Ian T Nabney (1996-2001) % Check that inputs are consistenterrstring = consist(mix, 'gmm', x);if ~isempty(errstring) error(errstring);end [ndata, xdim] = size(x); % Sort out the optionsif (options(14)) niters = options(14);else niters = 100;end display = options(1);store = 0;if (nargout > 2) store = 1; % Store the error values to return them errlog = zeros(1, niters);endtest = 0;if options(3) > 0.0 test = 1; % Test log likelihood for terminationend check_covars = 0;if options(5) >= 1 if display >= 0 disp('check_covars is on'); end check_covars = 1; % Ensure that covariances don't collapse MIN_COVAR = eps; % Minimum singular value of covariance matrix init_covars = mix.covars;end % Main loop of algorithmfor n = 1:niters % Calculate posteriors based on old parameters [post, act] = gmmpost(mix, x); % Calculate error value if needed if (display | store | test) prob = act*(mix.priors)'; % Error value is negative log likelihood of data e = - sum(log(prob)); if store errlog(n) = e; end

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

65

Page 71: Chua Boon Jin Capstone Project Final Report

if display > 0 fprintf(1, 'Cycle %4d Error %11.6f\n', n, e); end if test if (n > 1 & abs(e - eold) < options(3)) options(8) = e; return; else eold = e; end end end % Adjust the new estimates for the parameters new_pr = sum(post, 1); new_c = post' * x; % Now move new estimates to old parameter vectors mix.priors = new_pr ./ ndata; mix.centres = new_c ./ (new_pr' * ones(1, mix.nin)); switch mix.covar_type case 'spherical' n2 = dist2(x, mix.centres); for j = 1:mix.ncentres v(j) = (post(:,j)'*n2(:,j)); end mix.covars = ((v./new_pr))./mix.nin; if check_covars % Ensure that no covariance is too small for j = 1:mix.ncentres if mix.covars(j) < MIN_COVAR mix.covars(j) = init_covars(j); end end end case 'diag' for j = 1:mix.ncentres diffs = x - (ones(ndata, 1) * mix.centres(j,:)); mix.covars(j,:) = sum((diffs.*diffs).*(post(:,j)*ones(1, ... mix.nin)), 1)./new_pr(j); end if check_covars % Ensure that no covariance is too small for j = 1:mix.ncentres if min(mix.covars(j,:)) < MIN_COVAR mix.covars(j,:) = init_covars(j,:); end end end case 'full' for j = 1:mix.ncentres diffs = x - (ones(ndata, 1) * mix.centres(j,:)); diffs = diffs.*(sqrt(post(:,j))*ones(1, mix.nin)); mix.covars(:,:,j) = (diffs'*diffs)/new_pr(j); end if check_covars % Ensure that no covariance is too small for j = 1:mix.ncentres if min(svd(mix.covars(:,:,j))) < MIN_COVAR

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

66

Page 72: Chua Boon Jin Capstone Project Final Report

mix.covars(:,:,j) = init_covars(:,:,j); end end end case 'ppca' for j = 1:mix.ncentres diffs = x - (ones(ndata, 1) * mix.centres(j,:)); diffs = diffs.*(sqrt(post(:,j))*ones(1, mix.nin)); [tempcovars, tempU, templambda] = ... ppca((diffs'*diffs)/new_pr(j), mix.ppca_dim); if length(templambda) ~= mix.ppca_dim error('Unable to extract enough components'); else mix.covars(j) = tempcovars; mix.U(:, :, j) = tempU; mix.lambda(j, :) = templambda; end end if check_covars if mix.covars(j) < MIN_COVAR mix.covars(j) = init_covars(j); end end otherwise error(['Unknown covariance type ', mix.covar_type]); endend options(8) = -sum(log(gmmprob(mix, x)));if (display >= 0) disp(maxitmess);end function a = gmmactiv(mix, x)%GMMACTIV Computes the activations of a Gaussian mixture model.%% Description% This function computes the activations A (i.e. the probability% P(X|J) of the data conditioned on each component density) for a% Gaussian mixture model. For the PPCA model, each activation is the% conditional probability of X given that it is generated by the% component subspace. The data structure MIX defines the mixture model,% while the matrix X contains the data vectors. Each row of X% represents a single vector.%% See also% GMM, GMMPOST, GMMPROB% % Copyright (c) Ian T Nabney (1996-2001) % Check that inputs are consistenterrstring = consist(mix, 'gmm', x);if ~isempty(errstring) error(errstring);end ndata = size(x, 1);a = zeros(ndata, mix.ncentres); % Preallocate matrix switch mix.covar_type

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

67

Page 73: Chua Boon Jin Capstone Project Final Report

case 'spherical' % Calculate squared norm matrix, of dimension (ndata, ncentres) n2 = dist2(x, mix.centres); % Calculate width factors wi2 = ones(ndata, 1) * (2 .* mix.covars); normal = (pi .* wi2) .^ (mix.nin/2); % Now compute the activations a = exp(-(n2./wi2))./ normal; case 'diag' normal = (2*pi)^(mix.nin/2); s = prod(sqrt(mix.covars), 2); for j = 1:mix.ncentres diffs = x - (ones(ndata, 1) * mix.centres(j, :)); a(:, j) = exp(-0.5*sum((diffs.*diffs)./(ones(ndata, 1) * ... mix.covars(j, :)), 2)) ./ (normal*s(j)); end case 'full' normal = (2*pi)^(mix.nin/2); for j = 1:mix.ncentres diffs = x - (ones(ndata, 1) * mix.centres(j, :)); % Use Cholesky decomposition of covariance matrix to speed computation c = chol(mix.covars(:, :, j)); temp = diffs/c; a(:, j) = exp(-0.5*sum(temp.*temp, 2))./(normal*prod(diag(c))); endcase 'ppca' log_normal = mix.nin*log(2*pi); d2 = zeros(ndata, mix.ncentres); logZ = zeros(1, mix.ncentres); for i = 1:mix.ncentres k = 1 - mix.covars(i)./mix.lambda(i, :); logZ(i) = log_normal + mix.nin*log(mix.covars(i)) - ... sum(log(1 - k)); diffs = x - ones(ndata, 1)*mix.centres(i, :); proj = diffs*mix.U(:, :, i); d2(:,i) = (sum(diffs.*diffs, 2) - ... sum((proj.*(ones(ndata, 1)*k)).*proj, 2)) / ... mix.covars(i); end a = exp(-0.5*(d2 + ones(ndata, 1)*logZ));otherwise error(['Unknown covariance type ', mix.covar_type]);end

function mix = gmm(dim, ncentres, covar_type, ppca_dim)%GMM Creates a Gaussian mixture model with specified architecture.%% Description% MIX = GMM(DIM, NCENTRES, COVARTYPE) takes the dimension of the space% DIM, the number of centres in the mixture model and the type of the% mixture model, and returns a data structure MIX. The mixture model% type defines the covariance structure of each component Gaussian:% 'spherical' = single variance parameter for each component: stored as a vector

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

68

Page 74: Chua Boon Jin Capstone Project Final Report

% 'diag' = diagonal matrix for each component: stored as rows of a matrix% 'full' = full matrix for each component: stored as 3d array% 'ppca' = probabilistic PCA: stored as principal components (in a 3d array% and associated variances and off-subspace noise% MIX = GMM(DIM, NCENTRES, COVARTYPE, PPCA_DIM) also sets the% dimension of the PPCA sub-spaces: the default value is one.%% The priors are initialised to equal values summing to one, and the% covariances are all the identity matrix (or equivalent). The centres% are initialised randomly from a zero mean unit variance Gaussian.% This makes use of the MATLAB function RANDN and so the seed for the% random weight initialisation can be set using RANDN('STATE', S) where% S is the state value.%% The fields in MIX are% % type = 'gmm'% nin = the dimension of the space% ncentres = number of mixture components% covartype = string for type of variance model% priors = mixing coefficients% centres = means of Gaussians: stored as rows of a matrix% covars = covariances of Gaussians% The additional fields for mixtures of PPCA are% U = principal component subspaces% lambda = in-space covariances: stored as rows of a matrix% The off-subspace noise is stored in COVARS.%% See also% GMMPAK, GMMUNPAK, GMMSAMP, GMMINIT, GMMEM, GMMACTIV, GMMPOST, % GMMPROB% % Copyright (c) Ian T Nabney (1996-2001) if ncentres < 1 error('Number of centres must be greater than zero')end mix.type = 'gmm';mix.nin = dim;mix.ncentres = ncentres; vartypes = {'spherical', 'diag', 'full', 'ppca'}; if sum(strcmp(covar_type, vartypes)) == 0 error('Undefined covariance type')else mix.covar_type = covar_type;end % Make default dimension of PPCA subspaces one.if strcmp(covar_type, 'ppca') if nargin < 4 ppca_dim = 1; end if ppca_dim > dim error('Dimension of PPCA subspaces must be less than data.') end

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

69

Page 75: Chua Boon Jin Capstone Project Final Report

mix.ppca_dim = ppca_dim;end % Initialise priors to be equal and summing to onemix.priors = ones(1,mix.ncentres) ./ mix.ncentres; % Initialise centresmix.centres = randn(mix.ncentres, mix.nin); % Initialise all the variances to unityswitch mix.covar_type case 'spherical' mix.covars = ones(1, mix.ncentres); mix.nwts = mix.ncentres + mix.ncentres*mix.nin + mix.ncentres;case 'diag' % Store diagonals of covariance matrices as rows in a matrix mix.covars = ones(mix.ncentres, mix.nin); mix.nwts = mix.ncentres + mix.ncentres*mix.nin + ... mix.ncentres*mix.nin;case 'full' % Store covariance matrices in a row vector of matrices mix.covars = repmat(eye(mix.nin), [1 1 mix.ncentres]); mix.nwts = mix.ncentres + mix.ncentres*mix.nin + ... mix.ncentres*mix.nin*mix.nin;case 'ppca' % This is the off-subspace noise: make it smaller than % lambdas mix.covars = 0.1*ones(1, mix.ncentres); % Also set aside storage for principal components and % associated variances init_space = eye(mix.nin); init_space = init_space(:, 1:mix.ppca_dim); init_space(mix.ppca_dim+1:mix.nin, :) = ... ones(mix.nin - mix.ppca_dim, mix.ppca_dim); mix.U = repmat(init_space , [1 1 mix.ncentres]); mix.lambda = ones(mix.ncentres, mix.ppca_dim); % Take account of additional parameters mix.nwts = mix.ncentres + mix.ncentres*mix.nin + ... mix.ncentres + mix.ncentres*mix.ppca_dim + ... mix.ncentres*mix.nin*mix.ppca_dim;otherwise error(['Unknown covariance type ', mix.covar_type]); end

function n2 = dist2(x, c)%DIST2 Calculates squared distance between two sets of points.%% Description% D = DIST2(X, C) takes two matrices of vectors and calculates the% squared Euclidean distance between them. Both matrices must be of% the same column dimension. If X has M rows and N columns, and C has% L rows and N columns, then the result has M rows and L columns. The% I, Jth entry is the squared distance from the Ith row of X to the% Jth row of C.%% See also% GMMACTIV, KMEANS, RBFFWD%

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

70

Page 76: Chua Boon Jin Capstone Project Final Report

% Copyright (c) Ian T Nabney (1996-2001) [ndata, dimx] = size(x);[ncentres, dimc] = size(c);if dimx ~= dimc error('Data dimension does not match dimension of centres')end n2 = (ones(ncentres, 1) * sum((x.^2)', 1))' + ... ones(ndata, 1) * sum((c.^2)',1) - ... 2.*(x*(c')); % Rounding errors occasionally cause negative entries in n2if any(any(n2<0)) n2(n2<0) = 0;endfunction errstring = consist(model, type, inputs, outputs)%CONSIST Check that arguments are consistent.%% Description%% ERRSTRING = CONSIST(NET, TYPE, INPUTS) takes a network data structure% NET together with a string TYPE containing the correct network type,% a matrix INPUTS of input vectors and checks that the data structure% is consistent with the other arguments. An empty string is returned% if there is no error, otherwise the string contains the relevant% error message. If the TYPE string is empty, then any type of network% is allowed.%% ERRSTRING = CONSIST(NET, TYPE) takes a network data structure NET% together with a string TYPE containing the correct network type, and% checks that the two types match.%% ERRSTRING = CONSIST(NET, TYPE, INPUTS, OUTPUTS) also checks that the% network has the correct number of outputs, and that the number of% patterns in the INPUTS and OUTPUTS is the same. The fields in NET% that are used are% type% nin% nout%% See also% MLPFWD% % Copyright (c) Ian T Nabney (1996-2001) % Assume that all is OK as defaulterrstring = ''; % If type string is not emptyif ~isempty(type) % First check that model has type field if ~isfield(model, 'type') errstring = 'Data structure does not contain type field'; return end % Check that model has the correct type s = model.type; if ~strcmp(s, type)

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

71

Page 77: Chua Boon Jin Capstone Project Final Report

errstring = ['Model type ''', s, ''' does not match expected type ''',... type, '''']; return endend % If inputs are present, check that they have correct dimensionif nargin > 2 if ~isfield(model, 'nin') errstring = 'Data structure does not contain nin field'; return end data_nin = size(inputs, 2); if model.nin ~= data_nin errstring = ['Dimension of inputs ', num2str(data_nin), ... ' does not match number of model inputs ', num2str(model.nin)]; return endend % If outputs are present, check that they have correct dimensionif nargin > 3 if ~isfield(model, 'nout') errstring = 'Data structure does not conatin nout field'; return end data_nout = size(outputs, 2); if model.nout ~= data_nout errstring = ['Dimension of outputs ', num2str(data_nout), ... ' does not match number of model outputs ', num2str(model.nout)]; return end % Also check that number of data points in inputs and outputs is the same num_in = size(inputs, 1); num_out = size(outputs, 1); if num_in ~= num_out errstring = ['Number of input patterns ', num2str(num_in), ... ' does not match number of output patterns ', num2str(num_out)]; return endend

function [C,rate]=confmat(Y,T)%CONFMAT Compute a confusion matrix.%% Description% [C, RATE] = CONFMAT(Y, T) computes the confusion matrix C and% classification performance RATE for the predictions mat{y} compared% with the targets T. The data is assumed to be in a 1-of-N encoding,% unless there is just one column, when it is assumed to be a 2 class% problem with a 0-1 encoding. Each row of Y and T corresponds to a% single example.%% In the confusion matrix, the rows represent the true classes and the% columns the predicted classes. The vector RATE has two entries: the% percentage of correct classifications and the total number of correct% classifications.%

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

72

Page 78: Chua Boon Jin Capstone Project Final Report

% See also% CONFFIG, DEMTRAIN% % Copyright (c) Ian T Nabney (1996-2001) [n c]=size(Y);[n2 c2]=size(T); if n~=n2 | c~=c2 error('Outputs and targets are different sizes')end if c > 1 % Find the winning class assuming 1-of-N encoding [maximum Yclass] = max(Y', [], 1); TL=[1:c]*T';else % Assume two classes with 0-1 encoding c = 2; class2 = find(T > 0.5); TL = ones(n, 1); TL(class2) = 2; class2 = find(Y > 0.5); Yclass = ones(n, 1); Yclass(class2) = 2;end % Compute correct = (Yclass==TL);total=sum(sum(correct));rate=[total*100/n total]; C=zeros(c,c);for i=1:c for j=1:c C(i,j) = sum((Yclass==j).*(TL==i)); endend

function fh=conffig(y, t)%CONFFIG Display a confusion matrix.%% Description% CONFFIG(Y, T) displays the confusion matrix and classification% performance for the predictions mat{y} compared with the targets T.% The data is assumed to be in a 1-of-N encoding, unless there is just% one column, when it is assumed to be a 2 class problem with a 0-1% encoding. Each row of Y and T corresponds to a single example.%% In the confusion matrix, the rows represent the true classes and the% columns the predicted classes.%% FH = CONFFIG(Y, T) also returns the figure handle FH which can be% used, for instance, to delete the figure when it is no longer needed.%% See also% CONFMAT, DEMTRAIN%

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

73

Page 79: Chua Boon Jin Capstone Project Final Report

% Copyright (c) Ian T Nabney (1996-2001) [C, rate] = confmat(y, t); fh = figure('Name', 'Confusion matrix', ... 'NumberTitle', 'off'); plotmat(C, 'k', 'k', 14);title(['Classification rate: ' num2str(rate(1)) '%'], 'FontSize', 14);

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

74