# Fog-Computing-Based Heartbeat Detection and Arrhythmia Classification Using Machine Learning
## 2 Preliminaries and Previous Work  
Electrocardiography monitoring is the dominant method of understanding variations in heart rate, heart rhythm, and other patterns of the heart's electrical impulses. ECG records the electrical activity of the heart, by detecting electrical impulses generated by the polarization and depolarization of cardiac tissue. The impulses are then translated into a waveform, which eventually enables physicians or cardiologists to evaluate irregular heart rhythm, thus diagnosing cardiac abnormalities. Arrhythmia literally means _without rhythm_, but this word is used to denote any abnormal rhythm. In terms of heart activity, the term _arrhythmia_ refers to any change from the normal sequence of electrical impulses. In this sense, arrhythmias refer to a collection of conditions that are characterized by heart rhythms that do not follow a normal pattern. The electrical impulses may happen too fast (tachycardia), too slowly (bradycardia), too early (premature contraction), or irregularly (flutter or fibrillation), causing the heart to beat too fast, too slowly, too early, or irregularly [26]. The ECG provides the most accurate means of identifying a cardiac arrhythmia. The arrhythmias can be classified into two major categories. The first category consists of arrhythmias formed by a single irregular heartbeat, herein called _morphological arrhythmia_. The other category consists of arrhythmias formed by a set of irregular heartbeats, herein called _rhythmic arrhythmias_[1]. An ECG recording is analyzed based on the three _waves_: \(P\), \(QRS\), and \(T\), which occur in a sequential way. Figure 1 provides a graphical representation of the \(PQRST\) complex. The \(P\) wave has small magnitude and represents the impulse of the two regions of the heart's atria that transfers the blood from the veins. It is characterized by depolarization of the atrial muscles. The \(QRS\) complex that has high magnitude and spikes because of the rise in the conduction velocity, measures the depolarization of the ventricles. Lastly, the repolarization and revitalization of the ventricles takes place during the \(T\) wave. The assessment of cardiac function is linked with the detection of significant fiducial points of a heartbeat: the \(P\) wave, the \(QRS\) complex, and the \(T\) wave. Moreover, the recognition of the onset and offset points of the \(P\) wave, the onset and offsets point of \(QRS\) complex, and the onset and offset point of the \(T\) wave of a \(PQRST\) complex is diagnostically relevant. Furthermore, the wave recognition points serve also as references for all amplitude measurements, for example, the distances between fiducial points of a heartbeat such as the \(P\) wave, the \(PQ/PR\) interval, the \(QRS\) width, the \(QT\) interval, the amplitude of \(P\), the amplitude of \(QRS\), \(ST\) level, and the amplitude of \(T\). The design of algorithms for the analysis of heart arrhythmias based on ECG recordings has been studied for many years [1]. All such algorithms rely on the analysis of the \(PQRST\) complex. The most prominent in terms of amplitude is the \(QRS\) wave and is therefore the easiest to detect. Hence, the heartbeat detection problem is equivalent to the \(QRS\) detection. The \(QRS\)-detection problem, on its standard formulation, takes as input an ECG sample and computes whether it resides in a \(QRS\) wave. It is necessary at this point to clarify that the \(QRS\) detection is complicated mainly because of the different kinds of noise present in the ECG signal and not only because of the physiological variability of the \(QRS\) complexes. The aforementioned noise sources include muscle noise, wave variations caused by slight translocation of electrodes, power-line interference, baseline wander, and \(T\) waves with high-frequency characteristics similar to \(QRS\) complexes. Therefore, \(QRS\) detection methods typically apply appropriate digital signal processing algorithms to raw signals to reduce noise and amplify the signal.