You are on page 1of 81

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

A project report submitted to SIM University


in partial fulfilment of the requirements for the degree of
Bachelor of Science (or Bachelor of Biomedical Engineering)
November 2010

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, Renyis 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, Renyis 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

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 ................................................................................................................................................................ 5
ENTROPY ESTIMATORS ......................................................................................................................................... 6
Bi-Spectral Entropy 1 and 2 ........................................................................................................................ 6
Approximate Entropy ................................................................................................................................. 8
Wen Entropy ............................................................................................................................................... 8
Sample Entropy .......................................................................................................................................... 8
Shannon Spectral Entropy .......................................................................................................................... 9
Renyis Entropy ........................................................................................................................................... 9
Kalmogorov-Sinai Entropy ....................................................................................................................... 10
CLASSIFIERS ...................................................................................................................................................... 10
Fuzzy Sugeno Classifier ............................................................................................................................. 10
Gaussian Mixture Model .......................................................................................................................... 11
CHAPTER 3 ................................................................................................................................................. 13
RESULTS........................................................................................................................................................... 13
DISCUSSION...................................................................................................................................................... 22
CHAPTER 4 ................................................................................................................................................. 24
SUMMARY ....................................................................................................................................................... 24
CONCLUSION .................................................................................................................................................... 24
FUTURE WORKS ................................................................................................................................................ 24
CHAPTER 5 ................................................................................................................................................. 25
REFLECTION ...................................................................................................................................................... 25
REFERENCES ............................................................................................................................................... 27
APPENDIX A ENTROPY VALUES ................................................................................................................ 30
ENTROPY VALUES FOR NORMAL SIGNAL ................................................................................................................ 30
ENTROPY VALUES FOR EPILEPSY SIGNAL................................................................................................................. 34
ENTROPY VALUES FOR PRE-ICTAL SIGNAL............................................................................................................... 36
APPENDIX B ENTROPY CODES .................................................................................................................. 41
BI-SPECTRAL ENTROPY CODES ............................................................................................................................. 41
APPROXIMATE ENTROPY CODES........................................................................................................................... 42

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

ii

WEN ENTROPY CODES ....................................................................................................................................... 43


SAMPLE ENTROPY CODES.................................................................................................................................... 44
SHANNON SPECTRAL ENTROPY CODES .................................................................................................................. 46
RENYIS ENTROPY CODES .................................................................................................................................... 46
KALMOGOROV SINAI ENTROPY CODES .................................................................................................................. 46
APPENDIX C - GUI ....................................................................................................................................... 48
GUI MAIN SCREEN CODES .................................................................................................................................. 48
GUI SUB SCREEN CODES .................................................................................................................................... 56
APPENDIX D - CLASSIFIER ........................................................................................................................... 59
FUZZY CLASSIFIER CODES .................................................................................................................................... 59
GAUSSIAN MIXTURE MODEL CLASSIFIER CODES ..................................................................................................... 60

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

iii

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

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

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 patients are suffering
from epilepsy or any other brain associated disorders. Experience electroencephalographers
will be able to recognize these patterns. During recording, the patients 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 patients 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 patients 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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

signals unlike Fourier transform, which captures stationary signal. FWT is suitable for EEG
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.
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

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
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

CHAPTER 2
Classifier

EEG Signal

Entropies
Estimators

ANOVA
Test

Results

Index

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

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, Renyis
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

Non-redundant
Region
0.5
f2

0.5

f1

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):
f1m

iBi j
Bi j

f 2m

jBi j
Bi j

Where i and j are the frequency bin index in the non-redundant region
Normalized bispectral entropy (BE 1):

P1 pi log p1
where
pi

B f1 , f 2

B f , f

the region inside the triangle

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

Normalized bispectral square entropy (BE 2):

P2 p n log p n
where
pn

B f1 , f 2

B f , f

the region inside the triangle


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:
1
N

1m1
N

m
m

APEN
m
,
r
,
N

log
C
r

log
C
r

i
i

1
i

1 i
N

1
N

where C im r

N m 1
1
r xi x j
N m 1 j 1

is the correlation integral.

For this project, m is set to 5 and r is set to0.2 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:
E wentropy X , T
where X is the input data, T is a string containing the type of entropy.

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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

largely independent of data length. [Physio Toolkit, Richman and Randall 2000]. SampEn
can be calculated by using this equation:
SampEn (k , r , N ) ln

A(k )
for k 0,1,...,m 1 with B(0) N , the length of the input
B(k 1)

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 dont 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:
1
where p f is the power level
SEN

f log
p
f
f

High entropy data have broad flat probability distribution while low entropy data have
narrow peaked probability distribution [Kannathal et al. 2006].
Renyis Entropy
Renyis entropy is given by:

1
REN


log
p
1

k where

In this paper, we used a 2 to determined the REN for normal and epileptic EEG data.
This is a special case called Renyis quadratic entropy. Renyis quadratic entropy is given
by:

REN
2

log
p

The difference between REN and SEN is that REN data is weighted towards frequencies
in the lower frequency band. [Kannathal et al. 2006].

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

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:

tdiv 2Kt where t div

is the average time for the pair to diverge apart and K is

expressed in bits/sec.

N
m
m
2N

r
,N
1C
m
m

C
r
,
N

m
m
i
j
K

lim
lim
is the

N
N

1
r

0
m

1
j

1
m
m

where
C
r
,N
m

1
m

1
j

correlation function from Grasserger and Procaccaia algorithm.


For this project, m is set to 2 and r is set to0.15 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 inputoutput 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.
R if x1 is A1 , ... , x k is Ak then y g x1 ,..., x k

where
x1 x k is the premise variables

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

10

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

y is the consequence variable


g is the function of value y when x1 x k satisfies the premise
The final output y is given by:

y y y
y
yy
i

where

y y i A1i x10 ... Aki xk0 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]:

x;

2 2
d

T
exp x 1 x
2

1
2

Where

denotes the parameters

and

x 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:
f k x j x; j with
k

j 1

j 1

1 for j 0 : j 1..... k

where
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

11

j is the mixing weight

x; j 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 X n x1 ..... x n such that the probability of X n is never smaller
than the new mixture. For all components, j 1..... k the equations for EM are [A.P.
Dempster et al. 1977, J.J. Verbeek et al. 2003]:
P j | xi j xi ; j / f k xi
n

j P j | xi / n
i 1

j P j | xi xi / n j
n

i 1

j P j | xi xi i xi i / n j
n

i 1

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

12

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
Bi Spectral
Entropy 1
Bi Spectral
Entropy 2
Kalmogorov-Sinai
Entropy
Sample Entropy
Shannon Spectral
Entropy
Renyis Entropy
Approximate
Entropy
Wentropy

Normal

Epilepsy

Pre-Ictal

P - Value

0.565707.634E-02

0.483250.155

0.471325.833E-02

< 0.0001

0.773773.163E-02

0.731844.555E-02

0.678113.926E-02

< 0.0001

7.68840E031.408E-02
1.33240.122

3.36197E027.547E-02
0.926470.139

2.16623E024.632E-02
1.01750.163

Too few data

Too few data

Too few data

N.A.

-16.339 0.653

-19.535 1.02

-16.378 0.935

< 0.0001

2.2512 5.578E-02

1.9325 0.215

1.8785 0.256

< 0.0001

-5.17516E+07
5.255E+07

-2.75498E+09
2.540E+09

-1.41293E+08
7.067E+08

< 0.0001

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

13

< 0.0001
< 0.0001

Group Mean with 95% Confidence Interval

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

14

Table 1 ANOVA test on EEG data with 8


different entropies

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

15

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.
4 sets of data namely Renyis, 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 preictal 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
Normal
Epilepsy

EEG Data

Pre-Ictal

Normal

30

Epilepsy

28

Pre-Ictal

27

Sensitivity =
90.91%
Specificity =
100%

Sensitivity =
96.55%
Specificity =
98.33%

Sensitivity =
96.43%
Specificity =
95.16%

PPV = 100%
NPV = 95%
PPV = 93.33%
NPV = 98.33%
PPV = 90%
NPV = 98.33%

Training 2 and Testing 2


Classification rate: 94.4444%
EEG Test Result
Normal
Epilepsy
EEG Data

Pre-Ictal

Normal

27

Epilepsy

29

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

16

PPV = 90%
NPV = 100%
PPV = 96.67%
NPV = 98.33%

Pre-Ictal

29

Sensitivity =
100%
Specificity =
95.24%

Sensitivity =
96.66%
Specificity =
98.33%

Sensitivity =
87.88%
Specificity =
98.24%

PPV = 96.67%
NPV = 93.33%

Training 3 and Testing 3


Classification rate: 93.3333%
EEG Test Result
Normal
Epilepsy

EEG Data

Pre-Ictal

Normal

29

Epilepsy

29

Pre-Ictal

26

Sensitivity =
93.55%
Specificity =
98.31%

Sensitivity =
90.63%
Specificity =
98.23%

Sensitivity =
96.30%
Specificity =
93.65%

PPV = 96.67%
NPV = 96.67%
PPV = 96.67%
NPV = 95.00%
PPV = 86.67%
NPV = 98.33%

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.

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

17

Training1 and Testing1


Classification rate: = 81.11%
EEG Test Results
Normal
Epilepsy
Pre-Ictal

EEG Data

Normal

28

Epilepsy

21

Pre-Ictal

24

Sensitivity =
75.68%
Specificity =
96.23%

Sensitivity =
87.50%
Specificity =
86.36%

Sensitivity =
82.76%
Specificity =
90.16%

PPV =
NPV =
PPV =
NPV =
PPV =
NPV =

93.33%
85.00%
70.00%
95.00%
80.00%
91.67%

PPV =
NPV =
PPV =
NPV =
PPV =
NPV =

86.67%
90.00%
76.67%
93.33%
90.00%
93.33%

Training2 and Testing2


Classification rate: = 84.44%
EEG Test Results
Normal
Epilepsy
Pre-Ictal

EEG Data

Normal

26

Epilepsy

23

Pre-Ictal

27

Sensitivity =
81.25%
Specificity =
93.10%

Sensitivity =
85.19%
Specificity =
88.89%

Sensitivity =
87.10%
Specificity =
94.92%

Training3 and Testing 3


Classification rate: = 85.56%
EEG Test Results
Normal
Epilepsy
Pre-Ictal

EEG Data

Normal

29

Epilepsy

24

Pre-Ictal

24

Sensitivity =
74.36%
Specificity =
98.04%

Sensitivity =
100.00%
Specificity =
90.91%

Sensitivity =
88.89%
Specificity =
90.48%

Table 3 Results obtained for Fuzzy


BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

18

PPV =
NPV =
PPV =
NPV =
PPV =
NPV =

96.67%
83.33%
80.00%
100.00%
80.00%
95.00%

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
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

90.91%

100%

100%

95%

96.55%

98.33%

93.33%

98.33%

Pre-Ictal

96.43%

95.16%

90%

98.33%

Normal

75.68%

96.23%

93.33%

85.00%

87.50%

86.36%

70.00%

95.00%

Pre-Ictal

82.76%

90.16%

80.00%

91.67%

Normal

100%

95.24%

90%

100%

96.66%

98.33%

96.67%

98.33%

Pre-Ictal

87.88%

98.24%

96.67%

93.33%

Normal

81.25%

93.10%

86.67%

90.00%

85.19%

88.89%

76.67%

93.33%

Pre-Ictal

87.10%

94.92%

90.00%

93.33%

Normal

93.55%

98.31%

96.67%

96.67%

90.63%

98.23%

96.67%

95%

Pre-Ictal

96.30%

93.65%

86.67%

98.33%

Normal

74.36%

98.04%

96.67%

83.33%

100.00%

90.91%

80.00%

100.00%

88.89%

90.48%

80.00%

95.00%

Normal
GMM

Fuzzy

GMM

Fuzzy

GMM

Fuzzy

Test1

Test1

Test2

Test2

Test3

Test3

Epilepsy

Epilepsy

Epilepsy

Epilepsy

Epilepsy

Epilepsy
Pre-Ictal

94.44%

81.11%

94.44%

84.44%

93.33%

85.56%

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 Renyis Entropy. The equation is:
Index

Re nyi ApEn Bi1 SampEn


Re nyi ApEn Bi1 SampEn

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

19

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
Index

Normal
0.601352.047E-02

Epilepsy
0.707793.170E-02

Pre-Ictal
0.663095.876E-02

Probability Value
< 0.0001

Group Mean with 95% Confidence Interval

Table 5 Result obtained for Index

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

20

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

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

Method

Classifier
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

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

22

Kannathal N. et al. (2006) demonstrated similar reading in his work. Using Spectral
Entropy, Renyis Entropy, Kalmogorov-Sinai Entropy and Approximate Entropy with
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
Renyis 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

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 Renyis 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, Renyis 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

Chapter 5
Reflection
The time has finally come... its 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

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

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. 379423, 623656.

[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. Krse (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

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

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

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

-16.43376952

2.240502907

-49450863.8

Param04

0.522298349

0.750108306

0.047769821

1.246586628

-16.68509287

2.308072105

-94041815.03

Param05

0.505885912

0.731923742

2.49845E-05

1.20328337

-16.38875007

2.25327774

-50520020.71

Param06

0.597463498

0.776162051

0.000260149

1.32295946

-17.00353217

2.266419509

-221303234.9

Param07

0.482822252

0.694217885

0.000140503

1.086324579

-17.26260351

2.131867256

-101711724.7

Param08

0.54487598

0.752218248

2.65356E-15

1.218408576

-16.20060608

2.217451575

-59562854.3

Param09

0.420154655

0.707584179

1.51931E-11

1.181371312

-16.65130592

2.219878339

-96512499.77

Param10

0.382121993

0.734393451

0.013244059

1.229463776

-17.35337184

2.261789905

-186148752.6

Param11

0.428825249

0.720366789

0.007610172

1.21661072

-17.62203686

2.27415899

-168440419.5

Param12

0.585706038

0.782297161

0.001201899

1.329339621

-15.97731415

2.25943792

-36257748.54

Param13

0.555406949

0.763680064

1.60021E-31

1.275042536

-16.9829631

2.264210756

-10301824.47

Param14

0.482321699

0.736113623

3.76164E-12

1.215094757

-17.71471372

2.272248756

-72916176.12

Param15

0.503528899

0.745074045

0.033430375

1.200797676

-17.46365669

2.250150253

-204068248.8

Param16

0.598153657

0.784062814

1.18774E-05

1.328963343

-16.82361918

2.27377205

-180152095.2

Param17

0.470282412

0.736349583

0.004862812

1.214207966

-17.61685109

2.26768313

-161943338.4

Param18

0.597158075

0.788992712

7.24584E-72

1.393027812

-16.21772974

2.271837246

-62129414.4

Param19

0.512391448

0.718322694

0.01933641

1.130833348

-17.35263942

2.239717876

-39955084.58

Param20

0.510747235

0.716884761

6.94225E-13

1.188543586

-16.59226204

2.29362637

-85270809.24

Param21

0.572801443

0.749767512

0.000721722

1.209448086

-16.71424266

2.264640305

-33878181.66

Param22

0.517261452

0.740394276

0.038609849

1.179246488

-16.83148747

2.277857336

-69241210.45

Param23

0.504125453

0.731028768

0.000148687

1.210306805

-16.00726922

2.274949907

-29666453.7

Param24

0.48823463

0.723233162

7.17645E-33

1.135779722

-17.27971197

2.264530988

-31207132.25

Param25

0.525493286

0.735458914

0.018207238

1.153653175

-16.69328238

2.262527226

-93140540.58

Param26

0.559988793

0.750802161

1.49998E-18

1.211941986

-16.7996421

2.228486384

-6398766.815

Param27

0.511933331

0.725774572

0.019484409

1.187890831

-17.22390011

2.293277893

-27625129.63

Param28

0.62706871

0.780948644

1.811E-12

1.288085396

-16.9036756

2.269749514

-197690018.8

Param29

0.60602528

0.77763494

2.45343E-05

1.263158714

-15.76398

2.256477084

-32441467.39

Param30

0.570120137

0.751704832

0.028534707

1.220517963

-16.69469104

2.312120285

-29094237.92

Param31

0.599150685

0.76479051

2.03937E-06

1.290736018

-15.98048119

2.315681354

-17725096.96

Param32

0.618609394

0.79239542

0.010991074

1.339440879

-15.75800416

2.261005904

-26372249.52

Param33

0.635406524

0.793808978

0.00644109

1.413019553

-16.17447116

2.244345257

-57356581.55

Param34

0.54388799

0.769563454

0.000186402

1.290122636

-16.61788124

2.285886867

-48643535.81

Param35

0.446686243

0.734938258

2.26183E-16

1.253853655

-17.30495282

2.293495934

-172508324.2

Param36

0.455127795

0.763810737

8.6487E-10

1.273478432

-15.98621136

2.246897232

-29976959.1

Param37

0.452805035

0.732622397

0.00686793

1.227011525

-17.52208515

2.27519583

-143535376.5

Param38

0.485436961

0.738911894

1.49345E-07

1.205612534

-17.71891299

2.255685272

-79475981.78

Param39

0.418995494

0.730943951

0.004111545

1.255841925

-17.30323888

2.271956203

-170940610.5

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

30

Param40

0.439369372

0.731530806

8.35176E-37

1.264401614

-16.61406291

2.288800417

-67124727.55

Param41

0.475542099

0.722940204

0.012915931

1.23347122

-17.53322824

2.265795218

-146774367.4

Param42

0.6361379

0.781648531

0.006326659

1.316645698

-17.14024412

2.263319143

-23900.45728

Param43

0.636767658

0.780255494

1.85442E-06

1.311593866

-15.58410665

2.281874086

-20692851.87

Param44

0.585870735

0.763906158

0.007953331

1.207926228

-15.71271789

2.227471894

-24971211.03

Param45

0.504021969

0.714847425

0.000177527

1.133161255

-17.34922702

2.255541551

-43098874.59

Param46

0.528351359

0.731699318

0.003913733

1.134027326

-16.7274905

2.259765358

-104547831.2

Param47

0.658081388

0.795678489

3.93545E-05

1.3985659

-16.77235464

2.328012413

-171644928.2

Param48

0.594061874

0.756264748

3.298E-151

1.242553933

-16.55676579

2.312400903

-27277222.94

Param49

0.588680303

0.75655554

0.023117334

1.176453274

-16.06539748

2.202505292

-18715443.33

Param50

0.537259334

0.753630592

1.63216E-79

1.282458828

-15.71012922

2.340513942

-20025435.26

Param51

0.611867546

0.77881702

1.15465E-10

1.422994211

-17.09762241

2.373552378

-32339.66181

Param52

0.551401973

0.761110343

0.08483018

1.276921636

-16.65225619

2.277317427

-1893073.629

Param53

0.540348368

0.740884083

0.037697983

1.146034463

-17.0843552

2.247752059

-17744619.35

Param54

0.48074224

0.718719293

0.000177805

1.166926803

-16.75350349

2.287809389

-100369912.6

Param55

0.636804619

0.788192754

0.05543793

1.306215389

-15.52921983

2.259447123

-24385026.62

Param56

0.518887872

0.737436716

1.27699E-18

1.176114121

-16.69296727

2.284923509

-52000964.88

Param57

0.624568593

0.763746256

6.52891E-06

1.238454329

-15.61370544

2.257236991

-33749620

Param58

0.667823303

0.814267907

4.5377E-05

1.441878201

-17.34979411

2.256203186

-1893264.184

Param59

0.655529773

0.810390371

0.009151698

1.450908725

-16.04295337

2.291383203

-34671780.19

Param60

0.665666335

0.802436552

1.69189E-05

1.416248822

-16.50387588

2.310328482

-62857034.51

Param61

0.643169896

0.791035451

0.000315712

1.404008292

-16.41125089

2.290831104

-52345982.69

Param62

0.646127571

0.803094978

0.000458631

1.469181322

-17.38918786

2.306260732

-2579737.583

Param63

0.639489464

0.800712873

2.05149E-79

1.372134459

-16.51568066

2.233284354

-62101580.15

Param64

0.618765997

0.779719347

0.00318596

1.304845977

-17.34595383

2.261351367

-37061695.98

Param65

0.590023689

0.824817707

6.95657E-06

1.543983891

-17.00345457

2.287731744

-127029711

Param66

0.651362099

0.836339463

0.007737245

1.555450831

-16.41909902

2.290905353

-65702324.13

Param67

0.650628662

0.802627689

1.40442E-24

1.439658831

-17.24431691

2.275803774

-83612686.23

Param68

0.612504141

0.792546414

0.024537033

1.294580352

-16.69598483

2.26097425

-95484117.91

Param69

0.578524181

0.779684644

3.77758E-15

1.359171349

-16.52510989

2.246493549

-59187238.63

Param70

0.661200988

0.811906714

0.012264696

1.498817094

-17.33959753

2.325149402

-1928178.925

Param71

0.688039398

0.820782259

0.008460501

1.456401038

-16.00304927

2.270342024

-31103895.89

Param72

0.527017346

0.790209112

2.00422E-27

1.464163375

-16.97192353

2.271116348

-123039705.4

Param73

0.61129719

0.78865252

0.023363774

1.426427451

-16.18786944

2.270653057

-37655702.41

Param74

0.661237453

0.805857511

0.015543732

1.499511938

-17.32194826

2.298366259

-1710382.742

Param75

0.676420712

0.805486467

2.13524E-26

1.49227568

-16.08293158

2.307404543

-35700576.78

Param76

0.631499975

0.783336194

4.16038E-07

1.342693505

-17.17384578

2.257477777

-18804927.08

Param77

0.606925666

0.806789767

0.001488973

1.503636666

-16.85821911

2.280620735

-110194989.9

Param78

0.617277888

0.819089517

1.84E-145

1.500425357

-17.18656892

2.258883811

-266037179.2

Param79

0.606363875

0.812175989

0.018987507

1.431037127

-16.18900993

2.258551733

-53890947.09

Param80

0.622575501

0.797694534

0.016732456

1.347832978

-17.00627436

2.237870709

-80935693.45

Param81

0.648259142

0.794494756

1.01595E-38

1.388539277

-16.43490345

2.283446307

-74210359.97

Param82

0.609594472

0.7844065

0.001158203

1.5342162

-16.32495859

2.322598684

-46330125.5

Param83

0.679020854

0.806670891

1.82603E-07

1.572622964

-17.27458133

2.315595787

-564782.8411

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

31

Param84

0.660277812

0.805014936

8.99371E-67

1.501499278

-15.8459668

2.296602815

-27787286.42

Param85

0.639846834

0.794146686

1.00634E-16

1.428179953

-16.26343479

2.255340465

-46943617.64

Param86

0.623367715

0.785335184

0.015365423

1.36869146

-17.05024473

2.263177082

-13020792.44

Param87

0.537383807

0.808172545

1.09461E-05

1.534492016

-16.66946502

2.333284094

-92176066.28

Param88

0.604442899

0.786255769

4.51067E-06

1.387763154

-16.84353019

2.287272375

-65448953.93

Param89

0.674044848

0.796192503

2.56844E-72

1.421479429

-16.24287522

2.278477795

-62546488.6

Param90

0.653468402

0.794916949

0.000455356

1.627867009

-16.06512115

2.298587595

-35097184.48

Param91

0.613586726

0.790540123

1.11422E-18

1.337808307

-16.08581334

2.315329943

-39051328.65

Param92

0.545997637

0.76714435

4.59819E-27

1.301802832

-16.57830724

2.288655852

-63322167.28

Param93

0.556167249

0.767651453

0.009642746

1.287617217

-16.72904764

2.283903431

-103993544.7

Param94

0.538151851

0.741486649

0.010474047

1.211054936

-17.88133016

2.252777075

-98509111.91

Param95

0.46474627

0.734480817

0.007204768

1.231919753

-17.50758229

2.251488908

-213700015

Param96

0.525408446

0.760302125

0.000639646

1.290600737

-17.02306769

2.269570859

-12389152.87

Param97

0.508636153

0.748649345

4.54351E-07

1.304873512

-16.13143183

2.333063264

-34246415.11

Param98

0.552373299

0.767227787

0.010283277

1.305033276

-16.90621714

2.281159256

-199025462.4

Param99

0.6389819

0.787381589

0.010032047

1.335544207

-16.69974804

2.329959254

-27600428.48

Param100 0.513341269

0.747081961

0.002115133

1.229912236

-17.64035041

2.275910304

-167695670.5

Param101 0.55754777

0.762422489

2.66971E-20

1.256471905

-15.84657521

2.228619711

-38050836.18

Param102 0.642556814

0.792086604

1.13403E-44

1.331529594

-16.86148014

2.293473387

-5492343.956

Param103 0.519553308

0.752062939

1.9063E-20

1.24960585

-16.09456711

2.23442541

-58928053.57

Param104 0.676644935

0.827653498

0.007617452

1.54219873

-16.02854822

2.276043836

-34297207.67

Param105 0.556886037

0.776020043

0.017266842

1.374873855

-16.07632998

2.294781641

-18827286.89

Param106 0.406018601

0.758457747

0.002784126

1.249884151

-16.25580148

2.195344853

-11579677.34

Param107 0.625067959

0.795003821

0.008096461

1.3564489

-16.06636142

2.257358372

-22669508.07

Param108 0.565346079

0.779913863

0.022007313

1.350747063

-15.30085401

2.264593771

-11976990.43

Param109 0.55632798

0.767487101

1.16245E-49

1.269244839

-15.282273

2.076956401

-23395875.35

Param110 0.399486902

0.727410521

0.065150399

1.172212561

-16.20364388

2.056117502

-12450582.64

Param111 0.53308515

0.756241994

1.45398E-10

1.298645828

-15.73306268

2.167036532

-12308188.57

Param112 0.547308962

0.743860248

6.82477E-13

1.245663587

-15.79970816

2.176919761

-13645529.38

Param113 0.562968168

0.737483819

9.36935E-32

1.229655293

-15.33771423

2.159846926

-24181848.94

Param114 0.445177345

0.702354039

1.83348E-07

1.136068313

-15.83452737

2.057505733

-39327917.93

Param115 0.470755652

0.78011834

0.030264387

1.332284353

-14.98061851

2.142068151

-7233574.748

Param116 0.424447344

0.755785752

3.99766E-29

1.271152879

-16.03479436

2.149218356

-43514803.8

Param117 0.538744894

0.769715491

1.7943E-110

1.371055662

-15.19035006

2.211027904

-21974288.42

Param118 0.566723868

0.781959263

2.93333E-10

1.298018112

-16.3383236

2.156801453

-76588111.62

Param119 0.496562023

0.741935889

1.31553E-11

1.186449766

-15.25826819

2.091320346

-22185593.18

Param120 0.624121319

0.8057627

3.73122E-17

1.41428749

-14.88059295

2.190852559

-8782389.87

Param121 0.447849565

0.755614108

1.09591E-90

1.368627488

-15.09807391

2.202129211

-9887900.707

Param122 0.486328807

0.748412699

0.001059677

1.308054879

-15.11467444

2.214407211

-9844813.406

Param123 0.499911416

0.803271788

9.80337E-05

1.394418603

-16.15981305

2.153484895

-50618038.87

Param124 0.699354678

0.865724308

0.00805299

1.704625147

-15.51635997

2.262811317

-24029843.43

Param125 0.450722528

0.759015715

1.71457E-56

1.238365674

-16.19265121

2.165353104

-53081292.05

Param126 0.542096747

0.810551986

0.027404537

1.410999084

-16.42815204

2.15250031

-85007072.75

Param127 0.687114111

0.809405579

3.6739E-06

1.519366706

-15.68237379

2.331158486

-35210044.41

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

32

Param128 0.50408279

0.746928142

0.010709729

1.286376417

-16.49313791

2.225853874

-678750.5514

Param129 0.654908337

0.84131903

0.002619459

1.608787915

-15.82206214

2.241687292

-34729021.74

Param130 0.67695079

0.876248048

0.004053588

1.754559783

-17.01222404

2.278682758

-221795413.1

Param131 0.60225192

0.762056294

0.033028897

1.317107955

-15.12932401

2.230821089

-20418117.63

Param132 0.616621664

0.807045526

0.000995121

1.422773468

-14.89301463

2.224730646

-9054952.13

Param133 0.644754685

0.839621198

0.002547355

1.603804484

-16.88710897

2.308266616

-194533347.6

Param134 0.511501649

0.812389791

0.009486402

1.534588624

-16.19681293

2.248357259

-11493941.84

Param135 0.273522381

0.689567879

0.03666155

1.108478161

-16.36241571

2.060938145

-65651025.1

Param136 0.531885108

0.779148702

8.01317E-18

1.331670555

-16.10337452

2.241154569

-47081518.96

Param137 0.559325032

0.777494421

0.004375856

1.268320042

-15.97101088

2.215202367

-41277117.8

Param138 0.674393687

0.825046106

9.88925E-07

1.585349028

-17.04624989

2.315826315

-30.86537608

Param139 0.474745894

0.720904761

1.84565E-50

1.13607392

-16.36543038

2.087828866

-56002744.03

Param140 0.615832896

0.839136139

0.002735494

1.597423147

-16.68912418

2.30766104

-155295382.3

Param141 0.395300485

0.747458838

6.83566E-26

1.258581853

-16.02955434

2.175527319

-43331015.71

Param142 0.655839058

0.818074645

2.10807E-34

1.578625008

-17.0583858

2.338251995

-1040.055651

Param143 0.649742119

0.812978263

1.3531E-22

1.411049608

-15.22092815

2.231596223

-18592804.48

Param144 0.656901721

0.797257847

0.001142341

1.406575962

-15.90400549

2.286115971

-36384485.11

Param145 0.623907883

0.792546771

3.8027E-19

1.306425883

-15.73431698

2.176388098

-31583925.96

Param146 0.493709271

0.766304206

5.19981E-07

1.390959911

-15.88325483

2.254469442

-12353265.03

Param147 0.552111783

0.766369857

0.003404153

1.316086355

-16.70317343

2.223771997

-2613012.493

Param148 0.565560202

0.766574765

4.19306E-59

1.30209677

-15.8831477

2.271347071

-36007949

Param149 0.67098361

0.809103292

4.14093E-12

1.408961405

-16.67037482

2.271251289

-151979294.2

Param150 0.485972882

0.763371943

0.049611335

1.293636088

-16.14332022

2.263565427

-49140066.28

Param151 0.522062979

0.799403114

0.002969597

1.502116757

-15.69184767

2.305084902

-30907458.07

Param152 0.649932197

0.802099198

1.75991E-16

1.509049013

-15.6798567

2.330721423

-35607161.77

Param153 0.50294316

0.765595776

0.00148431

1.241868121

-15.20317198

2.181045046

-18989141.47

Param154 0.461843671

0.749115498

1.90994E-51

1.226914739

-16.37112844

2.176035934

-26583019.94

Param155 0.655058557

0.802650084

3.6952E-10

1.366588972

-16.03169776

2.226486758

-19350047.37

Param156 0.382561844

0.759563575

0.026820322

1.340543682

-16.11554741

2.25524622

-49115380.98

Param157 0.41817883

0.728961928

0.013864408

1.210065463

-16.13512601

2.204005052

-47308991.29

Param158 0.574608741

0.817219249

0.016241628

1.6142521

-15.69134168

2.30124087

-26748361.51

Param159 0.524598666

0.728677885

0.020868538

1.186837589

-15.56721319

2.182999902

-16570741.73

Param160 0.567052392

0.750507236

1.43056E-63

1.262079703

-16.57193725

2.247518249

-808853.6574

Param161 0.64768695

0.791011207

0.003010281

1.435882168

-17.05224607

2.294388843

Param162 0.479434542

0.746369507

1.10376E-05

1.186641886

-16.24976459

2.143858151

-60907147.75

Param163 0.588593405

0.765861477

0.010162182

1.326879822

-15.52346949

2.269922579

-9289612.875

Param164 0.638608

0.812843522

3.81768E-34

1.47656826

-16.24748222

2.2944691

-10854404.6

Param165 0.650839833

0.804879384

0.000136567

1.456987323

-15.58521595

2.266758057

-32296404.31

Param166 0.607659478

0.781942142

1.8245E-24

1.451422864

-14.73817732

2.362081768

-6534125.073

Param167 0.583949056

0.760802202

1.282E-05

1.262944402

-16.14733265

2.206672953

-18104993.54

Param168 0.497838381

0.773595646

0.033129192

1.325452549

-15.76676327

2.21044982

-29079922.18

Param169 0.41940784

0.757923956

0.016057818

1.312818859

-16.1454604

2.279883168

-51842972.96

Param170 0.605384448

0.77106387

1.36369E-63

1.26619741

-15.97957905

2.173267476

-40596252.6

Param171 0.433704474

0.742172774

9.37518E-46

1.247876744

-16.37789586

2.211390056

-27827145.54

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

33

Param172 0.614584198

0.797160383

0.000648446

1.352753292

-15.9601958

2.229589304

-44748589.87

Param173 0.618504584

0.781859001

1.1605E-05

1.30653674

-16.44052887

2.188719393

-63598.87746

Param174 0.57365867

0.770239743

0.015759142

1.273823545

-15.77719942

2.185896523

-38653725.38

Param175 0.55020769

0.765129307

0.014177625

1.283892886

-15.90993529

2.238529272

-48128615.83

Param176 0.528087489

0.776455552

5.22583E-05

1.257919153

-15.43405686

2.152456862

-16373873.01

Param177 0.496082119

0.764115526

1.12084E-12

1.257973931

-16.18826255

2.208169597

-50469650.71

Param178 0.652169686

0.799630237

1.5817E-05

1.477511284

-15.64469185

2.30031534

-33841032

Param179 0.606139709

0.795394453

0.01153601

1.373160028

-15.59079252

2.277538348

-27519325.44

Param180 0.635029701

0.788945504

0.019127693

1.429554576

-16.4001298

2.289244356

-5407.932806

Param181 0.603480403

0.772567118

2.71584E-35

1.337770613

-15.70556272

2.279366417

-32068364.41

Param182 0.627678241

0.810538791

1.35707E-71

1.452196061

-16.09457029

2.28142312

-53809220.64

Param183 0.537989395

0.771952836

0.041287977

1.389549535

-16.48586104

2.33379066

-176814.4584

Param184 0.567928687

0.766595723

3.0091E-36

1.314289954

-15.61635365

2.26705001

-21583086.66

Param185 0.580807938

0.794984091

0.036526892

1.351276949

-15.94205584

2.193445897

-42480114.51

Param186 0.550854954

0.771583824

5.01099E-20

1.29902214

-16.67503472

2.218600869

-1780816.023

Param187 0.594535852

0.801730436

0.000153707

1.444059783

-15.58517488

2.278214272

-25942293.27

Param188 0.60925192

0.783914102

0.061267988

1.353528196

-15.83206741

2.230915623

-32284454.69

Param189 0.549898606

0.768919243

0.015147573

1.253310874

-15.98000554

2.210934248

-4815559.066

Param190 0.663713081

0.813609265

0.013698092

1.434185864

-16.07814172

2.278825358

-52471084.72

Param191 0.567737024

0.781323972

0.017359146

1.411791798

-16.24993551

2.296073968

-10241611.22

Param192 0.556133465

0.76720612

0.023077504

1.265340212

-15.72661525

2.206139386

-22999638.05

Param193 0.640883185

0.799447535

3.07895E-14

1.417974454

-15.89160927

2.317113957

-28067488

Param194 0.570686527

0.764313303

1.01997E-18

1.231237848

-16.22399484

2.200351427

-43585037.78

Param195 0.614450683

0.775125256

5.6729E-154

1.261342889

-15.95747022

2.21514791

-41711173.78

Param196 0.624347688

0.778721831

0.002540215

1.325925405

-16.74223482

2.282109132

-3964522.199

Param197 0.572271079

0.775495676

1.13645E-23

1.277463946

-15.76174208

2.224596896

-23824887.93

Param198 0.570234951

0.770897039

7.26177E-06

1.311362021

-15.98221991

2.258256226

-12712795.84

Param199 0.662103228

0.803119379

4.90494E-08

1.339421907

-16.03664077

2.230009885

-19468298.97

Param200 0.557037354

0.78087344

0.064832385

1.355294039

-16.17111505

2.259009433

-10731136.93

Sample
0.808348319
1.12376066
0.992562342
1.075116653
0.921185615
1.032418321
0.670957367
0.900294546
1.016586558
0.956926865
0.891614869
0.725131571
0.793891872
0.903795012

Shannon
858185.2769
0
0
0
0
0
0
0
0
0
0
0
0
0

Renyi's
-20.66890234
-20.77288716
-20.1735575
-18.46823443
-19.9325194
-17.99617434
-19.35019505
-20.34062804
-19.93995593
-20.92970301
-20.10190646
-20.67035306
-20.90364844
-18.37013544

AppEn
1.959119931
2.180516391
2.112414084
2.011155926
1.942726522
2.141787495
1.418179803
1.713924121
2.111238243
1.953643246
2.015517994
1.652238994
1.637112941
2.010985707

Wentropy
-4322420996
-6169330931
-3462060971
-613601710.5
-2412433983
-346662961.4
-1314790827
-3860343070
-3205100553
-5780273240
-4941471531
-8183566647
-8255361970
-123294255

Entropy values for Epilepsy Signal


System
Param1
Param2
Param3
Param4
Param5
Param6
Param7
Param8
Param9
Param10
Param11
Param12
Param13
Param14

Bispec1
0.660152962
0.640312009
0.665330149
0.193213893
0.521008894
0.41133349
0.586595596
0.128853768
0.385914163
0.693187379
0.654399288
0.544034697
0.465729356
0.605149616

Bispec2
0.78096093
0.778272466
0.790897728
0.688317589
0.735306369
0.717408765
0.81955884
0.598578958
0.715523646
0.811157395
0.789606971
0.715505952
0.730082675
0.741291393

Kalmogorov
5.21552E-09
0.000394384
7.75542E-09
0.001871851
1.52518E-20
0.017942703
0.000758951
0.000118889
0.006270654
0.032070731
0.004093639
9.69803E-47
3.14446E-47
0.15547003

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

34

Param15
Param16
Param17
Param18
Param19
Param20
Param21
Param22
Param23
Param24
Param25
Param26
Param27
Param28
Param29
Param30
Param31
Param32
Param33
Param34
Param35
Param36
Param37
Param38
Param39
Param40
Param41
Param42
Param43
Param44
Param45
Param46
Param47
Param48
Param49
Param50
Param51
Param52
Param53
Param54
Param55
Param56
Param57
Param58
Param59
Param60
Param61
Param62
Param63
Param64
Param65
Param66
Param67
Param68
Param69
Param70
Param71

0.524321381
0.413882479
0.633537705
0.568228912
0.566877855
0.198332722
0.544993842
0.619758226
0.611640109
0.623221012
0.524799674
0.335019938
0.656028562
0.498471781
0.389875226
0.656320435
0.247264381
0.544972726
0.497547093
0.657559722
0.624092664
0.319879678
0.669993308
0.566015242
0.244333496
0.410540453
0.570742664
0.203566617
0.555995871
0.487270811
0.37221263
0.358208836
0.687059052
0.255565345
0.648296521
0.417463199
0.582687975
0.670505056
0.503736272
0.242190327
0.564995244
0.590150264
0.211069908
0.534819645
0.55221545
0.535897679
0.177956789
0.610273288
0.421589395
0.594609042
0.547561239
0.526645724
0.416247875
0.608452234
0.48363852
0.258613336
0.580993539

0.734217343
0.663325353
0.786814984
0.778346143
0.731971789
0.690601246
0.715111935
0.771242023
0.765171219
0.758535657
0.722672089
0.693115316
0.781131562
0.715321583
0.674532205
0.789073076
0.681767725
0.731267489
0.694704483
0.790956178
0.786009609
0.673641528
0.789453095
0.724277822
0.662088832
0.738780444
0.755877099
0.69325988
0.723262963
0.716087733
0.723573741
0.731981973
0.80584748
0.713105846
0.79687507
0.699289746
0.745592492
0.800101367
0.743299156
0.675095517
0.71441595
0.739811229
0.67440218
0.738280989
0.728291522
0.757498729
0.644963262
0.754896379
0.713925589
0.73484227
0.704070322
0.731900337
0.738100313
0.785901315
0.736544704
0.671106627
0.729162432

1.67173E-46
0.275047346
0.000290136
8.86865E-36
2.5842E-232
1.53439E-69
8.33614E-05
2.29525E-75
1.90551E-25
5.47293E-20
1.00086E-42
1.2523E-112
0.011653099
9.24636E-33
1.128E-133
0.118036297
0.002868347
6.52311E-06
0.342392445
0.087416204
0.007113149
0.000171558
0.000857988
1.16643E-08
1.10721E-06
0.000443997
0.108088016
4.26354E-06
0.028854853
2.39112E-05
4.6909E-26
1.09801E-06
1.65343E-22
0.028480556
5.67302E-07
0.137042143
2.72718E-43
4.21816E-19
1.3738E-102
3.35811E-08
1.02008E-07
0.269828324
0.059967007
5.53143E-18
0.11834955
0.000500833
0.003176158
3.59003E-61
0.004551641
0.12561631
0.203926578
0.094725745
2.3835E-07
2.4593E-13
1.45338E-08
4.49716E-06
7.54655E-19

0.853810383
0.708856049
1.119684123
0.798224003
0.848299359
1.007580959
0.788793437
0.836176779
0.871830115
1.158141724
0.79996684
0.9481852
1.136806717
0.990881557
0.841853307
0.986233679
0.760663681
0.78750866
0.826391681
1.067396312
1.260820558
0.954784908
0.806050791
0.830699003
1.064263465
0.812853756
0.853823074
1.050230046
1.119455797
1.043866191
0.695461373
0.887416587
0.868989825
0.952908958
0.975319493
0.899923632
0.835352811
1.138913146
0.848154864
0.96823158
1.062830833
0.644062227
0.970285795
0.935693979
0.922479096
0.656499822
1.108207169
0.961824563
0.994445351
0.96887997
0.700477841
1.014209411
0.970194811
0.94136251
0.839914759
1.028832778
0.915081832

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

35

-19.04636626
-17.64178866
-21.08583063
-18.31110341
-20.54983695
-18.85122538
-17.95839117
-18.87040652
-19.05827054
-19.69393264
-20.10789566
-19.12931945
-20.88592402
-20.65557169
-18.8420898
-20.6149275
-19.63332331
-17.87768467
-20.0424194
-20.19347399
-20.85575034
-18.79855679
-21.08159723
-18.57758378
-17.65330343
-18.9207249
-20.4635943
-19.908162
-17.72720913
-20.24482127
-18.85377785
-19.59984323
-21.09122888
-19.33757982
-20.72770534
-19.52727383
-18.05788065
-19.3700228
-19.20315316
-19.37821393
-18.26511136
-18.47170894
-19.52351307
-19.79764512
-21.15330347
-20.72167099
-19.38997114
-19.67936181
-18.03267274
-18.17039143
-20.18625685
-19.61601042
-20.71241914
-20.96226756
-19.23076953
-18.90722813
-18.36460688

1.765343352
1.482936973
2.182169417
1.642810541
1.827125019
1.975266122
1.81616136
1.998767744
2.010310715
2.272426738
1.748394148
1.977778126
2.197393725
1.994964644
1.731072257
2.151379683
1.621467646
1.701849856
1.875366833
2.159907686
2.191915383
2.086115398
1.953127172
1.866986569
2.086388802
1.680457374
1.920459532
1.904808676
2.209488183
2.169571987
1.494583932
1.999221537
1.914540237
2.072850723
2.128094952
1.971138526
1.871492712
2.224297027
1.781388986
1.923056603
2.118248491
1.447747955
1.890787365
1.976133094
1.873792832
1.680687383
1.968153765
2.042072064
2.124273773
2.094796611
1.683946128
2.088817012
2.123203833
2.082132798
1.751804751
2.114247534
1.884670872

-1130042095
-288679671
-7991470850
-463663808.2
-6767896875
-897212097.3
-444200283.9
-320114026
-584739203.2
-1715557807
-2484742156
-1271574170
-5346387677
-7600333752
-461781079.5
-6521442028
-1750366856
-177911822.1
-1893208191
-5189251929
-7163314341
-863826291.8
-5380659811
-827786968.4
-227318904.6
-923639884.5
-3595533125
-1949981985
-190123718.4
-5679402416
-1316196148
-2130438705
-5702808513
-1920577415
-4815055716
-1948139938
-230256000.9
-1430468247
-1236349495
-1566498776
-436600576.4
-944749583.9
-1230048006
-3528427406
-12358007733
-3183720948
-1331797648
-2361192715
-219198015.6
-468563943.7
-5370757213
-1566124518
-5332697004
-5457477184
-1217570143
-520568007
-692598409.1

Param72
Param73
Param74
Param75
Param76
Param77
Param78
Param79
Param80
Param81
Param82
Param83
Param84
Param85
Param86
Param87
Param88
Param89
Param90
Param91
Param92
Param93
Param94
Param95
Param96
Param97
Param98
Param99

0.208068233
0.570800446
0.550178329
0.302039686
0.6697321
0.600114942
0.609653006
0.509449785
0.174867236
0.559100813
0.482682993
0.289751555
0.457791645
0.665016563
0.632727808
0.506882153
0.338625711
0.374675307
0.695818595
0.537396722
0.596711794
0.50573945
0.209828555
0.199253426
0.50400854
0.214620502
0.194163681
0.579851566

Param100 0.51103737

0.689964304
0.720912018
0.77295189
0.674907052
0.794273271
0.738746869
0.760096013
0.751302531
0.622830312
0.756399629
0.709606453
0.762453924
0.714539875
0.787895474
0.797530384
0.696363499
0.688181398
0.682649563
0.819816083
0.743193851
0.755289424
0.764455126
0.691672646
0.692687366
0.717842104
0.644434904
0.651026868
0.786691115

0.234493531
0.000683424
1.2312E-128
5.08866E-05
9.63522E-06
0.000189456
9.06362E-12
2.05435E-05
0.321252886
0.000906315
6.35363E-08
9.7847E-144
3.84399E-06
3.50456E-17
0.012946316
0.232479268
0.150918297
2.07735E-08
0.000451481
0.062033797
0.001760973
4.8145E-05
1.18414E-06
0.001103656
4.96722E-09
5.84956E-64
2.76145E-09
0.000821253

0.996488578
0.939182178
0.863262061
0.956582041
0.910706239
0.990876852
0.889902998
0.792180106
0.804578393
0.859377962
0.950207127
1.150306965
0.629647299
0.87213719
1.106196478
0.816267429
0.958837464
0.853900141
1.402840199
0.989236928
1.044238711
0.677894578
1.007301083
1.075138623
1.049618259
0.759320189
1.027429175
0.749289552

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

-19.38772213
-19.90929322
-17.89054225
-18.92824338
-20.72002345
-17.86745805
-18.04959389
-20.79849357
-20.82249231
-20.55965241
-20.29387118
-17.70201727
-18.20465297
-20.53202833
-18.6746942
-20.17455817
-18.76621108
-18.86086206
-19.55757794
-20.37737853
-19.48058727
-20.73155639
-19.72157635
-19.16883723
-17.84806413
-20.94788335
-19.68160303
-20.2027611

1.95271231
2.063745194
1.859070753
2.046713821
2.017347222
2.127812832
1.966974023
1.755621645
1.357030559
1.911883469
1.939932152
2.174167365
1.346248033
2.003513661
2.162536289
1.865654164
2.022057791
1.697435058
2.266608334
2.075590106
2.136625812
1.728960936
1.881687846
2.017985325
2.231689907
1.351867076
1.881513306
1.883168633

-1758525138
-4308816980
-76687646.63
-594101981.1
-4288228612
-105399987.5
-208559127.9
-8254843979
-5964126236
-4343060243
-4515764138
-41818578.94
-264892350.5
-3717507289
-702504596.8
-2812687821
-526257391.9
-1301535454
-1443790492
-3639786693
-1793244901
-4350684020
-1491235313
-1397640148
-131544577.2
-6377608544
-1662960539
-6020712633

0.717072026

0.093281202

1.071764765

-19.43380478

2.139690857

-1793790541

Sample
1.140326406
0.543176551
0.956769446
1.017012816
0.963243116
1.148202784
1.263223976
0.579376476
0.381895475
0.553669649
0.854363956
1.000461163
1.180328394
1.131160262
1.071115313
1.170208847
1.030062612
1.179419812
0.967973839
0.935717879
0.847247255
0.959047281
1.12177762

Shannon
1358160.409
1366764.374
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Renyi's
-15.71781404
-18.16098498
-16.98427159
-16.20847003
-17.21989841
-15.73139395
-16.04291273
-17.62923
-20.49184524
-18.22218711
-16.67757669
-15.78285827
-15.03316583
-15.34008598
-15.49354033
-16.23834693
-15.56606046
-16.62668921
-15.83062982
-15.73866737
-18.26796626
-16.8651613
-16.68640525

AppEn
1.918114991
0.937171624
1.9432013
1.940057403
2.029114219
2.064756712
2.122888882
1.089845521
0.54299444
1.014651823
1.762570984
1.992236584
2.138430477
2.104259062
2.049771857
2.06483132
2.108729844
2.206699552
1.967777899
1.803351142
1.703459884
1.878453489
2.173271186

Wentropy
-52470390.27
-760567434.9
-54146109.98
-3615760.565
-122976943.1
-293351.6649
-7960440.33
-314426203
-9496832031
-795878326.5
-11718618.96
-25763550.66
-21395139.92
-4377456.637
-36886279.24
-48861280.36
-16703816.25
-76151979
-1517006.377
-46397692.95
-302133575.6
-62349049.18
-62781204.67

Entropy values for Pre-Ictal Signal


System
Param1
Param2
Param3
Param4
Param5
Param6
Param7
Param8
Param9
Param10
Param11
Param12
Param13
Param14
Param15
Param16
Param17
Param18
Param19
Param20
Param21
Param22
Param23

Bispec1
0.439538677
0.356565042
0.449302499
0.507189396
0.520701458
0.499363394
0.52996767
0.411952233
0.385817728
0.392964552
0.314194005
0.541542411
0.543718116
0.513931423
0.466701214
0.508817571
0.494071379
0.553931387
0.456001967
0.47165031
0.534219173
0.426756069
0.545689123

Bispec2
0.678324856
0.615705589
0.689452652
0.676163372
0.731327547
0.680643079
0.737611239
0.632950541
0.640046389
0.626316752
0.64697957
0.692406644
0.701833745
0.679685546
0.663091951
0.72391298
0.655565403
0.713165894
0.693607903
0.649665871
0.730446059
0.661903961
0.701558431

Kalmogorov
1.30274E-35
0
1.96419E-55
0.026261414
1.2188E-137
1.28268E-05
0.039731705
1.78454E-55
0.256582076
2.1064E-95
9.18394E-41
6.71882E-13
3.5466E-110
6.30502E-31
1.40771E-09
0.020383866
0.075642837
0.059495882
1.65711E-08
1.2492E-121
0.010252928
2.86603E-25
3.4508E-138

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

36

Param24
Param25
Param26
Param27
Param28
Param29
Param30
Param31
Param32
Param33
Param34
Param35
Param36
Param37
Param38
Param39
Param40
Param41
Param42
Param43
Param44
Param45
Param46
Param47
Param48
Param49
Param50
Param51
Param52
Param53
Param54
Param55
Param56
Param57
Param58
Param59
Param60
Param61
Param62
Param63
Param64
Param65
Param66
Param67
Param68
Param69
Param70
Param71
Param72
Param73
Param74
Param75
Param76
Param77
Param78
Param79
Param80

0.523568039
0.468528067
0.514879202
0.445798288
0.521048838
0.3393317
0.350269273
0.557465477
0.336107655
0.548634999
0.537371205
0.489448849
0.501844774
0.484491934
0.480662455
0.442125388
0.421126163
0.450296567
0.447481596
0.531236779
0.523098299
0.496617233
0.452085968
0.494195672
0.470611513
0.42731342
0.381718995
0.447340046
0.485513715
0.369597856
0.55057608
0.484425803
0.510853382
0.399593783
0.499831122
0.500768758
0.46650443
0.426573516
0.390881917
0.435751961
0.489528027
0.571853365
0.297311209
0.491042772
0.496940179
0.498441218
0.407181009
0.485837675
0.521575063
0.479140514
0.549835889
0.482012877
0.3750712
0.585619878
0.482844345
0.428606526
0.51558416

0.713045149
0.681069265
0.70471661
0.639232204
0.70131235
0.603927166
0.655443875
0.758708243
0.691356981
0.696759072
0.693724357
0.653541156
0.662337858
0.72318961
0.667695103
0.616724686
0.69819765
0.629056134
0.701111619
0.693612905
0.690179883
0.727469964
0.707223077
0.719427744
0.704013866
0.673512136
0.577997279
0.692002003
0.663650908
0.609437219
0.704740127
0.673929702
0.726620656
0.603828277
0.670510482
0.66574056
0.676135394
0.678553356
0.604511058
0.667686452
0.699415149
0.743751304
0.62943997
0.662009003
0.67631742
0.689007422
0.695167469
0.673725261
0.725062352
0.654828897
0.729621064
0.69116311
0.658541755
0.74622887
0.719822122
0.614678058
0.728622724

1.63583E-26
0.010375913
1.23061E-05
5.1467E-05
1.12113E-07
1.1763E-205
1.75495E-09
2.325E-196
0.122899544
0.007625511
2.77928E-05
0.001623935
5.7063E-144
0.059146645
6.6133E-114
0.185816644
0.021407083
9.94124E-05
0.105254702
1.51668E-26
1.63502E-21
4.70362E-07
0.014174358
1.27019E-06
3.06695E-05
9.749E-118
0.086891449
5.70508E-41
0.012731477
0.035232164
1.87654E-20
6.66026E-55
0.125796878
1.0761E-107
0.03454652
1.00343E-05
1.11209E-50
7.28448E-87
0.002294768
0.010267559
1.48846E-07
1.70964E-73
0.006718258
0.044094585
0.000290498
3.3821E-102
0.025011553
4.12711E-16
2.20618E-38
0.229054303
2.6835E-39
4.95035E-43
2.00701E-10
0.006805575
1.40067E-52
6.1552E-143
0.010937269

1.136320754
0.999842621
1.071435498
1.008927728
1.022153417
0.578217534
0.553012879
0.992413953
0.91461549
0.985009621
1.179079943
1.01808952
0.971969908
1.261574357
1.015189364
0.871602245
1.063440219
0.6378656
1.066696487
1.17767871
0.98745293
1.161412081
1.195746127
1.163236839
1.154693016
0.906869506
0.830154141
0.971272857
0.939917931
0.894920271
1.132942437
0.945765349
1.100218354
0.883806308
1.116970863
0.972558103
0.826769701
0.842348095
0.846037819
0.873852033
0.832972958
1.269651114
0.866022428
0.95236652
1.096357143
1.020790253
0.757665878
1.016824825
1.155491652
0.85271051
1.177460268
1.161077227
0.459417486
1.301291984
1.159791591
0.945770587
1.258842845

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

37

-17.03157259
-17.34774728
-14.39526505
-16.93377042
-16.24342613
-17.62017182
-18.32736749
-17.30842747
-17.19112018
-15.8391012
-14.70954055
-15.82303402
-15.5722059
-16.26114618
-16.36533792
-16.63331336
-15.14724472
-16.96321226
-15.07115765
-16.77093414
-17.29948954
-16.01453341
-16.21981163
-17.06264924
-16.64693672
-15.75289619
-16.72088893
-16.92041544
-15.79334799
-16.00979749
-16.76670342
-16.4871148
-15.722086
-16.39369123
-15.35168184
-15.92028061
-19.82785362
-17.60314129
-16.53829941
-15.96024651
-16.80674448
-16.29427304
-16.39747026
-16.18765184
-15.9061006
-16.04636547
-17.76704074
-14.84503961
-15.17376341
-18.79609534
-16.72437417
-15.54459519
-19.19013479
-16.42072018
-15.96133973
-16.79933253
-16.00333778

2.042546704
1.920500946
1.885794583
1.709621605
2.019768871
1.010637675
0.927212906
2.06682786
1.824482026
2.012123713
2.126203261
2.109099844
1.96917638
2.190367345
1.95798411
1.683025914
1.929369204
1.154619864
1.9345719
2.261186647
1.979732345
2.038987585
2.155130204
2.061541231
2.048008517
1.772966429
1.593830538
1.974374011
1.875517623
1.649123422
2.177545635
1.898654134
2.045315357
1.695480728
2.11734137
1.909829214
1.602757313
1.682427386
1.667884357
1.724924216
1.674852053
2.179933904
1.773283513
1.863313668
2.097137982
1.926330816
1.582664779
1.911353955
2.011077935
1.678311818
2.093482766
2.125601915
0.757937629
2.215474769
2.107416179
1.65181266
2.180734473

-142911342.6
-183128512
-7600790.063
-25272448.04
-2714962.247
-306439718
-622249900.4
-154680289.6
-72033907.67
-17011780.12
-9200057.968
-16654091.27
-17472591.53
-83220423.35
-34068328.04
-47468905.51
-15080648.56
-71295653.71
-22387241.16
-131946970.3
-2364399.552
-24165750.28
-80991446.08
-230579846.7
-98049145.37
-21400695.16
-93455879.3
-80440357.51
-12157046.31
-31162517.67
-50554542.86
-60815857.91
-39010049.45
-101510040.2
-12548683.59
-25713976.64
-2427090682
-242499915.9
-49945770.09
-36698287.79
-53188378.6
-32360143.54
-17526639.64
-23683835.42
-62628780.93
-754962.0119
-403441239.2
-5017011.687
-9752488.029
-673572671.1
-83663408.67
-42978931.02
-1830669135
-15916046.05
-28070040.02
-11743640.45
-26098146.71

Param81
Param82
Param83
Param84
Param85
Param86
Param87
Param88
Param89
Param90
Param91
Param92
Param93
Param94
Param95
Param96
Param97
Param98
Param99
Param100
Param101
Param102
Param103
Param104
Param105
Param106
Param107
Param108
Param109
Param110
Param111
Param112
Param113
Param114
Param115
Param116
Param117
Param118
Param119
Param120
Param121
Param122
Param123
Param124
Param125
Param126
Param127
Param128
Param129
Param130
Param131
Param132
Param133
Param134
Param135
Param136
Param137

0.480163946
0.409942325
0.481941959
0.473704427
0.591872686
0.4128234
0.447462092
0.543216898
0.518152292
0.442812845
0.481998628
0.38643222
0.412324464
0.545433646
0.431446777
0.510077122
0.527618338
0.432440684
0.529209227
0.520030091
0.511748021
0.472545164
0.482171256
0.471601782
0.479214574
0.478704963
0.488851413
0.428249738
0.495593656
0.474325776
0.458405405
0.488349503
0.380052516
0.484547525
0.477920957
0.41346988
0.523768057
0.562064287
0.402280299
0.55048711
0.456321292
0.49392707
0.312077426
0.478527328
0.509118711
0.455414665
0.506465443
0.450035994
0.432038192
0.426300574
0.506878333
0.467512946
0.423776524
0.341450253
0.49580255
0.46073727
0.430653524

0.690781511
0.622902641
0.698204097
0.671442541
0.742731633
0.638554207
0.66445246
0.716567634
0.730190918
0.643372998
0.671306488
0.696041415
0.665823794
0.726495098
0.639030446
0.720528092
0.725772837
0.633381137
0.687426522
0.705117929
0.660982546
0.652304956
0.684248442
0.676129916
0.756405517
0.667665792
0.662384
0.670140075
0.673135395
0.680218467
0.668788537
0.665716549
0.648495711
0.6996489
0.714833776
0.655318733
0.737547449
0.695554786
0.6399557
0.688121117
0.650976197
0.668517779
0.65413125
0.695138136
0.667086431
0.63995402
0.687848798
0.664512234
0.643139794
0.65736625
0.659748473
0.66035135
0.596454841
0.573314411
0.665527794
0.602222239
0.676309681

0.070645941
2.0426E-34
2.00429E-71
0.134619323
5.3736E-10
2.5115E-140
8.11553E-59
2.47965E-86
1.70749E-19
0.13988212
0.033648774
0.000512162
3.15106E-37
1.54132E-05
0.065061106
0.046044562
7.3242E-122
0.22943327
9.5171E-128
0.084165798
0.007254019
0.083058826
3.98437E-13
4.92012E-67
1.0978E-156
2.73305E-29
1.4455E-148
0.00877908
0.136859587
1.44204E-05
3.58949E-68
0.002559286
0.193655037
0.069573294
1.17386E-39
1.59535E-64
2.60017E-27
0.137161465
0.046688927
0.001559855
0.001664859
7.0391E-127
1.22824E-71
2.4413E-06
2.9922E-131
4.25072E-10
0.028865505
1.65727E-33
1.17465E-22
4.5744E-143
1.0314E-102
0.101335
1.79098E-05
0.034863865
5.18939E-96
0.038248308
6.07505E-05

1.217778049
0.86852982
1.191623021
0.975550991
1.37338448
0.84825946
1.028960604
1.130024769
1.111143453
0.889580643
1.037645188
0.815173795
1.071331609
1.038571658
1.018809323
1.100271797
1.161719426
0.717748256
1.057275095
1.14615119
0.978074468
0.907542907
1.012356648
1.023856707
1.239567295
0.877401082
0.974761534
1.030231454
1.029066566
0.983578169
1.077343225
0.898286206
0.916181112
1.032124028
1.208285241
0.910031085
1.258961984
1.041373771
0.953520104
1.028765239
0.936074123
0.926975284
1.1026273
1.060818506
1.009486384
0.974799771
1.08970651
1.151401501
0.91977602
0.947441885
1.01336882
0.991736275
0.88948339
0.847390343
1.008324904
0.858974156
0.922438536

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

38

-15.33354806
-17.19582817
-15.9363692
-16.06733348
-15.94994122
-18.25928507
-15.51450595
-14.37777826
-17.13004803
-17.15302619
-17.27936053
-16.86278164
-15.18080062
-16.56972169
-16.6257101
-16.72080169
-17.31712108
-17.07992185
-14.91561041
-15.99636069
-16.23724788
-16.72219127
-16.06214902
-16.30031854
-17.97940006
-16.3998602
-16.05636364
-16.30126909
-16.78414914
-15.52230564
-14.59640668
-16.51434112
-15.74279882
-16.82979566
-16.84702075
-16.23644573
-17.2152661
-15.7971521
-16.59246847
-16.24333209
-16.2915659
-16.30579414
-14.93811115
-16.75423318
-15.98083514
-15.06915371
-15.02551215
-14.28481769
-16.58017503
-16.54172335
-15.88224293
-16.24315711
-16.7564987
-16.75500184
-16.38472795
-16.55812243
-16.34520158

2.17285236
1.637108978
2.096965157
1.891780842
2.283366683
1.667041137
1.93474141
2.038284716
2.034808843
1.785548577
1.964704928
1.859811678
1.744197925
2.048058423
1.746427261
2.014965912
2.074251217
1.628839106
1.996192922
2.081375425
1.943581085
1.822985975
1.927882727
1.873653666
2.091787776
1.789230716
1.735400632
1.837745796
1.941582427
1.897966381
1.887556536
1.817628173
1.744930487
1.965728886
2.013030121
1.739463731
2.101258458
2.04742516
1.743446855
1.940582636
1.747555255
1.85649161
1.776533759
1.893225659
1.993192972
1.747052071
2.002044498
1.965124745
1.687693371
1.738289539
2.04718052
1.869516256
1.631640235
1.595787324
1.928582496
1.662413831
1.784866505

-33446001.74
-53184882.44
-123134.0778
-53498164.99
-32960.85479
-549535678.8
-40562359.64
-6160640.936
-246394687.1
-63175948.07
-167196011.6
-22970951.69
-11357113.45
-2792807.71
-72287281.7
-109918015.3
-297355116.5
-97452486.57
-5012882.904
-583343.4057
-19385280.51
-82499499.36
-19363071.27
-92318912.53
-421005958.1
-73080615.3
-37259365.65
-2333660.617
-149047495.2
-14315741.09
-4969120.749
-41088318.77
-45390206.03
-658009.7843
-84899316.5
-72469670.67
-21754424.97
-51567490.19
-126265203.8
-2354162.655
-37231091.77
-21289241.85
-7056625.198
-103271227.8
-13828318.36
-3398467.348
-14811492.21
-2460529.064
-122050995.1
-13949529.48
-30303227.03
-3280831.965
-66736349.04
-67571724.22
-4692267.94
-62592560.29
-21578203.71

Param138
Param139
Param140
Param141
Param142
Param143
Param144
Param145
Param146
Param147
Param148
Param149
Param150
Param151
Param152
Param153
Param154
Param155
Param156
Param157
Param158
Param159
Param160
Param161
Param162
Param163
Param164
Param165
Param166
Param167
Param168
Param169
Param170
Param171
Param172
Param173
Param174
Param175
Param176
Param177
Param178
Param179
Param180
Param181
Param182
Param183
Param184
Param185
Param186
Param187
Param188
Param189
Param190
Param191
Param192
Param193
Param194

0.435657555
0.455074377
0.45281663
0.378495114
0.447387269
0.426661518
0.384674438
0.500588798
0.358710272
0.494364139
0.631481863
0.501078675
0.410486321
0.486951482
0.571248394
0.472888642
0.418264904
0.5138802
0.48664032
0.455371653
0.439929674
0.50375386
0.498546478
0.531771953
0.478163355
0.558347412
0.496209053
0.420835204
0.434415761
0.455858181
0.448295954
0.530056134
0.56082447
0.388552709
0.517407437
0.484544421
0.477510708
0.485296421
0.439830268
0.553943838
0.389135399
0.453415086
0.491447651
0.432725805
0.514992908
0.523963112
0.536649363
0.576507524
0.578708099
0.507567203
0.539646991
0.399500985
0.409091097
0.50499529
0.450863096
0.462162897
0.453906769

0.682269842
0.693889622
0.646138757
0.617399772
0.687161501
0.676556291
0.661725015
0.679634351
0.645107522
0.671216319
0.791404778
0.711724267
0.697585438
0.660037889
0.778192881
0.665806058
0.65084327
0.668316304
0.722942591
0.673343837
0.646719807
0.696085908
0.671089893
0.704698048
0.688216808
0.705856617
0.665805848
0.664738271
0.577843016
0.675465942
0.705681996
0.68909372
0.706137947
0.644886017
0.658398713
0.685719805
0.684092996
0.673288455
0.668558056
0.76789716
0.670122504
0.675414506
0.723925304
0.65911522
0.698573006
0.700998784
0.702023618
0.768362088
0.719885697
0.67940094
0.697763438
0.565911974
0.662466071
0.750598269
0.711332871
0.637474021
0.663617564

5.33129E-36
9.43875E-12
6.92407E-19
1.15175E-15
0.086115606
2.5842E-11
2.03556E-26
9.756E-145
0.012064447
1.67791E-50
3.36317E-22
1.6134E-137
0.056364081
0.023984996
0.034503037
2.4022E-17
1.34943E-20
4.68237E-05
4.38385E-19
0.003638052
0.098895568
1.3077E-100
0.093464589
9.183E-147
1.0466E-102
1.4628E-83
4.86261E-47
4.2738E-99
2.71937E-13
2.4757E-117
6.35659E-06
1.12634E-10
1.50923E-36
3.2457E-15
1.61954E-07
0.000188684
1.4225E-63
7.2595E-131
7.90008E-06
6.53609E-05
5.36825E-58
3.92807E-42
0.045613121
0.113280026
2.7104E-06
0.001029816
0.130440612
0.019474329
8.03444E-10
0.087102972
2.8731E-108
2.82695E-48
4.40506E-62
0.036360916
2.31092E-07
0.017762794
0.102288932

1.012873354
1.145489486
0.930676989
1.088598066
1.043992242
1.075422211
0.986085922
0.994496269
1.00623807
1.025755548
1.358972972
1.055887947
1.223689922
0.906593935
1.380496541
0.937301572
0.901590509
1.041957991
1.19413893
1.203382433
0.851912158
1.214660566
0.937527006
1.065043004
1.111770991
1.062575793
0.951889662
0.902469979
0.816495319
1.127086663
1.21803863
1.004894061
0.996421217
1.03791955
0.940273811
1.000772641
1.063618499
1.031246908
0.996043045
1.382119025
1.093456134
1.073821637
1.272426595
1.108294958
1.073819452
1.225824466
0.974529296
1.294575067
1.1232834
0.956210383
1.077640422
0.808532038
1.019093611
1.258417157
1.260626695
1.006758983
1.0356017

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

39

-16.29637672
-16.52584255
-16.43155065
-15.08495167
-16.90440762
-16.72466383
-15.99837868
-16.68587165
-15.21736793
-16.77381372
-16.29234908
-16.76792914
-17.44922262
-16.91721825
-16.7666011
-16.69565671
-16.6024362
-15.80502821
-16.829265
-14.3972104
-16.6776811
-14.34966259
-16.79549082
-15.21141386
-15.47578587
-15.51893596
-16.1267609
-15.98686732
-16.97023776
-15.16755348
-17.19399603
-15.84860969
-16.32881944
-17.14913345
-16.02664505
-15.87667241
-14.4237614
-16.26653083
-16.37584498
-17.48978013
-16.85444058
-16.91441823
-17.59219347
-15.35864241
-16.16334326
-17.04289631
-15.74682311
-16.43096772
-15.54469491
-15.52070219
-15.43769469
-17.02948644
-15.34063578
-17.4137788
-17.16785801
-14.99931688
-17.02501788

1.776865315
2.028835167
1.747594452
1.771729773
1.870145334
1.941361555
1.824837298
1.943852886
1.707809189
1.946757549
2.254592688
2.015831216
1.953756402
1.797439403
2.208208463
1.84720311
1.656645922
2.021583937
2.02796027
2.026307297
1.675453043
1.981008625
1.834285952
1.9777839
1.961984637
2.041672056
1.912983206
1.752067824
1.583842881
1.892607583
1.963446496
1.988458507
2.023530549
1.809835511
1.897348354
1.893493468
1.817039269
1.890972144
1.815787222
2.203115922
1.875674311
1.997264707
2.056987773
1.892388266
1.924587854
2.042902409
1.917660895
2.161249045
2.092033566
1.851176574
2.04308637
1.510842449
1.823210724
2.163426446
2.052387159
1.768628625
1.965001154

-89240119.77
-80279293.18
-37301625.8
-9389839.66
-77669524.06
-61433697.62
-28176968.57
-3608526.225
-7159110.928
-58768188.89
-39653870.37
-169781683.4
-199314409
-127556857.7
-100684423
-23935758.5
-58780432.12
-10118772.95
-80330153.73
-2191844.981
-7033646.641
-1662402.575
-66624442.68
-11287552.06
-32820570.64
-6151081.838
-31078110.75
-7954744.576
-84485754.6
-4839327.044
-50683553.25
-38862190.97
-91169633.44
-102350408.9
-26316834.51
-14981035
-4455467.249
-84660181.01
-11973489.55
-9471998.621
-101307451.6
-111423470.5
-23294460.8
-30226993.8
-80709863.55
0
-19353155.83
-45187132.37
-7529776.557
-38790548.71
-30499930.97
-20655454.84
-6792600.346
-171166864.1
-46834882.19
-4882379.884
-91421676.1

0.432989334
0.501071453
0.443551421
0.51338921
0.344166183

0.601664591
0.741243669
0.668489218
0.70829459
0.56726236

1.2746E-84
4.33174E-17
0.025887381
2.23398E-05
1.25968E-53

0.880470204
1.26482824
1.198196233
1.112430712
0.838693263

0
0
0
0
0

-16.82016179
-16.8364361
-17.0523978
-16.75223146
-16.72968483

1.617613541
2.093464539
2.05053601
1.941757276
1.577302382

-93069412.82
-92706247.73
0
-26452983
-83929726.38

Param200 0.438625635

0.653893156

4.70033E-14

0.935487786

-16.19816833

1.716223051

-35694427.68

Param195
Param196
Param197
Param198
Param199

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

40

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 data
function 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
dependence
Fx_input(Xsize/2+2) = 0 + i*0; %set = 0 else interpolation will cause
problem
%bispectrum in the third cumulant function
B_input = zeros(Xsize/2, Xsize/4); %to form the triangle
for 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
end
end
%normalized bispectral entropy P1
x1 = B_input(find(B_input)); %return value that is non-zer0
x2 = conj(x1); % conjugate of x1
B_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


dependence
Fx_input(Xsize/2+2) = 0 + i*0; %set = 0 else interpolation will cause
problem
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

41

B_input = zeros(Xsize/2, Xsize/4); %to form the triangle


for k1 = 1:Xsize/2;
for k2 = 1:min(k1,Xsize/2-k1)
B_input(k1,k2) = Fx_input(k1) * Fx_input(k2) *
conj(Fx_input(k1+k2-1));
end
end
%normalized bispectral entropy P2
x1 = B_input(find(B_input)); %return value that is non-zer0
x2 = conj(x1); % conjugate of x1
B_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, filterfactor
function 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 space
prevalue = 0;
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

42

% how many are closer than r in the post space


postvalue = 0;
% will be used in distance calculation
dist = zeros(N,p);
% Loop over all the points
for 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

43

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 column
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

44

n = length(y); %determine the length of y to n


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
entropy
R=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 0
end
N
A
B
p
e

=
=
=
=
=

n*(n-1)/2;
match(1:M); %first element of match to M to A
[N;A(1:(M-1))];
A./B; %A right array divide of B
-log(p); %to calculate entropy value

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

45

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

Renyis 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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

46

KS_entropy = ks_entropy(data, datalength, filterfactor);


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 space
prevalue = 0;
% how many are closer than r in the post space
postvalue = 0;
% will be used in distance calculation
dist = zeros(N,p);
% Loop over all the points
for 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-value
entropy = 2^-k; % to calculate entropy

BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

47

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 EDIT
gui_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

48

% Choose default command line output for EEG


handles.output = hObject;
% Update handles structure
guidata(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 structure
varargout{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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

49

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);
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');
end
guidata(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);
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

50

guidata(hObject, handles);

% --- Executes on selection change in Screen.


function Screen_Callback(hObject, eventdata, handles)
% hObject
handle to Screen (see GCBO)
% 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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

51

% 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 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');
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

52

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

% --- 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)


BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

53

% hObject
% eventdata
% handles

handle to kal (see GCBO)


reserved - to be defined in a future version of MATLAB
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.
%
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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

54

%
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)
% 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
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

55

% --- 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)
% 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 EDIT
gui_Singleton = 1;
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

56

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)
% Choose default command line output for EEG_Output
handles.output = hObject;
% Update handles structure
guidata(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 structure
varargout{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)
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

57

% hObject
% eventdata
% handles
called

handle to EEG_data (see GCBO)


reserved - to be defined in a future version of MATLAB
empty - handles not created until after all CreateFcns

% 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

58

Appendix D - Classifier
Fuzzy Classifier Codes
clear all;
clc;
load normalisedtraining3woapp
load normalisedtesting3woapp
load class
%features
p1 = training(:,1);
p2 = training(:,2);
p3 = training(:,3);
p4 = training(:,4);
%p5 = training(:,5);
%p6 = training(:,6);
%p7 = training(:,7);
%p8 = training(:,8);
%classes
t1 = class(:,1);
t2 = class(:,2);
t3 = class(:,3);
p = [p1';p2';p3';p4'];
t = [t1';t2';t3'];
%features
test1 = 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 clustering
y=evalfis(ptest,fismat); %Perform fuzzy inference calculations
outres=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
end
end
yj
xlswrite('Fuzzywoapp.xls', yj, 'Fuzzy3', 'A1'); %to create excel file
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

59

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 data
clc
clear all
close all
%load data file
load training3woks
load testing3woks
% Work with 2-d data
nin = 4;
% No of inputs
class =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 models
options = foptions;
options(14) = 50;
% Initialise the model parameters from the data
%(No. of Mix = No. of outputs)
% mix1 = normal, mix2 = mild, mod,severe and prolif
mix1 = gmminit(mix1, data(label==1, :), options);
mix2 = gmminit(mix2, data(label==2, :), options);
mix3 = gmminit(mix3, data(label==3, :), options);

% mixture model 1
% mixture model 2
% mixture model 3

% Now train each model


options(1) = 1; % Print error values
options(5) = 1; % Prevent collapse of variances
options(14) = 1000; % Number of iterations
mix1 = 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 classification
test_probs = [gmmprob(mix1, test) gmmprob(mix2, test) gmmprob(mix3,
test)];
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

60

% Convert to 1 of N encoding
target = [ test_label==1 test_label==2

test_label==3];

%No. of outputs
fh1 = 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

61

%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%

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 options
if (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 data
if (options(5) == 1)
% Do the initialisation
perm = randperm(ndata);
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

62

perm = perm(1:ncentres);
% Assign first ncentres (permuted) data points as centres
centres = data(perm, :);
end
% Matrix to make unit vectors easy to construct
id = eye(ncentres);
% Main loop of algorithm
for 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

63

%
%
%
%
%
%
%

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.

Copyright (c) Ian T Nabney (1996-2001)

See also
GMM, GMMPOST, GMMACTIV

% Check that inputs are consistent


errstring = consist(mix, 'gmm', x);
if ~isempty(errstring)
error(errstring);
end
% Compute activations
a = gmmactiv(mix, x);
% Form dot product with priors
prob = 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 consistent


errstring = 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;
end
post = post./(s*ones(1, mix.ncentres));
BME499 ENG499 MTD499 ICT499 MTH499 CAPSTONE PROJECT REPORT

64

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 consistent
errstring = 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 centres
options(5) = 1;
[mix.centres, options, post] = kmeans(mix.centres, x, options);
% Set priors depending on number of points in each cluster
cluster_sizes = max(sum(post, 1), 1); % Make sure that no prior is zero
mix.priors = cluster_sizes/sum(cluster_sizes); % Normalise priors
switch mix.covar_type
case '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

65

% 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

66

%
%
%
%
%
%
%
%

OPTIONS(14) is the maximum number of iterations; default 100.

Copyright (c) Ian T Nabney (1996-2001)

The optional return value OPTIONS contains the final error value
(i.e. data log likelihood) in OPTIONS(8).
See also
GMM, GMMINIT

% Check that inputs are consistent


errstring = consist(mix, 'gmm', x);
if ~isempty(errstring)
error(errstring);
end
[ndata, xdim] = size(x);
% Sort out the options
if (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);
end
test = 0;
if options(3) > 0.0
test = 1; % Test log likelihood for termination
end
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 algorithm
for 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

67

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

68

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]);
end
end
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 consistent


errstring = 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

69

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)));
end
case '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

70

%
'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

71

mix.ppca_dim = ppca_dim;
end
% Initialise priors to be equal and summing to one
mix.priors = ones(1,mix.ncentres) ./ mix.ncentres;
% Initialise centres
mix.centres = randn(mix.ncentres, mix.nin);
% Initialise all the variances to unity
switch 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

72

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 n2
if any(any(n2<0))
n2(n2<0) = 0;
end
function 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 default


errstring = '';
% If type string is not empty
if ~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

73

errstring = ['Model type ''', s, ''' does not match expected type
''',...
type, ''''];
return
end
end
% If inputs are present, check that they have correct dimension
if 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
end
end
% If outputs are present, check that they have correct dimension
if 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
end
end
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

74

%
%
%

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));
end
end
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

75

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

76

You might also like