2.2.1. Fuzzification of Heart Rate Measures by Optimal Heart Rate Training Zones

In this section, we describe a linguistic approach based on fuzzy logic for the OHRTZ. In fuzzy logic methodology, a variable can be defined by means of terms, which are described by means fuzzy sets. Each fuzzy set is defined in terms of a membership function which is a mapping from the universal set to a membership degree between 0 and 1.

Based on the fuzzy logic methodology, we proceed to describe the HR under a linguistic representation defined by the parameters from the CRP, detailed in Section 2.1. Specifically, we propose three intuitive terms {*low, adequate and high*}, which are defined by fuzzy sets, for describing the variable *heart rate*, which is measured by a 2-tuple value ¯*hr<sup>i</sup>* = *hr<sup>i</sup>* , *ti* . *hr<sup>i</sup>* represents a given value in the heart rate stream and *t<sup>i</sup>* its time-stamp. Hence, the heart rate stream is composed of a set of measured values *<sup>S</sup>* ¯*hr* <sup>=</sup> { ¯ *hr*0, . . . , ¯*hri* , . . . , ¯ *hrn*} which are collected by the heart rate sensor.

In this section, we focus on the fuzzification of a heart rate measure individually, ¯*hr<sup>i</sup>* . On one hand, because of prior definitions in cardiac rehabilitation, which are, (1) the OHRTZs as values of HR between the ranges [*r*+,*r*−]; and (2) the ventilatory thresholds [*VT*1, *VT*2] as the efficient and safe ranges of aerobic physical activity, we define the term as *adequate*. This term is described by a fuzzy set characterized by a membership function whose shape corresponds to a trapezoidal function. The well-known trapezoidal membership functions are defined by a lower limit *l*1, an upper limit *l*4, a lower support limit *l*2, and an upper support limit *l*<sup>3</sup> (See Equation (1)):

$$TS(\mathbf{x})[l\_1, l\_2, l\_3, l\_4] = \begin{cases} 0 & \mathbf{x} \le \mathbf{0} \\ (\mathbf{x} - l\_1) / (l\_2 - l\_1) & l\_1 \le \mathbf{x} \le l\_2 \\ 1 & l\_2 \le \mathbf{x} \le l\_3 \\ (l\_4 - \mathbf{x}) / (l\_4 - l\_3) & l\_3 \le \mathbf{x} \le l\_4 \\ 0 & l\_4 \le \mathbf{x} \end{cases} \tag{1}$$

For the term *adequate*, the fuzzy set is characterized by the trapezoidal membership function that is defined by Equation (2):

$$\mu\_{\text{adaptive}}(hr\_i) = TS(hr\_i)[VT\_1, r\_{-}^\*, r\_{+}^\*, VT\_2], VT\_1 < r\_-^\* < r\_+^\* < VT\_2 \tag{2}$$

On the other hand, with *VT*<sup>2</sup> being the threshold from aerobic to anaerobic activity, and *r* ∗ <sup>+</sup> the upper limit range for OHRTZs, we define the term *high*, which is described by a fuzzy set characterized by the trapezoidal membership function that is defined by Equation (3):

$$
\mu\_{\rm high}(hr\_i) = TS(hr\_i)[r\_{+}^{\*}, VT\_2, VT\_2, VT\_2], VT\_2 > r\_+^{\*} \tag{3}
$$

In a similar way, with *VT*<sup>1</sup> being the lower threshold of the aerobic activity and *r*<sup>−</sup> the lower limit range for OHRTZs, we define the term *low*, which is described by a fuzzy set characterized by the trapezoidal membership function that is defined by Equation (4):

$$
\mu\_{low}(hr\_i) = TS(hr\_i)[VT\_1, VT\_1, VT\_1, r\_{-}^\*]\_\prime VT\_1 < r\_{-}^\* \tag{4}
$$

The relation between the thresholds from cardiac rehabilitation program and the membership functions is shown in Figure 1. Moreover, thanks to the use of linguistic modifiers, in fuzzy logic, we can model different semantics over the membership functions for describing the linguistic terms [36]. To represent the impact of a linguistic modifier *m* over a linguistic term *v*, such as *great* or *fair*, a straightforward power operation of the membership function is proposed [37] and defined by *µm*,*v*(*x*) = *µv*(*x*) *<sup>α</sup><sup>m</sup>* .

**Figure 1.** Example of membership functions for the terms low, normal, and high. In the example, the optimal heart rate training zones (OHRTZs) of the sessions are for trained patients, which are closer to *VT*<sup>2</sup> than to *VT*<sup>1</sup> . In the example of modifiers, the impacts of the weak modifier in short-dashed lines and the strong modifier in long-dashed lines are shown.

If *α<sup>m</sup>* < 0, we obtain a weak modifier, such as *fair*; and a strong modifier with *α<sup>m</sup>* > 0, such as *great*. In Figure 1, we describe the impact of the linguistic modifiers, and in Section 4, we describe the comparative results of provided by the cardiac rehabilitation team.

At this point, based on the current value of the heart rate *hr<sup>i</sup>* and the thresholds for the session [*VT*1, *VT*2] and [*r* ∗ <sup>+</sup>,*r* ∗ <sup>−</sup>], we are able to calculate the degree of the fuzzy terms {*low, adequate, and high*} in order to advise the patient in real-time with respect to the adequacy of the sessions.

The degrees of membership of the HR to the fuzzy sets {*low, adequate, and high*} can provide an intuitive evaluation for the real-time monitoring of sessions in wrist-worn wearable devices. For example, in this work, gradually changing colors in the evaluation of the HR are used to paint the screen of the wearable device and to evaluate the session using a 4-star scale, as described in Section 3.

However, in practice, it is necessary to handle additional issues in order to provide real-time monitoring during the rehabilitation sessions: the monitoring in the progressive stage and the temporal evaluation of heart rate streams.

2.2.2. Fuzzy Transformation from the Progressive to Maintenance Stage

In the literature there is a lack of proposals for modeling of the progressive stage in cardiac rehabilitation. This is related to the fact that it does not contain critical HRs. To resolve this issue, we propose a straightforward method to translate the model of OHRTZs from the aerobic state to define the initial basal state. In this way, the basal state is described by the following parameters:


Next, for calculating the time evolution in real-time within the progressive stage, we define a weight progression *w* = ∆*t*0/*dw*, *w* ∈ [0, 1], where ∆*t*<sup>0</sup> is the duration of session in the current time *t*<sup>0</sup> and *d<sup>w</sup>* is the total duration of the progressive stage defined by the cardiac rehabilitation team.

Based on the temporal evolution of the weight progression as well as the initial and final values of each threshold, we can define the threshold in the progressive stage for each current time frame using a linear progression as shown in Equation (5).

$$\begin{aligned} r\_{-}(w) &= r\_{-}^{0} + (r\_{-}^{\*} - r\_{-}^{0}) \cdot w, w = \Delta t\_{0}/d\_{w} \\ r\_{+}(w) &= r\_{+}^{0} + (r\_{+}^{\*} - r\_{+}^{0}) \cdot w, w = \Delta t\_{0}/d\_{w} \\ VT\_{1}(w) &= VT\_{1}^{0} + (VT\_{1} - VT\_{1}^{0}) \cdot w, w = \Delta t\_{0}/d\_{w} \\ VT\_{2}(w) &= VT\_{2}^{0} + (VT\_{2} - VT\_{2}^{0}) \cdot w, w = \Delta t\_{0}/d\_{w} \end{aligned} \tag{5}$$

In Figure 2, we show an example of a CRS, where the linear progression of thresholds from progressive to maintenance stages is plotted.

**Figure 2.** Evolution of the values of parameters from progressive to maintenance stages for a rehabilitation session: duration range (30 min), duration of progressive stage (10 m) , OHRTZ *r* ∗ <sup>+</sup>,<sup>−</sup> <sup>=</sup> [130 bpm, 110 bpm], *HRmax* <sup>=</sup> <sup>170</sup> bpm, and *VT*1,2 <sup>=</sup> [100 bpm, 150 bpm]. This includes the basal ranges [*r* 0 <sup>+</sup>,*r* 0 <sup>−</sup>] = [65 bpm, 75 bpm], and the lower and upper basal threshold *VT*<sup>0</sup> 1,2 = [60 bpm, 85 bpm] for the patient. HR: heart rate; bpm: number of contractions of the heart per minute.
