1 Introduction

In recent years, it has become clear that heart rate variability (HRV) analysis can detect signs of illnesses and seizures. For example, it can be used to screen patients with suspected sleep apnea, those who fall asleep at the wheel, and for the prediction of epileptic seizures [1,2,3]. To perform HRV analysis, it is necessary to measure the R–R interval (RRI) in the electrocardiogram (ECG) with sufficient accuracy and long-term stability. In general, heart rates are measured in hospitals, because the medical equipment required for the measurement is difficult to carry, requires specialized knowledge, and is expensive. Furthermore, this equipment cannot respond to out-of-hospital symptoms that occur at night or following sudden arrhythmias. A small, wireless Holter electrocardiograph is used for continuous heart-rate measurement outside the hospital. However, Holter ECGs are not equipped with a function to analyze HRV in real time, which is problematic and ineffective. Several wearable electronic technologies have been introduced for daily heart rate measurements, including smart clothing, smart wear, wearable health systems, and wearable ECGs [4, 5]. Compared with a conventional ECG, a garment-type wearable device is more suitable for long-term monitoring and daily use. However, motion artifact interference, mainly caused by the friction between the textile electrodes and the skin, considerably limit the performance of these devices [6]. Furthermore, garment-type devices have fixed electrode measurement positions, and some studies have shown that the position of the electrodes affects the results of the measurements [7]. In addition to garment-type ECGs, patch-type telemeters have also been studied [8]. Unfortunately, conventional patch-type devices are too large to conduct measurements for long periods of time in daily life, and it is difficult to wear them when going out. In addition, expertise and experience are required to affix these devices in the proper position.

Therefore, we developed a highly accurate, compact, and inexpensive patch-type RRI telemeter to measure heartbeats continuously in daily life. To allow this device to facilitate long-term stable RRI measurements, the R-wave should have a sufficiently high amplitude relative to baseline variations and other characteristic waves. However, the optimal electrode placement for inducing such an ECG varies considerably among individuals. Therefore, for people with little or no expertise, analyzing HRV by placing the electrodes at the appropriate positions can be difficult. Hence, a system that instructs the user on the proper use of the device is essential.

The remainder of this paper is organized as follows. We describe the system design and algorithm in Sects. 2 and 3, respectively. In Sect. 4, we explain the evaluation process, and validation results are presented in Sect. 5. Finally, the conclusions are stated in Sect. 6.

2 Patch-type RRI measurement device

2.1 Device overview

Figure 1 shows the patch-type device, and Fig. 2 shows its attachment.

Fig. 1
figure 1

Patch-type device

Fig. 2
figure 2

Attached patch-type device

The top part of the patch-type device has dimensions equal to 103 mm × 30 mm × 8 mm, and the thickness of the base is 0.15 mm. The sampling frequency is 1.2 kHz and the resolution of the analog/digital (A/D) converter was 24 bits. The base itself was sufficiently flexible to conform to the curves of the body, and has a mass equal to only 44.0 g. Furthermore, automatic gain adjustment and digital filters provided stable R-wave detection.

The device uses Bluetooth low energy (BLE), a low-power-consumption communication method, to transmit data to a smartphone for continuous measurements over a long period without constraints. When the battery was charged to a capacity of 100%, it could operate continuously for approximately 18 h.

This patch-type device does not calculate the HRV directly; however, it measures only the RRI. A smartphone application receives and calculates RRI data in real time to derive the HRV indices [3]. The HRV indices to be derived comprise a) four time-domain indices: the mean of RRI (meanNN), the standard deviation of the RRI (SDNN), the root-mean-square of the difference of adjacent RRIs (RMSSD), and the number of pairs that are 50 times greater than the difference of adjacent RRIs (NN50); and b) four frequency-domain indices: total power (TP), power in the low-frequency band of 0.04–0.15 Hz (LF), power in the high-frequency band of 0.15–0.4 Hz (HF), and the ratio of LF to HF (LF/HF). The HRV indices were obtained from statistical, or frequency analyses of the 3 min moving window. From this, an outlier in the RRIs would affect adversely the indices of the subsequent 3 min intervals. Therefore, the outlier RRIs ought to be replaced by the real-time compensation techniques, which were implemented as a function of a smartphone application. The RRIs observed during 180 s were stored in a buffer. The median absolute deviation RRIMAD of the ith RRI was calculated using the stoNred RRIs (RRIn | n: 1–i-1) as

$${RRI}_{MAD}=median\left|{RRI}_{i}- {median \,RRI}_{n}\right|,$$
(1)

where the function “median” estimates the median of the input variables. The range of normal RRIs is given by

$$median \,{RRI}_{n}-4\sigma < {RRI}_{i} <median \,{RRI}_{n}+4\sigma ,$$
(2)

where the standard deviation \(\sigma =1.4826\times {RRI}_{MAD}\). The RRI outliers, which are smaller than the lower limit, are removed from the RRI data used for the HRV analysis. However, when the observed RRI is greater than the upper limit, multiple heartbeats are assumed to have been missed. Therefore, the number of heartbeats N is estimated as

$$N= round\left(\frac{{RRI}_{i}}{median \,{RRI}_{n}}\right),$$
(3)

where the function “round” returns the decimal point rounded value of the input value (in ms), and the outlier is replaced with the Nth corrected RRIs, given by

$$\widehat{RRI}= \frac{{RRI}_{i}}{N}$$
(4)

2.2 Operation principle of patch-type device

A block diagram of the device is shown in Fig. 3.

Fig. 3
figure 3

Block diagram of patch-type device

A high-pass filter with a frequency of 0.16 Hz was applied to the input signal to remove the direct current and low-frequency-drift components in the ECG measurements. The signal was then amplified using an instrumentation amplifier with a common-mode feedback mechanism. The common-mode feedback mechanism allows in-phase waveforms to appear at each positive and negative input terminals of the differential amplifier circuit. This subsequently ensures that the noise introduced at each terminal is cancelled out. The instrumentation amplifier was INA122 manufactured by Texas Instruments. The amplification factor was defined as follows:

$${V}_{out}=\left({V}_{in}^{+}- {V}_{in}^{-}\right)G$$
(5)
$$G=5+\frac{200k}{{R}_{G}}$$
(6)

In this study, \({R}_{G}=10\) kΩ. Therefore, the amplification factor of this instrumentation amplifier was 25. A variable gain low-pass filter (LPF) was used to attenuate frequencies above 678.6 Hz. The working of the variable gain LPF is explained in detail in Sect. 2.2.2 and thereafter. A multiple feedback type BPF with a center frequency of 30 Hz and a quality factor of 1.0 was inserted between the output of the instrumentation amplifier and the input of the variable gain LPF.

The ECG waveform was amplified to obtain the R-wave amplitude of approximately 0.2 V (+ 500,000 in digital value) by an automatic gain-optimization mechanism in the variable gain LPF that is explained in Sect. 2.2.2. Herein, the desired amplitude of 0.2 V was set to help the signal to remain in the dynamic range despite the ECG-baseline fluctuations.

2.2.1 R-wave detection method

Figure 4 shows the processing in the microcomputer.

Fig. 4
figure 4

Microcomputer block diagram

An AD converter (ADS1246IPW, Texas Instruments) sampled the analog input with a sampling frequency of 1.2 kHz. The sampling resolution was 24 bits; thus, the input range was converted to a digital signal in the range of − 8,388,608 to + 8,388,607. Because the circuit treated only positive values, the range of 0 to + 8,388,607 corresponded to a voltage range of 0–3.3 V.

Furthermore, 50 Hz and 60 Hz notch filters were used to reduce the effect of hum noise generated by commercial power supplies. In addition, the attenuated BPF frequencies below 3 Hz and above 200 Hz. Subsequently, smoothing was added using the moving average of a 32-sample window for preprocessing, followed by first-order differentiation and R-wave detection.

The first derivative of the ECG was used for R-wave detection. It was further aided by steep changes in the waveform for R-wave detection. The threshold settings for the differential waveforms are shown in Fig. 5. Thresholds for the height, width, and area were set for the positive and negative pulses of the differential waveform. The height indicates the magnitude of displacement and serves as an indicator of steep changes; the width represents the time required for the change, and the area represents the size of the R-wave in the original waveform. A wave was considered as an R-wave when all the aforementioned thresholds were exceeded [9].

Fig. 5
figure 5

Thresholding in differential waveforms. The height and area of the negative pulse have negative values

2.2.2 Automatic gain-optimization mechanism

A patient’s age and physique can affect considerably the R-wave amplitude. In addition, factors such as electrode placement and the degree of adhesion between the electrodes and body surface can decrease the amplitude during measurements. Therefore, to account for these influencing factors, the patch-type device was equipped with an automatic gain-optimization mechanism. Herein, Fig. 6 illustrates the adjustment of Rc using the automatic gain-optimization mechanism on the patch-type device.

Fig. 6
figure 6

Rc adjustment method

The amplification factor of a variable-amplification LPF is defined as R2/Rc, where Rc is a variable resistance. The Rc value is within the range of 0–50 kΩ and is divided into 64 steps by a microcomputer. In the patch-type device, the amplification factor is adjusted by increasing or decreasing the value of R, such that the R-wave amplitude eventually reaches a digital value of approximately + 500,000.

The method for adjusting R is as follows:

  1. 1.

    First, set the value of R to 32Rstep, where Rstep = 50/64 kΩ. We note that 32Rstep is half of the maximum value of Rc

  2. 2.

    If the R-wave amplitude exceeds the digital value of + 500,000, reduce the amplification factor. This is performed by changing the value of Rc to the midpoint of its upper limit and the original value. The lower limit of Rc is changed to its original value

  3. 3.

    If the amplitude of the R-wave is less than the digital value of + 500,000, the amplification factor is increased by changing the value of Rc and its original value. The upper limit of Rc is changed to its original value

As shown in Fig. 6, this process was repeated six times to determine the final amplification ratio.

3 Optimal pasting position

3.1 Pasting position-selection algorithm

We developed a system that scores ECG waveforms and selects the optimal position for RRI measurements. The system indicates the pasting positions to the user on the corresponding smartphone application. Herein, the ECGs measured at each position are used for scoring. The pasting position with the highest score is determined to be optimal.

The procedure for the operation of the pasting-position selection system is as follows:

  • Apply the patch-type device onto the human body at the recommended position specified by the application. By maintaining the device in that state, press the OK button on the application to facilitate measurement and scoring

  • After the measurement is complete, perform the measurement and scoring at the next specified pasting position. Repeat this process for all specified pasting positions

  • After all the measurements at all the pasting positions are completed, attach the patch-type device onto the optimal pasting position specified by the application and repeat the measurement

  • If the score of the optimal paste position is above 11,500, the selection application is terminated; otherwise, the procedure is repeated from the beginning until this condition is satisfied

A flowchart of the pasting-position selection process is presented in Fig. 7. The system employs a software–hardware cooperative algorithm that is its most important feature, which contributes considerably to the usability of the system. The smartphone app (software) implements the functions for which visibility and user interaction are important. The embedded program (hardware) is responsible for accurate measurements and scoring.

Fig. 7
figure 7

Flowchart of pasting position-selection process

The system evaluates the ECG waveforms obtained from five different pasting positions and selects the position that provides the most stable ECG waveform. A flowchart of the waveform analysis is shown in Figs. 8 and 9.

Fig. 8
figure 8

Waveform analysis flowchart (Start terminal–B terminal)

Fig. 9
figure 9

Waveform analysis flowchart (B terminal–D terminal, end terminal)

The waveform analysis procedure is as follows:

  1. 1.

    A patch-type device is attached to pasting Position 1, and the ECG waveform is acquired for 2000 ms

  2. 2.

    Gain adjustment is performed using the acquired ECG waveforms for 2000 ms. A score of 500 is added if the gain is greater than 7 and less than 44

  3. 3.

    After gain adjustment, ECG waveforms for 3000 ms are acquired as the waveform (known as the “model waveform”) to be scored at this attachment position

  4. 4.

    Scores are added according to the number of R-waves detected in the model waveform. The ratios of the values of the numbers of detections and the score are 0:0, 1–2:500, 3–5:1000, 6:400, 7:300, 8:200, and ≥ 9:0, respectively (Terminal A in the flowchart)

  5. 5.

    If the average RRI obtained from the model waveform is between 300 and 1000 ms based on an estimation of the range of typical RRIs in the resting position, a score of 1000 is added

  6. 6.

    The amplitude (AD sampling value) of the first R-wave in the model waveform is divided by 100, and then added to the score (Terminal B in the flowchart)

  7. 7.

    If any AD sampling values of the model waveform are greater than twice the amplitude of the detected R-wave, a value that is five times the number of sampled data is subtracted from the score. This process intends to reduce the score for cases in which the waveform contains fluctuations or noise larger than the intensities of the R-waves

  8. 8.

    If any AD sampling values of the model waveform are smaller than twice the amplitude of the estimated S-wave in the model waveform, the number of samples is subtracted from the score (Terminal C in the flowchart)

  9. 9.

    The score thus obtained is saved at pasting Position 1

  10. 10.

    Steps 1–9 are performed for pasting Positions 2–5 in the same manner, and their respective scores are calculated (Terminal D in the flowchart)

  11. 11.

    The scores obtained for pasting Positions 1–5 are compared, and the pasting position with the highest score is considered the optimal pasting position (Terminal End in the flowchart)

Thus, the optimal placement position was automatically selected by the microcomputer by comparing the scores from the ECG waveforms acquired at each placement position, and the subject was notified through the application’s user interface. Subsequently, the RRI measurement was initiated.

3.2 Pasting position

The optimal pasting position-selection system uses a smartphone application to instruct the user about the various placements of the patch-type device. The system calculates the scores for five pasting positions, as shown in Fig. 10, and determines the optimal pasting position according to the score results.

Fig. 10
figure 10

Pasting positions

4 Methods

4.1 Experimental procedure

In this experiment, the patch-type device was applied, and measurements were conducted in four positions: supine, sitting, standing, and walking (3 km/h). Furthermore, the R-wave detection rate and RRI measurement accuracy were evaluated by employing simultaneously the proposed system and a reference ECG measurement system for measurements. In addition, a bedside monitor (BSM-3400, Nihon Kohden) was connected to the electrode terminals of the patch-type device to monitor the ECG waveform obtained at the optimal position. Experiments were conducted on 10 healthy male subjects and 10 healthy female subjects. The reference ECG measurement system comprised a high-sensitivity amplifier (MEG-6108, Nihon Kohden), digitizer (PowerLab16/35, ADInstruments), and PC with LabChart8Pro, connected in series.

First, a disposable electrode was affixed to induction II (midaxillary line to 5th intercostal space, left lateral clavicular fossa, and right lateral clavicular fossa) to obtain a reference ECG. Subsequently, the patch-type device was switched on and the application was started to select the pasting position. Subsequently, the process of optimal position selection described in the previous chapter was initiated, and measurements in the four body positions were started at the selected optimal position. After pasting the device on the optimal position, the electrode terminals of the patch-type device were connected to the bedside monitor. Measurements were then taken in four postures for 5 min each simultaneously using the reference ECG measurement system, a bedside monitor, and a patch-type device.

All experiments were conducted in compliance with the Declaration of Helsinki, using methods approved by the Ethics Committee of the Graduate School of Advanced Science and Technology, Kumamoto University (No. H26-1).

4.2 Evaluation indices

We used the R-wave detection rate, which has been proposed as a criterion for the stability of RRI measurements [3] as an evaluation index in this study. According to Salo et al., the R-wave detection rate for HRV analysis is 95% [10]. Furthermore, we used Bland–Altman analysis, which quantifies the error between the two methods. The limit of agreement (LoA), calculated using the Bland–Altman analysis, is given by the following equation:

$$LoA=Bias\pm 1.96SD$$
(7)

In the above equation, Bias is the mean of the differences between the two methods; SD is the standard deviation. Bland–Altman analysis requires a sampling rate of 250 Hz or higher in ECG measurements for HRV analyses. If the sampling rate is lower than that, the spectrum in the analysis will change [11]. Therefore, if LoA was within the range of \(\pm\) 4 ms, the RRI-measurement accuracy was sufficient for HRV analysis.

5 Results

Tables 1 and 2 present the results for the male and female subjects, respectively, for R-wave detection rate, LoA, and selected induction.

Table 1 R-wave detection rate [%]/limit of agreement (LoA) [ms]/selected induction in male subjects
Table 2 R-wave detection rate [%]/LoA [ms]/selected induction in female subjects

As presented in Table 1, the R-wave detection rate for male subjects was greater than 95% in 32 of the 40 measured epochs. In addition, LoA was within the Bias \(\pm\) 4 ms in 32 epochs. Positions 1–5 were selected with the probabilities of 42.5%, 12.5%, 10%, 25%, and 10%, respectively. Thus, the least likely selected pasting position had a selection probability of 10%. As presented in Table 2, the R-wave detection rate for the female subjects was greater than 95% in 36 of the 40 measurement epochs. In addition, LoA was within Bias \(\pm\) 4 ms in 35 epochs. Positions 1–5 were associated with the respective probabilities of 40%, 35%, 7.5%, 10%, and 5%. There were nine epochs for the same subject in the same position that did not meet the criteria for the R-wave detection rate and LoA.

In this experiment, detection failures occurred at 17 epochs, and the R-wave that caused detection failures at the M1 sitting position is shown in Fig. 11.

Fig. 11
figure 11

Missed detection of R-wave (M1 sitting)

All R-wave amplitudes were measured for 17 epochs and divided into two groups for each epoch, namely, the detected and omitted amplitudes. Three of the epochs were excluded because of mismatches between groups, and the remaining 14 epochs were compared between groups using the Wilcoxon rank-sum test. The test results showed that in 13 of the 14 epochs, the amplitude of the undetected R-wave was considerably smaller than that of the detectable R-wave.

6 Discussion

Currently, patch-type devices are already commercially available and, however, are intended for use by specialists with medical knowledge. In addition, its application is possible only based on the assumption that the device is positioned accurately to lead an appropriate ECG amplitude, and that the device appropriately reapplies itself when measurement becomes faulty. The patch-type device used in the current study was assumed to be applied by nonspecialists, and was used for routine measurements. People with no expertise experience difficulties in performing measurements at the optimal pasting position. To overcome this limitation and to improve the device usability for the public, we proposed the use of the patch-type device in combination with the optimal pasting position selection system.

The most frequently selected position for the male and female subjects was Position 1; however, the selection rate was approximately 40% for both genders. This result indicates that there are individual differences in the position and orientation of the heart. Fixing the position to only Position 1 may contribute to the improvement of usability by reducing the time required to select the position. However, the probability that the pasting Position 1 is the optimally selected position is at most 40%. This implies that other subjects may not be able to measure at the optimal position. Therefore, an optimal pasting position system that can accommodate individual differences could be useful.

A difference between the selection rate of the pasting positions by males and females could be observed. The selection rate of the pasting Position 2 was 12.5% for males, whereas it was 37.5% for females, which is the second highest rate. In addition, the selection rates for the pasting Positions 1, 3, and 5 were lower among females than males. Owing to the anatomical differences of the upper thorax in males and females, the presence of breasts in females may cause the patch-type device to tilt perpendicularly to their body axes. Therefore, the amplitudes of the R-waves detected by the patch-type device may become smaller at differing breast sizes. Therefore, females appear to be more prone to individual differences. As shown in Fig. 10, in the pasting Position 2, the device is placed at the center of the chest, and it may decrease the influences of the breast size compared with the other positions. However, pasting Positions 1, 3, and 5 are such that a part of the device is placed away from the center of the chest. This implies that the presence or absence of breasts may contribute to the selection of the optimal pasting position.

Previous studies have reported that the R-wave amplitude decreases in leads I and V2, and increases in lead II in standard 12 lead ECG during deep inspiration with reference to resting expiration in the supine position [12]. Among the five pasting Positions used in this study, pasting Position 5 was lead I; pasting Positions 1, 3, and 4 were lead II; and pasting Position 2 mimicked the National Aeronautics and Space Administration lead. In this study, there were 12 epochs in which the R-wave detection rate was lower than 95%, and eight of these epochs were caused by missed detections during waveform observations. Among these eight epochs, seven epochs had significant Wilcoxon rank-sum test results. The results measured in supine position show that five of the seven epochs were measured at pasting Positions 1 and 4. From these results, we can infer that the amplitude of the R-wave was smaller during restful expiration than during deep inspiration. Moreover, two out of seven epochs were measured at pasting Positions 2 and 5. This suggests that the amplitude of the R-wave decreased during deep expiration, giving rise to the missed detection.

In one of the eight epochs described in the previous paragraph, the Wilcoxon rank-sum test result was not significant, thus suggesting that the decrease in the R-wave amplitude associated with respiratory variability was not the cause of missed detection. Instead, the deformation of the R-wave due to the inclusion of electromyography contamination or motion artifacts is the cause of the undetectable R-wave.

Missed detection of the R-wave due to the decrease in R-wave amplitude associated with respiratory variation suggests that one of the parameters in R-wave detection (positive pulse height, positive pulse area, negative pulse height, or negative pulse area) may not have exceeded the threshold value. The threshold values adopted in this research were originally designed for lead II [3], and thus fine-tuning of the values should be performed in future studies to fit the various ECG obtained at the proposed pasting Positions.

The decrease in the R-wave amplitude with respiratory variation suggests the need to limit the number and depth of the subjects’ respiration for pure comparisons of the R-wave detection rate and LoA between the subjects, which will be necessary in future work. In addition, this study was conducted on young subjects in their early 20 s. In future work, we plan to conduct validation with different age groups, such as the elderly, and will seek to improve the usability of the device for a wider range of age groups.

7 Conclusion

In this study, we investigated an algorithm for selecting the optimum pasting Position. We conducted experiments to verify the stability and accuracy of RRI measurements using a patch-type device on ten male and ten female subjects. The patch-type device was applied to the positions suggested by the optimum pasting Position selection system, and RRI measurements were obtained for 5 min in each of the following four body positions: supine, sitting, standing, and walking (3 km/h). The results reveal that the R-wave detection rate and the LoA were sufficiently accurate for HRV analysis for 68 and 67 out of the total 80 epochs, respectively.

Statistical tests of the amplitude of the detected and undetected R-waves showed that the amplitudes of the undetected epochs were significantly lower than those of the detected epochs. Based on a review of the conditions for R-wave detection, we expect that the stability of the measurement can be improved further.