Professional Documents
Culture Documents
5.2 Method: 5.2.1 WSN-EEG Test and Model Design
5.2 Method: 5.2.1 WSN-EEG Test and Model Design
epilepsy. The system will implement the prediction Algorithm, FFNN and mathematical
model to diagnose epilepsy and enhance activities of daily living of epilepsy patients.
5.2 Method
The WSN-EEG consist from three parts,
• WSN- EEG Test and Model Design
• The brain waves illustration
• The FFNN based machine-learning approaches and Deep Learning
A Specific Sensor Ad hoc architecture testbed was designed to study the service time with respect to
latency and jitter factors for data transmission between the WSN and the EEG receiver. The Testbed
consists of a sensor ‘Sensor Side’ connected to the receiver ‘analyzer side’ by control radio environment
(RF cable), as illustrated in figure 25. This Testbed used specific traffic generator software to generate
UDP data (brain waves) from the sensors to the WSN-EEG receiver, and specific analyser to monitor
network traffic and performance time stamp between the nodes.
The study conducted the tests with a source and a receiver. The test-bed used IEEE802.11n as
transmission techniques and security protocol for data privacy. The measurements for data transmission
divided into two subclasses tests with enabled and with disabled security. In the both tests, the sensor
on the patient scalp is the source of the traffic, and the analyzer is the traffic receive in figure 23.
Wi-Fi Receiver
Sensor
RF Cable
Analyser
In the Test-bed, a set of UDP in different packet sizes sent from the sensor to the analyser to stressed
the network with maximize CPU capacity, evaluate the service time, study the effect of the signal delay
and the total service time to diagnose epilepsy and seizure attach prediction to alert the patients on
time[65]. All tests were repeated four times in each test session and therefore evaluated four times in
total to record the accurate average service time in respect to the data size and security scenarios.
In this Section, results about the system illustration of four brain waves A,B,T,and D
presented. These were obtained using the microcontroller software imitations on proteus 8
professional 8.4 Model. The C compiler for Microchip PIC MCUs used for coding, using the
PIC16F877A chip and 4MHz crystal. The PIC16F877A has two CCP module so we can use
one of them to calculate the frequency of input signal (brain wave). The Brain waves were
a tolerance point is described in order to expose the behaviour of each brain signal to a highly
changing value. To model a rapid change of frequency, i.e. of the subject’s boundary’s and
numbers , the frequency period is suddenly modified or interrupted. In this case CPP module
uses Timer1 for reference timing so appropriately set Tmier1. This is done through T1CON
register and we set prescaler of the Timer1 to 1:4(T1CON=0x21) .Here the last bit of T1CON
means TMR1ON). On the other hands CCP1 is set to interrupt at ever rising edge of input
Timer_1 was increased with the frequency of a quarter of system clock so its frequency is
0.25MHz. If the input frequency is 1Hz, the counter should count 250000 for one cycle and
counter of CCP will overflow. So in this system uses Timer1’s interrupt and at every
interrupt of Timer1 an other counting variable is increased(tk in code). In this code to avoid
double interrupt tk is divided by 2. For every tk is the same of 65536 CCP counter.
Table 1 Model and results of research-imitations on Proteus 8 Professional 8.4 Model Frequency
values to define normal and abnormal Brain waves
A Wave 8.5 Normal A Wave 12.5 Normal
When it goes from 1.02 to 1.99 Hz, the time is changed from 1.254390 to 1.625765 sec (look to part
of ANIMATING. It is animating time)
Fig. 11. Results of time, when begun changing frequency from 1.02 Hz
Fig. 13. Results of time, when begun changing frequency from 1.43 Hz
0,5
0,3
0,2
0,1
0
0,97 2 3,12 19,7
Differences of frequencies, Hz
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int Htime; //integer for storing high time
int Ltime; //integer for storing low time
float Ttime; // integer for storing total time of a cycle
float frequency;
const normal = 9;
const attach = 10; //storing frequency
void setup()
{
pinMode(normal,OUTPUT);
pinMode(attach, OUTPUT);
pinMode(8,INPUT);
lcd.begin(16, 2);
}
void loop()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Chastota signal");
Htime=pulseIn(8,HIGH); //read high time
Ltime=pulseIn(8,LOW); //read low time
Ttime = Htime+Ltime;
frequency = 10000/Ttime; //getting frequency with T time is in Micro seconds
lcd.setCursor(0,1);
lcd.print(frequency);
lcd.print(" Hz");
delay(500);
}
5.2.3 Feed Forward Neural Networks (FFNN) System Model and Problem
Formulation
The research proposed FFNN based machine-learning approach to overcome the problem
of non-linearity of the seizure attack. As we can observe in figure 24, the brain signal passing
through proposed tolerance point (pre seizure attack). Using neural network trained model
combining the different distribution in one desirable distribution considering the non-linearity
of the Seizure attack. , provided with a simple specification of the problem in coming section.
Figure 2 Example of an EEG A signal detailing normal behaviour (Gray Colour Normal Brain waves,
Yellow colour is the tolerance point /pre- attack, light blue is the brain activity during a seizure [66]
FFNN applied to the diagnosis of nonlinear signal using WSN-EEG algorithm approach, tolerance
point for signal boundaries for abnormal behaviour signs of possible seizures as identified in section
4.4.4. A faulty dictionary was first created containing responses observed at all inputs and outputs of
the brain wave behaviour for epilepsy patients. The FFNN machine-learning approach considered as
WSN-EEG approximation algorithm to capture mapping enclosed within the fault dictionary, in
addition, as an algorithm tool for searching the fault dictionary in the diagnostic phase.
In the FFNN model, the brain waves time domain, frequency domain measurements taken as
data for WSN-EEG device data-sheets-values. The abnormal signal behaviour and duration
were set as output set of data per fault. Changes in electrical activity in the brain and seizure
symptoms can be correlated to provide information about future seizures, their duration and
severity. However, this correlation between EEG signals and symptoms composes a complex
non-linear problem, which can be solve using neural networks, provided with a simple
specification of the problem. Moreover, Feed-Forward Neural Networks (FFNN for short)
Electrical activity in the brain can be measured non-invasively via EEG, using electrodes
attached to the scalp that measure voltage fluctuations within neurons in the brain, producing
a time-dependent signal
𝑆𝑆: 𝑅𝑅 → 𝑅𝑅 (1)
That can be sampled in time by the EEG into a finite collection of values 𝑆𝑆̃ (a set),
of the form
form of 𝑆𝑆 (i.e. spiking) that define three states of EEG waves as showcased in Figure
24. A normal state (light blue background), a pre-seizure state (pre-state for short,
yellow background), and a seizure state (light red background). Thus, given a signal 𝑆𝑆
we can partition collection 𝑇𝑇 in three (possibly empty) subsets 𝑇𝑇𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 , 𝑇𝑇𝑝𝑝𝑝𝑝𝑝𝑝 , 𝑇𝑇𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 such
that
hallucinations, muscle contractions, etc.) begin to appear on the patient, whose severity:
none (𝑛𝑛𝑛𝑛), mild (𝑚𝑚𝑚𝑚), moderate (𝑚𝑚𝑚𝑚), or (𝑠𝑠𝑠𝑠𝑠𝑠)severe define additional criteria for
EEG wave samples. Thus, the samples on a signal 𝑆𝑆 can be written as:
(𝑡𝑡𝑡𝑡)
𝑆𝑆 = �𝑆𝑆(𝑡𝑡𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 )|𝑡𝑡𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 ∈ 𝑇𝑇𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 , 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 ∈ {𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛, 𝑝𝑝𝑝𝑝𝑝𝑝, 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠} ∧ 𝑡𝑡𝑡𝑡 ∈
To create an FFNN-based strategy for seizure prediction, we will take the variables and
distinguish between normal and abnormal brain activity and propose a strategy to feed
The Research used the FFNN paradigm to forecast seizures, using the severity of symptom
signs as defined in in section 2. We can define abnormal brain activity in an EEG as a subset
That is, as the values of 𝑆𝑆 associated with the appearance of symptoms. Under these
definitions we can define normal brain activity as the complement of 𝑆𝑆𝑎𝑎𝑎𝑎
Given a signal, we can define the duration of seizure symptoms using the set diameter of
(𝑡𝑡𝑡𝑡)
𝑇𝑇 as
∆𝑇𝑇 (𝑡𝑡𝑡𝑡) = 𝑚𝑚𝑚𝑚𝑚𝑚�|𝑡𝑡1 − 𝑡𝑡2 |: 𝑡𝑡1 , 𝑡𝑡2 ∈ 𝑇𝑇 (𝑡𝑡𝑡𝑡) �, 𝑡𝑡𝑡𝑡 ∈ {𝑚𝑚𝑚𝑚, 𝑚𝑚𝑚𝑚, 𝑠𝑠𝑠𝑠𝑠𝑠} (9)
In addition, given a non-empty time-frame 𝑇𝑇� ⊂ 𝑇𝑇 we can define the variation of 𝑆𝑆 in 𝑇𝑇� as
∆𝑆𝑆 �
∆𝑆𝑆(𝑇𝑇)
∆𝑇𝑇�
= �
≥ 𝑆𝑆𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (11)
∆𝑇𝑇
For some tolerance value 𝑆𝑆𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 > 0. Provided with a baseline signal 𝑆𝑆̂ of brain activity
(deduced from expected brain activity), we can define the deviation between a given signal 𝑆𝑆
and the baseline 𝑆𝑆̂ as
Isolating the timeframes in which seizures occur, can be done with the provided tolerance
values 𝑆𝑆 (𝑚𝑚𝑚𝑚) , 𝑆𝑆 (𝑚𝑚𝑚𝑚) , 𝑆𝑆 (𝑠𝑠𝑠𝑠𝑠𝑠) > 0 that determine abnormal brain activity:
(𝑡𝑡𝑡𝑡)
𝑇𝑇𝑎𝑎𝑎𝑎 = �𝑡𝑡 ∈ 𝑇𝑇 |𝐷𝐷(𝑡𝑡)| > 𝑆𝑆 (𝑡𝑡𝑡𝑡) �, 𝑡𝑡𝑡𝑡 ∈ {𝑚𝑚𝑚𝑚, 𝑚𝑚𝑚𝑚, 𝑠𝑠𝑠𝑠𝑠𝑠} (14)
And the values of 𝑆𝑆 of abnormal brain activity as:
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
𝑆𝑆𝑎𝑎𝑎𝑎 = �𝑆𝑆(𝑡𝑡): 𝑡𝑡 ∈ 𝑇𝑇𝑎𝑎𝑎𝑎 � , 𝑡𝑡𝑡𝑡 ∈ {𝑚𝑚𝑚𝑚, 𝑚𝑚𝑚𝑚, 𝑠𝑠𝑠𝑠𝑠𝑠} (15)
Provided with a baseline signal 𝑆𝑆̂ for normal brain activity, we wish to apply the FFNN
paradigm to the problem of determining the type of future seizures a patient will suffer by
So that the resulting signal will be of the form 𝑆𝑆𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 = 𝐹𝐹(𝑋𝑋1 , 𝑋𝑋2 , 𝑋𝑋3 ). Classically, we would
like to construct 𝐹𝐹 as a linear combination of the input variables at each time step.
When using the Feed-Forward paradigm, the structure of the network must change, to avoid
creating cycles of neurons between layers (see Figure 25). To guarantee the structure of an
FFNN provided with the input, we can separate the network in a series of hidden layers 𝑂𝑂𝑗𝑗 , 𝑗𝑗 =
1, … , 𝑃𝑃 so that the input of each layer depends on a linear combination of the inputs of the
previous one.
In layer 𝑂𝑂𝑗𝑗 , if 𝑓𝑓𝑗𝑗𝑘𝑘 denotes the input function of neuron 𝑛𝑛𝑘𝑘 , 𝑓𝑓𝑗𝑗𝑘𝑘 is of the following form
In our case, the first layer of the neural network (the input layer) is defined by functions
𝐹𝐹𝑖𝑖 , 𝑖𝑖 = 1,2,3 of the form:
(𝑚𝑚𝑚𝑚) (𝑚𝑚𝑚𝑚) (𝑠𝑠𝑠𝑠𝑠𝑠)
𝐹𝐹𝑖𝑖 (𝑋𝑋𝑖𝑖 ) = � 𝑤𝑤𝑖𝑖 𝑋𝑋𝑖𝑖 (𝑡𝑡) � 𝑤𝑤𝑖𝑖 𝑋𝑋𝑖𝑖 (𝑡𝑡) + � 𝑤𝑤𝑖𝑖 𝑋𝑋𝑖𝑖 (𝑡𝑡)
(𝑚𝑚𝑚𝑚) (𝑚𝑚𝑚𝑚) (𝑠𝑠𝑠𝑠𝑠𝑠)
𝑡𝑡∈𝑇𝑇𝑎𝑎𝑎𝑎 𝑡𝑡∈𝑇𝑇𝑎𝑎𝑎𝑎 𝑡𝑡∈𝑇𝑇𝑎𝑎𝑎𝑎
X1 X2 X3 X Input Layer
W3.1
W1.1 W1.i W2.1 W2.i
W3.i
W1.2 W2.2 W3.2
Oj Hidden Layer,J
O1 ∫ ∫ ∫
Y Output Layer
∫ ∫
Y=
While if the network has 𝑁𝑁 + 1 layers (with layer 0 being the input layer), the output 𝑆𝑆𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛
𝑘𝑘 (𝑚𝑚𝑚𝑚)
𝑘𝑘 𝑘𝑘 (𝑚𝑚𝑚𝑚) (𝑠𝑠𝑠𝑠𝑠𝑠)
𝑆𝑆𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 (𝑡𝑡) = � 𝑤𝑤𝑁𝑁−1 𝑓𝑓(𝑚𝑚𝑚𝑚) (𝑡𝑡) + 𝑤𝑤𝑁𝑁−1 𝑓𝑓(𝑚𝑚𝑚𝑚) (𝑡𝑡) + 𝑤𝑤𝑁𝑁−1 𝑓𝑓(𝑠𝑠𝑠𝑠𝑠𝑠) (𝑡𝑡)
𝑘𝑘
Where the summation is taken over the number of neurons in the (𝑁𝑁 − 1)-th
(𝑡𝑡𝑡𝑡)
𝑓𝑓(𝑡𝑡𝑡𝑡) (𝑡𝑡) = 0 ⟺ 𝑡𝑡 ∉ 𝑇𝑇𝑎𝑎𝑎𝑎 , 𝑡𝑡𝑡𝑡 ∈ {𝑚𝑚𝑚𝑚, 𝑚𝑚𝑚𝑚, 𝑠𝑠𝑠𝑠𝑠𝑠} (17)
The predicting signal 𝑆𝑆𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 is constructed provided with an accurate baseline signal 𝑆𝑆̂ and
could provide patients with a more detailed prognosis on their condition, whether they are prone
to seizures and the type of seizures they will suffer. However, extrapolating baseline signals,
as well as the tolerances proposed in section 3 of this thesis, depends on the medical records of
a patient that must be weighted by additional factors (e.g. emotion, sleep patterns).
The range of values used to separate normal from abnormal behavior depends on two factors:
(1) distinguished values of 𝑆𝑆(𝑡𝑡), and (2) the oscillation frequency as presented in Table 1. Given
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
a frequency range for a specific type �𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 , 𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 �, the lower and upper boundaries (onset)
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
𝑓𝑓𝑚𝑚𝑚𝑚𝑚𝑚 = 𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 + 𝜀𝜀 (𝑡𝑡𝑡𝑡) (18)
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
𝑓𝑓𝑚𝑚𝑚𝑚𝑚𝑚 = 𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 − 𝜀𝜀 (𝑡𝑡𝑡𝑡) (19)
Thus, seizure symptoms are observable in the 4,5 Hz - 49,5 Hz, and a seizure attack is
considered to occur when the frequency of oscillation escalates to the abnormal range, and the
Table 2 Frequency values to define normal (𝒏𝒏𝒏𝒏) and abnormal (𝒎𝒎𝒎𝒎, 𝒎𝒎𝒎𝒎, 𝒔𝒔𝒔𝒔𝒔𝒔) behavior.
6. Results
The results presents the WSN- EEG test and model design simulation output, and a mathematical
prediction model based on simulation WSN-EEG simulations combined results brain waves illustration
output and the FFNN based machine-learning approach.
The WSN-EEG deployed IEEE802.11n transmission-techniques to estimate, and evaluate the quality
of service (QoS) parameters. In addition, data packet delay, the total serves time and the security protocol
impact on sensor networks. The results showed the EEG sensor networks performance depends on
design and implementation for security protocols, which adds a significant impact related to the data
packet delays, and the packet size transmitted over the ad hoc sensor network (figure 26, 27) [65].
228
211
188
135
111
82 94
Uplink
Uplink
32 64 128 256 512 1024 1472
UDP payload (Bytes)
284
221 241
202
124
92 103 Uplink
Uplink
32 64 128 256 512 1024 1472
UDP payload (Bytes)
Figure 5 Total service time for data transmission
from sensor to the receiver side - security Enabled
Uplink
32 92
64 103
128 124
256 202
512 221
1024 241
1472 284
6.2 Mathematical prediction Model
In the present work, a mathematical model has been developed to predict the abnormality in the brain
waves as diagnosis for epilepsy attack. The mathematical module corresponding to three different levels
on inputs, brain wave illustration, WSN-EEG simulation, and prediction algorithm implementing FFNN
based learning machine as data inputs for the model. These inputs were processed through three different
level of formulation process to predict the abnormal brain wave, and predict the seizure attack before it
occur in a reasonable time to caution the patents through the WSN-EEG alert system.
According to the developed model, the primary inputs were derivative from WSN-EEG simulation
inputs and outputs as flowing
Sp: Size of UDP packets (32-1472)
Np: Number of transmitted packets (n)
D: packet transmission delays in µs (Microsecond) (constant ≈ 0.5 µs based on test results in the
experiment section)
Nbs(f): Brain Waves length (A, B, D, T constant value) Hz/S
Si: security impact (constant value ≈15 µs to 70 µs)
Transmission Speed = 5 GHz
Qt: the number of pack on the queue
λ: wavelength
v: wave constant speed (5 Ghz Using IEEE802.11n)
x + y = z. (1)
µs=(Np*Sp)+(Si+(Qt*Nbs))+D (2)
Nbs= v/ λ (3)
When generated the illustrated brain wave the signal in (section 5.2.2), the main method is a harmonic
oscillation-the amplitude modulation of the carrying signal. This method gives qualitative results in the
analysis and synthesis of the frequency spectrum.
In general, the oscillating wave-signal is represented as follows:
Here: U(ω) is the amplitude of the bearing vibration, f is the frequency of the vibrating vibration, ω
is the ailane frequency, and φω is the initial phase of the bearing vibration.
The primary signal is a complex oscillation, its frequency spectrum F1 ... F2 (or Ω1 ... Ω2) is bounded
by a strip, i.e:
Ω2
y (t ) = ∑A
Ω i = Ω1
Ωi cos(Ωit + ϕΩi ),
(5)
Here is the amplitude of the primary signal of the i-th frequency component, i is the frequency
component of the primary signal, the initial phase i is the frequency component.
The amplitude of the harmonic wave (2) of the signal harmonic (4) after modulating the amplitude
form is represented as follows:
y (t ) = [ Aω + AΩ cos(Ωt + ϕΩ )] cos(ωt + ϕω ) =
A
= Aω 1 + Ω cos(ωt + ϕω ) cos(ωt + ϕω ).
Aω (6)
Coefficient of the depth of modulation of a quantity, when the given value is taken into account, the
amplitude modulated signal will have the following form:
y (t ) = Aω [1 + m cos(Ωt + ϕω )]cos(Ωt + ϕω ). (7)
With linear amplitude modulation and using sinusoidal mathematical formula presentation[70]
y (x, t) = A cos *(2π ((x/ λ)- ft)) = A cos (2π / λ (x-vt) (8)
where is y= wave value, x= wave position, t: time , A: wave amplitude
Implementing wavenumber and angular frequency to formula 3
Where k: wave number (2π wavelengths)
ω: angular frequency 2π times of the frequency
y(x, t) = U cos (ωt + φ) = U cos(2πft + φ)) (9)
Calculate the wavelength and frequency values
Based on defined tolerance point in the WSN- EEG Epilepsy Predictor Waves Algorithm and
implemented FFNN in ( section 5.4 ) and the defined wave bounders we calculate the
frequencies are calculated using a tolerance value 𝜀𝜀 (𝑡𝑡𝑡𝑡) as follows:
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
𝑓𝑓𝑚𝑚𝑚𝑚𝑚𝑚 = 𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 + 𝜀𝜀 (𝑡𝑡𝑡𝑡) (20)
OR
(𝑡𝑡𝑡𝑡) (𝑡𝑡𝑡𝑡)
𝑓𝑓𝑚𝑚𝑚𝑚𝑚𝑚 = 𝑎𝑎𝑚𝑚𝑚𝑚𝑚𝑚 − 𝜀𝜀 (𝑡𝑡𝑡𝑡) (21)
The obtain result of the proposed mathematical model approach can be implantation for
WSN-EEG as an epilepsy prediction and diagnose model or as new tool in the EEG system.