1 Introduction

Cardiovascular disease (CVD) is the leading cause of death among patients with noncommunicable diseases [1]. The risk factors for CVD include a lack of physical exercise, poor nutrition, family history of genetic diseases, smoking, hypertension, and diabetes [2]. Among these risk factors, lack of physical exercise, which can increase the risk of premature death by 9% [3], is the easiest to overcome. By contrast, sufficient physical exercise can reduce the overall risk of heart disease and stroke [4, 5]. The risk of coronary heart disease, hypertension, sudden cardiac death, and other cardiovascular events can be assessed by measuring the resting heart rate (HR) [6, 7] and postexercise HR recovery [8]. Regular exercise can lower the resting HR [9] and improve postexercise HR recovery [10].

Exercise guidance is a crucial component of an effective exercise routine. Current exercise guidance systems use distance and time as the control standards but do not facilitate HR management. Without effective guidance during exercise, appropriately controlling exercise intensity can be difficult for an individual without training experience. Wearable-device-based exercise guidance systems have thus been proposed in recent years to resolve this problem [11,12,13,14,15,16,17,18,19]. Astaras et al. [11] and Kokonozi et al. [12] presented prototypes of a wearable dry electrode device designed for exercise guidance and real-time monitoring of patients with CVD. Balsalobre-Fernandez et al. [13] introduced a wearable band for measuring movement velocity during a back squat exercise. Pruthi et al. [14] described an autonomous wearable device to count repetitive exercise movements in real time. Zhao et al. [15] developed wearable trackers for use during exercise and fitness activities. Yong et al. [16] designed a wearable device and Internet-of-things-based fitness system for exercise guidance. Bajpai et al. [17] developed a wearable-device-based fitness tracking system. Guo et al. [18] created FitCoach, a virtual fitness coach that uses wearable mobile devices to assess dynamic postures during exercises. Imani et al. [19] introduced a wearable hybrid-sensing system worn on the skin that offers real-time monitoring of health and fitness status by using biochemical and electrophysiological signals simultaneously.

In addition to wearable devices that guide exercise routines, music beats have a significant effect on exercise performance. Music beats can provide psychological motivation and reduce the feeling of exhaustion, and thus, promote a longer workout [20, 21]. Moreover, when the rhythm of music was similar to that of the exercise, the music can enhance exercise performance [22, 23]. A study correlating the HR with the tempo of music demonstrated that HR increases and decreases according to the tempo of music during a progressive exercise routine guided by music beats [24]. Despite their positive effects on exercises, music beats have not been incorporated into current wearable-device-based exercise guidance systems.

In this study, a smart-clothing-based intelligent exercise guidance system using music beat guidance was designed and developed. Smart clothing was used for electrocardiogram (ECG) signal collection and HR monitoring. Personalized running cadence (running steps per minute guided by music beats) was predicted using a quadratic polynomial regression model (QPRM) of HR and running cadence. HR was controlled to achieve the target HR range (HRR) recommended by the exercise prescription. The experimental results demonstrated the effectiveness of the proposed system for exercise guidance.

2 Methods

2.1 System Design

The proposed intelligent exercise guidance system is illustrated in Fig. 1. The system comprised three modules: front-end ECG signal-sensing device, middle-end exercise control application program, and backend cloud server.

Fig. 1
figure 1

Schematic of the architecture of the proposed intelligent exercise guidance system

The ECG signal-sensing device was a wearable device for exercise; the device comprised smart clothing and a gateway. The smart clothing was made of cloth and embedded with an ECG-sensing component, consisting of ECG sensors and conductive fibers. A tension adjustment system comprising elastic bands and Velcro strips was designed for adjusting the contact tension between the ECG signal-sensing component and the skin. At the center of the gateway was an STM32F401 microprocessor unit (MPU) with a 12-bit analog-to-digital converter (ADC). Raw ECG signals were collected by AD8232 ECG analog front-end chips through conductive fibers on the smart clothing and digitalized through the ADC of the MPU at a 250 Hz sampling frequency. The digital ECG signals were filtered successively by a 60 Hz notch filter, high-pass filter with a 0.05 Hz cutoff frequency, and low-pass filter with a 60 Hz cutoff frequency. The filtered signals were subsequently amplified by 200 times. The amplified digital ECG signals were transferred to the MPU through an array-mesh-structured conductive-fiber data bus and optical fiber circuits. The ECG signals were then denoised for movement artifact reduction and the HR was computed; the details of this process are described in Sect. 2.3.

The exercise control application program acquired HR data from the ECG signal-sensing device and processed the data to evaluate the physical and cardiopulmonary function of the subject. During the exercise routine, the application program executed the exercise prescription sent from the cloud server; provided music beats to guide the exercise; and recorded HR, running cadence, calories burned, degree of completion, and other data. The data were then uploaded to the cloud server at the end of the exercise routine to assist the subject with long-term tracking and recording of exercise performance.

On receiving a subject’s data, the cloud server analyzed the data to determine the subject’s physical ability level. On the basis of the basic data of the subject and the Physical Activity Readiness Questionnaire (PAR-Q) completed by the subject, the cloud server generated a personalized exercise regimen for the subject. According to the service pattern proposed in this study, a health-promoting exercise information system was constructed. Along with the smart clothing for monitoring HR and treadmill for performing the exercise, the intelligent exercise guidance system was applied to guide the subjects of various ages in performing the health-promoting exercises. The system helped the subject to reach the target HRR while measuring HR to monitor the subject’s cardiorespiratory status. Figure 2 depicts a subject performing exercises under the guidance of the proposed intelligent exercise guidance system while wearing the smart clothing.

Fig. 2
figure 2

A subject wearing the smart clothing and exercising under the guidance of the proposed intelligent exercise guidance system. The black object on the white smart clothing is the gateway

2.2 System Workflow

Figure 3 presents a flow of the intelligent exercise guidance system. After starting the exercise control application program, the subject first completed the PAR-Q to evaluate whether exercise would be risky; if not, the subject completed the registration and signed into the system. If the subject had an exercise prescription, the exercise would be started immediately. If not, the subject entered information concerning their exercise target and frequency, which was used to preliminarily evaluate and categorize their physical ability as bad (1 low-intensity exercise session for < 1 month), normal (1–3 medium-intensity exercise sessions/week for 1–6 months), and nice (1–6 high-intensity exercise sessions/week for the past 6 months).

Fig. 3
figure 3

Flow chart of the proposed intelligent exercise guidance system

Next, the intelligent exercise guidance system selected an exercise prescription preset in the database, comprising exercise duration and a target HR (percentage of maximum HR), according to two personalized evaluation types. After preparing the prescription, the intelligent exercise guidance system generated target HRs for three stages (warmup, training, and cooldown):

$${\text{HR}}_{\text{warmup}} = {\text{HR}}_{ \hbox{max} } \times 50\% ,$$
(1)
$${\text{HR}}_{\text{training}} = {\text{HR}}_{ \hbox{max} } \times 70\% ,{\text{ and}}$$
(2)
$${\text{HR}}_{\text{cooldown}} = {\text{HR}}_{ \hbox{max} } \times 60\% ,$$
(3)

where HRmax was calculated as follows:

$${\text{HR}}_{ \hbox{max} } = 2 20 - {\text{age}}.$$
(4)

The three-stage exercise routine was 30 min long, divided into warmup, training, and cooldown stages, lasting for 5, 15, and 10 min, respectively.

The Harvard step test was also performed to calculate the cardiorespiratory and physical fitness index [25]:

$${\text{Fitness Index}} = \frac{{{\text{Test duration}}\,\left( {\sec } \right) \times 100}}{{{\text{Sum of heart beats in the recovery periods}} \times 2}} ,$$
(5)

where the test duration was 3 min or until exhaustion, and heartbeats during the recovery periods were counted from 1 to 1.5, 2 to 2.5, and 3 to 3.5 min after exhaustion or test completion. The results were evaluated according to the norms used for Taiwanese people (Table 1).

Table 1 Norms of fitness index score for Taiwanese people

During the exercise session, the HR of the subject was monitored every 3 s to assess whether it reached the target range. If the target HRR was not reached after 1 min, the regression model would be used to adjust the speed of the music beats.

At the end of the exercise session, postexercise HR recovery was evaluated. At the same time that the exercise results were displayed, HR, running cadence, date, degree of completion, and other data were uploaded to the cloud server. According to the postexercise data, a new regression model was used to compute a running cadence and HR that was more suitable for the current physical state of the subject. During the next exercise session, the new regression model was fed back to the subject. The regression model was regularly updated with the data from the subject’s exercise sessions.

2.3 ECG Signal Denoising and HR Calculation

ECG signals are affected by movement artifacts, which must therefore be effectively removed [26,27,28]. Empirical mode decomposition (EMD) [29] was used to filter noise in this study. EMD, which can reduce motion artifacts and baseline wander in ECG signals [26,27,28], was used to decompose the ECG signal x(t) into N intrinsic mode functions (IMFs) and the residual r(t):

$$x(t) = \sum\limits_{j = 1}^{N} {IMF_{j} (t)} + r_{N} (t).$$
(6)

The pseudocode of the EMD algorithm is as follows:

figure a

In this study, the EMD algorithm was improved to accelerate the algorithm for wearable devices. First, the calculation of SD in step 3.6 was removed and the stopping criterion SD(i) < ɛ in step 3.7 was replaced with i > iter, where iter is the iteration threshold set according to various states of motion. Second, the stopping criterion in step 6 was replaced with the number of extrema in rj(t) ≤ 2 and j  ≤ order, where order is a preset iteration threshold for j. With the improved EMD algorithm, the denoised ECG signal y(t) was obtained by summing up the 1st, 2nd, …, Kth IMFs, where K ≤ N:

$$y(t) = \sum\limits_{j = 1}^{K} {IMF_{j} (t)} .$$
(7)

By using the denoised ECG signal y(t), a novel QRS morphology analysis algorithm, called MWqrs (proposed in another work [30]), was employed to differentiate between QRS complexes and artifacts. Three feature points were calculated after the algorithm detected a possible QRS complex. MWqrs was used to calculate the curve length transformation LT(ω, i) of y(t) as

$$LT(\omega ,i) = \sum\limits_{k = i - \omega }^{i} {\sqrt {\Delta t^{2} + \Delta c_{k}^{2} } } ,$$
(8)

where i is the start index and the curve length transformation was calculated from iω to i; Δc the length differentiable over the time window ω, chosen to be approximately equal to the QRS duration (0.13 s); and Δt the sampling period. The curve length of y(t) was then calculated in correspondence to the QRS complexes. HR was calculated as

$$HR = \frac{60}{RR},$$
(9)

where RR is the time interval between two adjacent R-peaks of the denoised ECG signal y(t).

2.4 QPRM of Running Cadence and HR

A QPRM of running cadence and HR was derived:

$$Y = \left( {a \times X^{2} } \right) + \left( {b \times X} \right) + c,$$
(10)

where Y is the HR (beats/min; BPM); X the running cadence (running steps per minute guided by music beats); and a, b, and c the quadratic polynomial regression coefficients. The target HRR constituting effective exercise was reached when the subject followed the guidance of music beats. The units of the running cadence (running steps/min) and the music beat (BPM) were consistent with respect to time. A music beat was the number of downbeats (strongest tones in melody) per minute, whereas running cadence was the number of forward foot shifts per minute. Therefore, the music beat could be used to interpret running cadence. Another study demonstrated that the standard deviation of the heartbeat interval during exercise was 65.13–95.34 ms [31]. Considering HR variability and a 2% hardware-level error rate, the three-stage effective HRRs were set at target HRs ± 10%:

$${\text{HRR}}_{\text{warmup}} = {\text{HR}}_{\text{warmup}} \times \left( { 100\% \pm 10\% } \right),$$
(11)
$${\text{HRR}}_{\text{training}} = {\text{HR}}_{\text{training}} \times \left( { 100\% \pm 10\% } \right),{\text{ and}}$$
(12)
$${\text{HRR}}_{\text{cooldown}} = {\text{HR}}_{\text{cooldown}} \times \left( { 100\% \pm 10\% } \right)$$
(13)

When using the intelligent exercise guidance system, the goals were to yield a high degree of completion for the exercise routine, even with a preset regression model, and generate a better effect with a postexercise-trained regression model. The degree of completion was the percentage of actual exercise HRs within the effective HRRs. A higher degree of completion represented a longer time, during which HRs were in the effective HRRs and corresponded to more effective exercise. When the degree of completion decreased, the actual exercise HRs became too low or high compared with the effective HRRs, necessitating HR adjustment (raising or lowering) to assist the subject in adjusting the exercise cadence so as to bring their HR back within the effective HRR. Thus, the exercise HR trend should be controlled, for which using an accurate regression model is essential. The preset regression models were grouped according to the physical ability to conform to the HR trends of various subjects. For the trained regression models, the predicted HRs of the running cadences of 60, 90, 120, and 150 steps/min generated by the preset regression model as well as the running cadence and HRs were recorded every minute during exercise and were used to train a new regression model.The running cadence was presented to the subject as music beats for exercise guidance. The music speed was generally marked by characters or numbers at the beginning of a music piece. The music speed was measured in beats per minute as well, representing the frequency with which a specified note (e.g., a quarter note) occurred in 1 min. For instance, music with a 4/4 beat played at 120 BPM has 120 quarter notes were played every minute. The duration of each quarter note was calculated by dividing 1 min by 120, which resulted in a 0.5-s duration. The duration of a bar was 0.5 s multiplied by 4 beats, which resulted in a 2-s duration. A larger BPM value represented faster speed. For the practical application of the proposed intelligent exercise guidance system, the only factor a subject requires to know about music speed is that running must be performed according to the guidance of the music beats.

3 Experimental Results

3.1 Experiment I

Experiment I aimed to evaluate the performance of the proposed EMD-based R-peak detection method by using full records from the MIT-BIH Arrhythmia Database [32, 33] (https://physionet.org/physiobank/database/mitdb/). The accuracy and sensitivity of R-peak detection were evaluated as

$${\text{Sensitivity}} = \frac{\text{TP}}{{{\text{TP}} + {\text{FN}}}}\,\,{\text{and}}$$
(14)
$${\text{Accuracy}} = \frac{{{\text{TP}} + {\text{TN}}}}{{{\text{TP}} + {\text{FP}} + {\text{FN}} + {\text{TN}}}},$$
(15)

where TP, FP, TN, and FN represent the number of true positive (correct detection of an R-peak), false positive (false detection of the absence of an R-peak), true negative (correct detection of the absence of an R-peak), and false negative (false detection of an R-peak) results, respectively. Table 2 presents the results of Experiment I. The average accuracy and sensitivity were 99.8% and 94.87%, respectively, demonstrating a highly satisfactory performance of the proposed algorithm.

Table 2 EMD-based R-peak detection results of the experiment on the MIT-BIH Arrhythmia Database

3.2 Experiment II

Experiment II aimed to evaluate the accuracy of R-peak detection for various running speeds with and without EMD-based ECG denoising. Twenty male volunteers were recruited at Chang Gung University and classified according to their physical ability. The subjects wore smart clothing with wireless ECG signal transmission devices. Each subject ran on a treadmill for 1 min at running speeds of 0, 1, 2, and 3 km/h, during which the ECG signals from their smart clothing devices were collected. The proposed EMD-based R-peak detection method was evaluated using these ECG signals. Table 3 presents the R-peak detection accuracy for various running speeds with and without ECG denoising through EMD. When EMD-based ECG denoising was employed, the accuracy of R-peak detection increased from 94.93 to 96.46%, whereas its sensitivity increased from 98.03 to 98.75%. Figure 4 presents the typical ECG signals filtered through EMD.

Table 3 R-peak detection accuracy for various running speeds with and without EMD
Fig. 4
figure 4

Typical ECG signals filtered through EMD. The original ECG signals are depicted in blue and the EMD-filtered signals in orange

3.3 Experiment III

Experiment III aimed to evaluate the preset QPRMs of HR and running cadence. At Chang Gung University, 15 male volunteers were recruited to be subjects and were classified according to their physical ability. The subjects wore smart clothing with wireless ECG signal transmission devices and ran on a treadmill under the guidance of specific music beats. Each subject ran for 27 min, which was divided into 3-min increments of the following nine cadences: 0, 60, 90, 120, 150, 120, 90, 60, and 0 steps/min. The HR data corresponding to the specific music beats were recorded by the application program. The data of HRs and running cadence were used to train the QPRM; three models of physical ability—“bad,” “normal,” and “nice”—were thus obtained. These models were then used as the preset models for various physical ability groups. The performance of the preset models was evaluated using mean absolute percentage error (MAPE) and the coefficient of determination (r2). The evaluation results are presented in Table 4 according to the physical ability of the subjects (bad, normal, or nice). The QPRM yielded a satisfactory MAPE and r2 for HR increasing and decreasing, and thus demonstrated the effectiveness of the model for predicting the correlations between HRs and running cadences.

Table 4 MAPE and r2 of the preset QPRMs for increasing and reducing HR

3.4 Experiment IV

Experiment IV aimed to evaluate the degree of completion of exercises by using the preset QPRMs from Experiment III. Eleven participants, randomly selected from the 15 participants of Experiment III, were included in this experiment. The subjects completed three stages (warmup, training, and cooldown) of exercise on the treadmill wearing smart clothing equipped with ECG signal transmission devices. Warmup, training, and cooldown times were 5, 15, and 10 min, respectively. By using the preset QPRMs from Experiment III and Eqs. (11)–(13), the effective HRRs were computed. When the HR of the subject was not within the effective HRR (i.e., the HR was too fast or too slow), the proposed intelligent exercise guidance system would generate a message prompting the subject to make an adjustment to increase or decrease the HR. The percentage of the actual HRs within the effective HRRs was computed, yielding the degree of completion. A high degree of completion indicated superior exercise efficacy. Table 5 presents the degree of completion of the three stages of exercise. The degree of completion was 94.2%, 78.36%, and 79.82% for the warmup, training, and cooldown stages, respectively. After removing the 1 min of HR variation before each stage, the degree of completion was 97.05%, 91.91%, and 98.32%, respectively. After stabilization, the HRs were mostly within the effective HRRs.

Table 5 Degree of completion of three stages (warmup, training, and cooldown) of the exercise with the preset QPRMs for increasing and decreasing HR

3.5 Experiment V

Experiment V aimed to evaluate the accuracy of the preset and trained QPRMs. The same 11 participants from Experiment IV were included in this experiment. The subjects completed three stages (warmup, training, and cooldown) of exercise on the treadmill wearing smart clothing equipped with wireless ECG signal transmission devices. They performed the warmup, training, and cooldown stages for 5, 15, and 10 min, respectively. For a subject using the intelligent exercise guidance system for the first time, the system initially had no QPRM specifically trained for the subject. Thus, a preset model was selected from the three models generated from Experiment III, according to the physical ability of the subject (bad, normal, or nice). The data of HRs and running cadence during exercise, together with the preset model, were used to train a new personalized model. The effective HRRs were computed using the trained models and Eqs. (11)–(13). When the HR of the subject was not within the effective HRR (i.e., the HR was too fast or too slow), the proposed intelligent exercise guidance system would generate a message prompting the subject to make an adjustment to increase or reduce the HR. The MAPE of the degree of completion was computed to evaluate the accuracy of the preset and trained models. Table 6 presents the evaluation results for increasing and decreasing HR. The MAPE of the preset model was small, but the MAPE of the trained model was even smaller. These results demonstrated the feasibility of using the preset and trained QPRMs.

Table 6 MAPE of the preset and trained QPRMs for increasing and decreasing HR

4 Discussion and Conclusions

In this study, a smart-clothing-based intelligent exercise guidance system employing music beat guidance was developed, an ECG signal denoising algorithm based on EMD was proposed, and a service pattern of music-beat-guided exercise was introduced.

Compared with currently available wearable-device-based exercise guidance systems, the proposed smart-clothing-based intelligent exercise guidance system has some novel features [11,12,13,14,15,16,17,18,19]. The proposed intelligent exercise guidance system incorporated music beats, which no current exercise guidance systems have done [11,12,13,14,15,16,17,18,19]. In addition, the proposed intelligent exercise guidance system used smart clothing for ECG signal collection and HR monitoring, which current exercise guidance systems also have not done [11,12,13,14,15,16,17,18,19]. The authors believe that the proposed smart-clothing-based intelligent exercise guidance system may provide more effective and personalized guidance for exercises.

The proposed intelligent exercise guidance system implemented the following key features: HR calculation, three-stage (warmup, training, and cooldown) exercise guidance, physical fitness index analysis, resting HR detection, and postexercise HR recovery detection. The system also provided a trend analysis of HR and running cadence. The key element of experimental design was to have subjects run on a treadmill guided by music beats. The performance of the system’s EMD-based R-peak detection was evaluated as well as the accuracy and degree of completion for the running cadence predicted using the QPRM. Physical ability groupings and general trend regression models were used to determine the regression models with high accuracy, which were then used for preset and trained models.

During the experiments that evaluated whether the three preset regression models accurately conformed to the exercise HR trend, the regression model with the best performance of r2 and MAPE was determined. According to this regression model, the regression models for raising and lowering HR were trained for the subject. In the experiments evaluating the degree of completion of the exercise, a single HR regression model was not desired for the cooldown stage. When the HR exceeded the target HRR, the reactions of a single regression model were significantly slower than the reactions of multiple regression models that could simultaneously process the rise and fall of the HR. Thus, the difference in degree of completion was verified using models for increasing and reducing HR at the same time. Finally, in the experiments concerning the overall trend and physical ability grouping regression models, the physical ability grouping regression model (preset model) was selected as the running cadence prediction model for a subject using the system for exercise guidance for the first time. A new regression model that was more suited to the subject’s own exercise HR trend could be trained rapidly on the basis of the preset model.

In conclusion, this study consisted of the design and development of an intelligent exercise guidance system that incorporated smart clothing and a wireless ECG signal transmission device. The system could be used for effective exercise guidance to strengthen cardiac functions. A service pattern involving music-beat-guided exercise was proposed; music beats were employed to guide the user’s exercise rhythm to accurately control the HR trend and achieve the target HRR during the prescribed exercise regimen. Experiments were performed to validate the trend and accuracy of HR control using the QPRM of HR and running cadence. The smart clothing was wearable and convenient to use. More indepth analysis of QRS complexes, ST segments, and T waves of three-lead ECG signals can be conducted in the future to identify means of enabling the proposed intelligent exercise guidance system to detect more risk indices.