# Fog-Computing-Based Heartbeat Detection and Arrhythmia Classification Using Machine Learning
## 4 Implementation Details
### ECG Data  
The database considered in this study is a collection of annotated ECG recordings obtained by the Arrhythmia Laboratory of Boston's Beth Israel Hospital, known as the _MIT-BIH Arrhythmia Database_[51]. We now provide some details on how this dataset was created as reported in Reference [51]. First, the creators of the dataset selected 48 half-hour excerpts of two channels (24 h of signal in total) of ECG recordings from 47 subjects: out of which 22 are women aged 23-89 years and the remaining 25 are men aged 32-89 years. The electrodes were placed on the chest as is standard practice for ambulatory ECG recording. The recordings were digitized at 360 samples per second per channel with 11-bit resolution over a 10 mV range. The samples include two leads--the modified limb lead-II and one of the modified leads \(V_{1}\), \(V_{2}\), \(V_{4}\), or \(V_{5}\) with a resolution of 51 V/bit. On the basis of  
Figure 3: Different phases of the processing of the ECG signal. these recordings, a total of 25 traces were selected such that they include arrhythmic cardiac activity. Out of these, four also include paced beats, meaning that they were produced by a pacemaker. Finally, following a random selection process, an additional 23 samples were chosen. Each of these samples corresponds to a 2D vector of 650 K entries. The vector is composed of two channels, therefore it is two dimensional. After the creation of the recordings, a simple slope-sensitive \(QRS\) detector was used to automatically annotate the recordings. Then, two cardiologists were consulted independently to correct the resulting annotations, as well as provide corrections and additions regarding the classification of the cardia rhythm and the signal quality. The two new sets of annotations were compared to identify discrepancies between the opinions of the two physiologists and generate a unifying version. In Reference [51], it is reported that from 48 recordings, within six of them, for a total of 33 heartbeats, the two physiologists could reach an agreement on the classification. Moreover, it is reported that a total of seven episodes of loss of signal or noise that was so severe in both channels simultaneously, that \(QRS\) complexes could not be detected; these episodes were all quite short and have a total duration of about 10 s. In all of the remaining data, every \(QRS\) complex was annotated, numbering about 109,000 in total. According to the Association for the Advancement of Medical Instrumentation (AAMI) standard [25] for testing and reporting performance results of cardiac rhythm and segment measurement algorithms, the evaluation of an arrhythmia detector algorithm should be made on the classification performance on five major categories of heartbeats:  
* **N** includes beats originating in the sinus node (normal and bundle branch block beat types);
* **S** includes supraventricular ectopic beats (SVEBs);
* **V** includes ventricular ectopic beats (VEBs);
* **F** includes beats that result from fusing normal and VEBs;
* **Q** includes any heartbeat not in the N, S, V, or F categories, essentially the undefined heartbeats as well as beats resulting from the use of a pacemaker. Note that the last category includes beats that are a result of a pacemaker operating under the skin of the patient. These beats are regulated and it is not meaningful to use them for arrhythmia classification. As stated above, the MIT-BIH database includes four patients who are using a pacemaker. For this reason, these four patients were excluded from our study. In this way, the resulting Q category includes only 33 beats. Because of the lack of data, we excluded all these beats from our study. Please also note that this is a common practice in other state-of-the-art studies; see, for example, the work of [PERSON] et al. [52]. Therefore, we are left with four beat categories. Each of these four categories contains more fine-grained types of arrhythmic beats. Table 1 lists the complete definitions for each of the four categories.