IMPLEMENTATION OF AN ARTIFICIAL INTELLIGENCE-BASED ECG ACQUISITION SYSTEM FOR THE DETECTION OF CARDIAC ABNORMALITIES

. The electrocardiogram (ECG) is a common test that measures the electrical activity of the heart. On the ECG, several cardiac abnormalities can be seen, including arrhythmias, which are one of the major causes of cardiac mortality worldwide. The objective for the research community is accurate and automated cardiovascular analysis, especially given the maturity of artificial intelligence technology and its contribution to the health area. The goal of this effort is to create an acquisition system and use artificial intelligence to classify ECG readings. This system is designed in two parts: the first is the signal acquisition using the ECG Module AD8232; the obtained signal is a single derivation that has been amplified and filtered. The second section is the classification for heart illness identification; the suggested model is a deep convolutional neural network with 12 layers that was able to categorize five types of heartbeats from the MIT-BIH arrhythmia database. The results were encouraging, and the embedded system was built.


Introduction
Cardiovascular illnesses are the leading cause of death worldwide, and their prevalence rises with age.The electrocardiogram (ECG) is one of the earliest exams used for diagnosis; it is a recording of the heart's electrical activity acquired by attaching tiny electrodes to the body.It is normally made up of three important waves: the P wave, the QRS complex, and the T wave [7].ECG interpretation is a critical skill for clinicians to acquire; reading errors are common and can lead to misdiagnosis.Using artificial intelligence for decision-making is the goal of numerous studies in the literature [6,11,16].The goal of this work is to create a system for acquiring and classifying ECG signals that is based on an ECG module for acquisition and deep learning to be used afterwards to simplify and facilitate cardiologists' tasks.This technique enables for the capture and categorization of data in five categories: normal, left bundle branch block [19,20], right bundle branch block [5], atrial prematurity [9,14], and ventricular premature contraction [14].
Many publications, such as [14,15,18], and [10], deal with the acquisition and categorization of cardiac anomalies utilizing ECG signals.They created and deployed a smart health care monitoring equipment that visualizes the ECG signal and counts the number of heartbeats at a reasonable cost.The AD8232 module is used to display the ECG signal in real time.Many additional studies employed ECG signal classifications based on artificial intelligence algorithms to detect cardiac problems early and treat them appropriately [2,4,17].The feature extraction stage is critical in classification, and several techniques for identifying and categorizing ECG heartbeats have been widely employed, including wavelet transform, filter banks, hidden Markov models, support vector machines, and others.The convolutional neural network (CNN) is a neural network used for anticipating and deep learning because of its amazing performance in the fields of image and voice and has a high potential to find significant patterns in data.Convolutional neural networks are similar to artificial neural networks in that they have a convolution layer, a subsampling layer, and a fully connected layer that is the same as the multilayer perceptron (MLP).In [8], they introduced an automated feature extraction method that eliminates the need for human feature extraction and preprocessing.It focuses on identifying five major macroclasses: Non-ectopic, Supraventricular ectopic (S), Ventricular ectopic (V), Fu-sion (F), and Unknown (Q).Their suggested method for ECG beat categorization consists of three major phases.Detection of ECG beats, sample extraction, and categorization Their method had a 92.7% accuracy.Another heartbeat classification technique based on artificial networks and fuzzy relations with an accuracy rating of 80-85% was utilized in [3].An efficient system based on the MLP-NN classifier is shown using two alternative feature extraction approaches.Our task entails acquiring the ECG signal and classifying heart disorders, more specifically arrhythmias.As a result, we must acquire the signal while filtering and amplifying it in order to classify it into one of five categories based on a 12-layer convolutional neural network: Normal, Left Bundle Branch Block, Right Bundle Branch Block, Atrial Prematurity, and Premature Ventricular Contraction.The accuracy of this approach was 99.56%.However, before reaching this stage, the signal must first go through a series of data preparation and segmentation stages.Figure 1 depicts an overview of the system.In this work, we will present the materials utilized for acquisition and categorization, as well as the study's methodology, experimental findings, and conclusion.

Methodology
The initial stage in this process is the acquisition of ECG signals, which was accomplished with the help of AD8232, a signal conditioning block that may be utilized for ECG and other biopotentiometric measurements.It is intended to extract, amplify, and filter tiny bio potential signals in the presence of distracting factors such as mobility or distant electrode location.This enables the output signal to be easily acquired by an ultra-low power analog-to-digital converter (ADC) or an integrated microcontroller.Disposable electrodes were employed in this experiment because they are faster, easier, and more sanitary than reusable electrodes or wet electrodes.They are placed on various bodily regions to get an ECG signal [1].The disposable electrodes included with the AD8232 kit are put on the test subject's bare skin on his right and left chest and right and left thigh while he is laying on his back.Figure 2 depicts the recovered signal utilizing our acquisition technology.

Fig. 2. Extracted signal using our acquisition system
The categorization is the second phase in this project.To handle the signal, which is a one-dimensional time series with uniform interval sampling, we propose a one-dimensional CNN with 12 layers.The hardware configuration utilized in the implementation is an HP 2000 laptop with an Intel(R) (TM) i3-3110M CPU at 2.40GHz, 4 GB of RAM, and the Windows 10 "64-bit" operating system.The programming language is Python, and the environment is Kaggle with Keras and skit learn libraries.The ECG signals were taken from PhysioBank's MIT-BIH arrhythmia database [13].It is made up of 47 ECG recordings taken by the BIH Arrhythmia Laboratory over the course of 48 half hours.Each ECG recording is made up of two leads.Each signal is captured at 360 Hz, and these recordings have been evaluated and confirmed by at least two cardiologists, and they have been split as follows for our model.To improve classification accuracy, the signal must be denoised (figure 3).In this example, the wavelet transform approach is used to preprocess the ECG data.The non-stationary data is split into discrete frequency band scale signals.The filter employs an adaptive threshold filtering method, and the Sym4 wavelet function from the Symlet family of wavelet functions is chosen since it is the most similar to the ECG signal.The convolutional neural network can automatically extract features from data; we just applied simple filtering to the signal to increase the generalization of the network and eliminate signal distortion.
For this model, we have normal, left bundle branch block, right bundle branch block, premature atrial beats, and premature ventricular beats, all of which are illnesses noted for each pulse in the MIT-BIH data.The process starts with R-peak detection (R-wave position detection is triggered when the adaptive threshold is exceeded), the dataset is then divided into 360 samples and centered around the detected R-peaks, and each segment is then normalized using Z-score normalization to address the issue of amplitude scaling and eliminate the offset effect before being fed to the CNN network for training and testing (figure 4).
The database is unbalanced, which might influence convolutional neural network feature learning and lower recognition accuracy.To decrease the data unbalance utilized for training, we oversample the under-represented classes, randomly duplicate the under-represented classes, and reject the over-represented classes after pre-processing and segmentation (table 2 and 3).
In this study, we present a 12-layer one-dimensional CNN to process a one-dimensional time series with uniform interval sampling.To preserve the general characteristics of the input data, we use the average pooling layer rather than the maximum pooling layer.With a total of eight alternate convolution and pooling layers, the proposed CNN network features one more alternate convolution and pooling layer than the current CNN network.They are followed by two completely connected layers and a dropout layer, as indicated in the flowchart (figure 5).
The first layer is convolved with a core size of 13 and a filter count of 16.Applying a medium-pooling layer of size 3 reduces Layer 2's output to 179*16.Then, the Layer 2 feature map is convolved with a core size of 15, and Layer 3 has 32 filters.Once more, a mean-pooling layer of size 3 is utilized, bringing the number of neurons down from 176*16 to 89*32.(layer 4).There are 64 filters in layer 5, with an average pooling size of 17.The output is decreased to 44*64 after layer 5, which is followed by an average-pooling layer with a size of 3. (layer 6).The output of layer 6 is convolved with layer 7, which has a core size of 19 and 128 filters.The next layer is a pooling layer with a size of 3. (layer 8).In Layer 9, the exclusion layer is set at 50%.Linking layer 10 to layer 11 are 35 neurons.Layer 11 connects five neurons to the SoftMax layer, which gives each problem type a probability.A linear recovery unit serves as the activation function prior to each mean clustering layer (ReLU).In order to prevent overfitting, the L2 factor of 5 is applied to all completely linked layers.

Results
Using stratified sampling, we dispersed 80% of the data in the training set and 20% in the test set.Kaggle's GPU was used to train the model.To develop our network, we utilized the TensorFlow framework, with the maximum number of epochs set to 40.Training took around 30 minutes, and the network parameters were saved in a local file to be used later.
As indicated in figures 6 and 7, the test had an accuracy of 99.56% and a loss of 4%.The confusion matrix (figure 8) was then used to assess the algorithm's sensitivity (Sen), which is the percentage of properly predicted positive people.Its specificity (Spe), which is the percentage of accurately predicted negative persons, and its positive prediction rate (Ppr), are calculated as follows:  Sen=TP/(TP+FN)  Spe=TN/(TN+FP)  Ppr=TP/(TP+FP) where (TP) is the number of true positives, (FP) is the number of false positives, (TN) is the number of true negatives, and (FN) is the number of false negatives (FN).
The sensitivity, specificity, and positive prediction rate of the model in the classification range between 98 and 100%, indicating that it is a model that clinicians may use to help them with their diagnosis.

Discussions
This CNN network outperformed other models in terms of overall classification accuracy (99.56%) for the classification of micro classes in the arrhythmia dataset, as well as 40-fold cross-validation to demonstrate the robustness of the algorithm compared to is [12], where they used a random forest classifier to recognize five main classes (N, Q, S, V, F), achieving 94.61% accuracy.Other studies employed a deep genetic collection of classifiers to categorize the extended duration ECG signal, achieving on 17 arrhythmia classifications on the same database.Following the classification that yielded substantial results, a model was developed in order to test it with our recovered signal on actual individuals.This model was built on a Raspberry Pi board, and then tests were run to ensure that our system worked properly.Because the signal was retrieved from a normal patient, the first findings revealed a decent categorization.Figure 9 shows how it might be used on different people with anomalies to view the results on a screen.

Conclusion
In this work, we were able to acquire the ECG signal using a card that integrates the entire acquisition chain, including amplification and filtering, and we were able to select a powerful algorithm for the data, thanks to the network's advantages in terms of automatic signal processing without the need for signal extraction, which is very useful and beneficial when compared to other algorithms.In this context, we recommend that the quality of the obtained signal be improved.Aside from the proposed solution, which is the Raspberry Pi, the cloud can be a good option to visualize the signal, process it through the model, and present the findings.

Fig. 1 .
Fig. 1.Overview of the used system The sensor's output signal is received by the analog pins on the Arduino Uno board.Ar-duino UNO is an open-source microcontroller based on the Microchip ATmega328.There are six analog pins on this board.The Arduino programming software is used to program this microcontroller.This board operates on both 5 V and 12 V.It has a maximum clock rate of 16 MHz and is a 10 bit microcontroller with 32 KB of flash program memory.C is the programming language used.The disposable electrodes included with the AD8232 kit are put on the test subject's bare skin on his right and left chest and right and left thigh while he is laying on his back.Figure2depicts the recovered signal utilizing our acquisition technology.