## Materials and Methods
### Simple and Efficient Noise Detection Method Using Vertical Histogram  
The measured ECG signal is corrupted by various noises, which makes exact R detection difficult. The noise of the ECG signal is classified as muscle artifact (MA), baseline wander (BW), and electrode motion artifact (EMA), as shown in Figure 4. The ECG noises are extracted from the MIT-BIH Noise Stress Test DB (NSTDB) [33]. MAs occur when skeletal muscles contract, the patient moves or because of shivering due to the inappropriate temperature of the environment [34]. The main problem with these interferences is the spectral overlap between the ECG and the muscle noise. BW is a type of low-frequency noise which adds to the ECG signal, resulting in a varying baseline. This noise is caused by changes in the impedance between the electrode and the patient's skin. These changes might be caused by movement, breathing or by perspiration, leading to a change of distance between the source of the signal, the heart, and the electrodes [35]. EMA is generally considered the most troublesome problem, as it can mimic the appearance of ectopic beats and cannot be removed easily by simple filters, as with noise of other types [33]. ECG signals measured in a measurement room or with a stable posture are relatively clean, but ECG signals measured under motion may contain various noises. The proposed method is basically robust to BW because it uses the product of two kinds of derivative filters. In addition, the processing of the sliding window unit can minimize the influence of false detection by strong noise. The proposed noise detection method is designed to cope with BW  
Figure 3: Connection of R peaks detected per successive sliding window for real-time processing. and EMA. The vertical histogram for the region of interest (ROI) around the signal point to detect MA and EMA is shown in Figure 5.  
The magnified signal \(x(n)\) for applying the vertical histogram is created by multiplying the original signal \(I(n)\) by 100 and rounding it to nearest integer because the original signal in the MIT-BIH DB has a small range of 10 mV. The histogram sum \(h(n)\) for the magnified signal point \(x(n)\) with the total number of bins \(2\times W_{v}+1\) and histogram \(m_{i}\) is obtained as follows:  
\[h(n)\ =\ \sum_{i\ =\ x(n)-W_{v}}^{x(n)+W_{v}}m_{i}, \tag{1}\]  
where \(W_{v}\ =\ 15\). The total number of bins in the histogram for \(x(n)\) is always the same, but the range of bin values depends on the signal height of \(x(n)\). Also, the histogram \(m_{i}\) represents the number of bin \(i\) (signal height) for the ECG signal in the ROI, and the histogram value becomes large in the local region where the frequency is high, such as MA. Figure 4: An example of muscle artifact (MA), baseline wander (BW), and electrode motion artifact (EMA) effects. Figure 5: Vertical histogram for the ROI around the magnified signal point. The characteristics of the vertical histogram in the noise region (A, B, and C) and ECG signal region (D, E, and F) is shown in Figure 6. In the figure, the noisy signal was created by adding MA to the Record 234 signal of MIT-BIH DB. The noise region generally has a higher vertical histogram value per bin, whereas a typical ECG signal region has a different vertical histogram distribution depending on the location of the signal point being processed. For the ECG signal, the vertical histogram at the peak point of the important P, R, and T waves (D in the figure; i.e., the peak of the P wave) is concentrated in the low bin section. The rising or falling interval of the important wave (E in the figure) has a flat histogram distribution over the entire bin range, while the flat interval (F in the figure) has a histogram distribution densified in a specific bin. As a result, we can see that the sum of the vertical histograms in the noise region is larger than the normal ECG signal region. Thus, a vertical histogram sum at each signal point is used to distinguish the noise point from the normal signal point.