ECG Signal Diagnoses Using Intelligent Systems Based on FPGA

This paper presents the use of Particle Swarm Optimization (PSO), neural networks with the most promising supervised learning algorithms for automatic detection of cardiac arrhythmias based on analysis of the Electrocardiogram (ECG). Artificial Neural Network (ANN) has three layers with ten nodes in the input layer, five nodes in the hidden layer and five nodes in the output layer, which is trained using the PSO algorithm. The trained network was able to classify the ECG signal in normal signal, atrial flutter, ventricular tachycardia, sever conducting tissue and wandering a trial pacemaker. Field Programmable Gate Arrays (FPGAs) have been used to implement ANN trained by the supervised learning algorithms and PSO, because of their speed benefits, as well as the re-programmability of the FPGAs which can support the reconfiguration necessary to program a neural network. A VHDL Design of ANN platform is proposed to evolve the architecture ANN circuits using FPGA-Spartan 6 Evaluation board. The VHDL design platform creates ANN design files using WebPACKTM ISE 13.3 program. All the algorithms used to train the ANN showed high effectiveness with 100% classification.


Introduction
he Electrocardiogram (ECG) is the record of variation of bioelectric potential with respect to time as the human heart beats.Electrocardiography is an important tool in diagnosing the condition of the heart.It provides valuable information about the functional aspects of the heart and cardiovascular system.Early detection of heart diseases/abnormalities can Prolong life and enhance the quality of living through appropriate treatment.For effective diagnostics, the study of ECG pattern and heart rate variability signal may have to be carried out over several hours.Thus, the volume of the data being enormous, the study is tedious and time consuming.Naturally, the possibility of the analyst missing (or misreading) vital information is high.Therefore, computerbased analysis and classification of diseases can be very helpful in diagnostics [1].
Electrocardiography deals with the electrical activity of the heart.Monitored by placing sensors at the limb extremities of the subject, electrocardiogram (ECG) is a record of the origin and the propagation of the electrical potential through cardiac muscles.It is considered a representative signal of cardiac physiology, useful in diagnosing cardiac disorders.Automatic arrhythmia detection and classification of arrhythmias are important in clinical cardiology, especially when performed in real time.This is achieved through the analysis of ECG beat and its extracted features.Several algorithms have been developed in the literature for detection and classification of ECG beats.Most of them use either time or frequency domain representation of the ECG T PDF created with pdfFactory Pro trial version www.pdffactory.comwaveforms, on the basis of which many specific features are defined, allowing the recognition between the beats belonging to different classes [2].
The most difficult problem faced by today's automatic ECG analysis is the large variation in the morphologies of ECG waveforms, not only of different patients or patient groups but also within the same patients.The ECG waveforms may differ for the same patient to such an extent that they are dissimilar to each other and at the same time they are similar for different types of beats.This is main reason that the beat classifier, performing well on the training data, generalizes poorly when presented with different patients [1].
One of the common approaches in ECG beat classification is Artificial Neural Networks (ANNs) that have shown accurate performance in different classification tasks.Combining neural classifiers is one approach to improve the classification performance, particularly for complex problems.Which complex computational task is solved by dividing it into a number of computationally simple tasks and then combining the solutions of those tasks [2].

RELATED WORKS
The continuous research has led to many new developments in Artificial Intelligent (AI) techniques such as ANN, Genetic Algorithm (GA) and PSO.Besides, new advanced algorithms were developed to hybrid these algorithms with each other.GA and PSO are both population based algorithms that have proven to be successful in solving a variety of difficult problems.However, both models have strengths and weaknesses.The two algorithms are used to improve the ANN performance in generalization ability, convergence velocity and learning ability [3].
Hardware implementation of an artificial neuron has a number of well-known advantages over software implementation.The hardware implementation of an artificial neuron can take the form of either a special purpose programmable controller or digital/analog circuit (device).Each type of implementations has its advantages, drawbacks, and fields of application [4].Therefore, literature survey for many previously published researches is presented as follows: S. Barro, et al., 1998 [5] described the application of a new artificial neural network model aimed at the morphological classification of heartbeats detected on ECG signal.Rui Mendes, et al., 2002 [6] carried out about Particle Swarm for Feed forward Neural Networks and make comparison between PSO and other approaches to show the benefits of PSO for training FNN when applied to classification and regression tasks.This work was only meant as a starting point in this field and the results were encouraging, considering that PSO is a general purpose method, where no specific knowledge is used.Indeed, when compared to a similar method, its performance is promising.H. GholamHosseini, D. Luo and K.J. Reynolds 2005 [7] proposed a two stage feed forward neural network for ECG signal classification.A number of neural network architectures are designed and compared for their ability to classify six different heart conditions.A. De Gaetano, et al., 2009 [8] proposed a supervised neural network-based algorithm is designed to reliably distinguish in electrocardiographic (ECG) records between normal and ischemic beats of the same patient.ShanxiaoYang and Guangying Yang 2010 [9] introduced the Electrocardiogram (ECG) pattern recognition method based on wavelet Transform and standard BP neural network classifier.B. Abibullaev 2011 [10] presented a new method for detection and classification of QRS complexes in ECG signals using continuous wavelets and neural networks.

PROPOSAL
The proposed work aims to automatically classify the ECG signal in five categories, which are: normal signal, atrial flutter, and ventricular tachycardia, sever conducting tissue and wandering a trial pacemaker.To perform the classification, it will be implemented a neural network, which the input will be an ECG signals and the training will be conducted by the PSO.

DATABASE
The entrance of the network will be composed from the ECG signal MIT-BH Arrhythmia Database.The data are from patients who were monitored and evaluated by the BIH Arrhythmia Laboratory, which led to 48 hours and a half of ECG recordings.From these records, 25 were collected, 60% of inpatients and 40% of outpatients at Boston's Beth Hospital [t].The 25 records remaining were selected to represent the important arrhythmias.The recording was digitized at 200 elements per channel with 12 bit resolution over 10 mv range.
From the database when the ventricular bits were derived we got the R peak values in the table form.This R peak was taken as the beginning, from the samples of the same patient 199 elements were taken to the next R peak value to make a 200 elements input.Thus each input becomes a matrix of 200x1 and ready to be used in MATLAB (2011).The same process was repeated to make all the inputs of all the kinds of inputs that are normal signal, a trial flutter, ventricular tachycardia, etc.

RESAMPLING
The 200 elements ECG signals were considered to be very large for training & implementing on FPGA beside training such large data will give greater chances for misclassifying so resampling was proposed to minimize the training dataset , It has been found no qualitative differences when resampling is introduced , This simple preprocessing will produce 10 elements to be trained by neural network.

OVER FITTING
One of the problems that occur during neural network training is called over fitting.The error on the training set is driven to a very small value, but when new data is presented to the network the error gets larger.The network has memorized the training dataset, but it has not learned to generalize to new situations.Figure 1 shows the response of a neural network that has been trained to approximate a noisy sine function.The underlying sine function is shown by the dotted line, the noisy measurements are given by the + symbols, and the neural network response is given by the solid line.Clearly this network has over fitted the data and will not generalize well.

Figure (1) Neural network response that suffer from over fitting.
One of the methods for improving network generalization is to use a network that is just large enough to provide an adequate fit.The larger network, the more complex the functions the network can create.If small enough network has been used, it will not have enough power to over fit the data.
It is difficult to know beforehand how large a network should be for a specific application.There are two other methods for improving generalization: regularization and early stopping.
In early stopping technique the available data is divided into three subsets.The first subset is the training set, which is used for computing the gradient and updating the network weights and biases.The second subset is the validation set.The error on the validation set is monitored during the training process.The validation error normally decreases during the initial phase of training, as does the training set error.However, when the network begins to over fit the data, the error on the validation set typically begins to rise.When the validation error increases for a specified number of iterations, the training is stopped, and the weights and biases at the minimum of the validation error are returned.The test set error is not used during training, but it is used to compare different models.It is also useful to plot the test set error during the training process.If the error in the test set reaches a minimum at a significantly different iteration number than the validation set error, this might indicate a poor division of the data set.

PARTICLE SWARM OPTIMIZATION
The PSO (Particle Swarm Optimization) is an optimization technique proposed by James Kennedy and Russell Eberhartin 1995.The method was created by simulating a simplified social model similar to model school of fish or flock of birds looking for food.In PSO, the population is called swarm.A swarm is a quantity of particles moving in an n-dimensional space within a subspace of search.There is a concept of neighborhood for each particle, which is the set of all neighboring particles.Each particle in a given iteration has a speed and position in space.The particle also has a small memory that stores the best position so far achieved (best place), and the best position ever reached by the known particle (best global), or, the best of all particles belonging to the neighborhood.To verify if a solution is better than another if it utilizes a fitness function that determines how good the solution to the problem is.As each particle's position represents a candidate solution to the problem, the fitness of a particle is a function of the position of the particle.Each particle modifies its velocity taking into account the best position itself and the best position of the group and over time the group has reached the highest position in the space.The flow chart showed in Figure (2) represents an outline of the PSO algorithm [11][12][13][14].
A new velocity for each particle is updated by equation ( ) ...( 1) ) ( 1Each particle changes its position according to equation ( 2)  3) for all datasets.The total number of neurons for each hidden layer is five.The Number of input layer and output layer usually come from number of attribute and class attribute.However there is no appropriate standard rule or theory to determine the optimal number of hidden nodes.After downloading the bit stream into the kit the ECG signal is generated from the inside of this kit for the sake of testing the accuracy of recognition, the ECG test signal was generated by a top level VHDL program as shown in figure (5) that stimulate the ECG signal from within the kit and then deliver it to the proposed ANN that is also generated within the same kit as mentioned earlier this technique gives very accurate sight to this whole ECG signal recognition process.

Figure (5) 12 bit ECG signal generation inside the top level.
A test bench waveform containing input stimulus which can be used to verify the functionality of the design module is created.The test bench waveform is a graphical view of a test bench.Figure (6) shows the simulation results of the heart condition input.

Figure ( 3 )
Figure (3) The architecture of the ANN proposed in this work.
slices and opens or closes once the implementation is complete, switches in the routing resources to wire the gates together.4. The state of the routing switches and CLBs (or macro cells) is extracted to create a bit stream where the ones and zeroes are used to open or close switches.5.The bit stream is downloaded into FPGA chip.The electronic switches in the device open or close in response to the binary bits in the bit stream.Upon completion of the downloading, the FPGA will act as an ECG signal diagnose device as shown in figure (4).

Figure ( 4 )
Figure (4) Hardware components for downloading the bit stream into the FPGA.

Figure ( 6 )
Figure (6) Simulation results of the first heart condition diagnosed.

Table ( 1) The MSE & epochs for the training algorithms. Training algorithm Resilient back propagation Scaled conjugate gradient Gradient descent Bayesian regulation
synthesizer program to transform the VHDL into a net list is used.The net list is just a description of the various logic gates in the design and how they are interconnected.2. The functioning of the circuit is tested by loading the net list into a simulator, applying the input ECG signal (known as test vectors), and observing the simulated outputs.3. Implementation tools are used to map the logic gates and interconnections into the FPGA.The FPGA consists of an array of slices which can be further decomposed into configurable Logic Blocks (CLBs) that perform logic operations using a set of Look Up-Tables (LUTs).The CLBs are interconnected with various local and global routing resources.The fitter places gates from the net list in various CLBs in the