## 2 Materials and Methods
### Evaluation Setup  
We examined modified limb lead II (MLII) ECG signals necessary for long-term ECG recording to validate the proposed method. The MLII signals were obtained by placing the ground electrode at the left infraclavicular fossa, the negative electrode at the right infraclavicular fossa, and the positive electrode on the left lower abdomen or just beneath the last rib. We obtained the signal data from the Massachusetts Institute of Technology-Beth Israel Hospital Normal Sinus Rhythm (MIT-BIH NSR) database [12; 13], which is an Open Data Commons Public Domain database. This database included 18 long-term ECG recordings of subjects referred to the Arrhythmia Laboratory at Boston's Beth Israel Hospital. The subjects in the database had no significant arrhythmias and included five men aged 26 to 45 and 13 women aged 20 to 50. We also tested the proposed method with the Fantasia database [12; 13; 14]. This database comprised 20 young (21-34 years old) and 20 elderly (68-85 years old) rigorously screened healthy subjects, who underwent 120 min of continuous ECG recording digitized at 250 samples per second. All subjects remained in a resting state in a sinus rhythm while watching the movie Fantasia (Disney, 1940) to help maintaining wakefulness. We implemented the proposed method using C++ coding. We originally intended to feed the ECG data through an analog-to-digital converter into our long-term HRV monitoring system at 1000 samples per second; however, we developed a separate program for validation purposes. The input data of the validation program was formatted as a comma-separated value (CSV) format file generated from the MIT-BIH NSR and the Fantasia databases. To simulate the real implementation, we resampled the original signals from the datasets to 1000 samples per second using linear interpolation. The implementation was included in the real-time HRV analysis system, where the data were serialized. The client received the serial data, detected the R peak, sent the results to the server, and deleted the data. Hence, the client memory did not store a large amount of ECG data, and the computation time was not affected by the data serialization. We consider that the two evaluateddatasets, which were resampled, can be considered as representative because a 1000-Hz sampling rate is commonly used for practical ECG recording. We then tested the proposed method on the first 10,000 s of each record in the MIT-BIH NSR database and compared the results with the existing results from other studies. We excluded records #Io07, #Io05, #Io08, #Io210, and #Izy09 from the Fantasia database because they contained many arrhythmatic beats with the negative peak deflection, which are considered as outliers for HRV analysis. The proposed method was tested on a 2.4 GHz Intel Core i7-4700 HQ CPU, 12 GB-memory Windows 8.1 notebook. Windows 8.1 is a multi-tasking operating system that processes multiple tasks in addition to our program. Hence, we measured the elapsed time of our proposed method five times per record and calculated the mean value for each record. We also set our program to have the highest priority in the task manager of the operating system. We focused on obtaining uninterrupted beats from the acquired ECG data. Thus, we included all signal series for the test with no exceptions. This allowed us to judge the detector's ability to recognize unreadable signals caused by very-high amplitude noise, very-low signal amplitude, loss of signal, or a combination of these factors [15]. Such error signals were noted as \"isolated QRS-like artefacts\" instead of R peaks (Figure 6). We manually marked the R peaks and analyzed both signal types.