Skip to main content
. 2022 Feb 13;22(4):1428. doi: 10.3390/s22041428

Table A1.

Pseudo-code of the ENVELOPE and SLOPE beat detection algorithms. Bold type in variable names indicates arrays.

ENVELOPE SLOPE
# PPG PROCESSING
Compute:
     x’(t) = first derivative of the PPG signal
     emin(t) = inferior envelope of x’(t)
     emax(t) = superior envelope of x’(t)
     x’norm(t) = min-max normalization of x’(t) as in
                       Equation (4)
# HEARTBEAT DETECTION
Define:
     thENV = threshold for the identification of
                   heartbeats from x’norm(t); set to 0.8
Find:
     tpeaks = occurrence time of the local maxima of
           x’norm(t) exceeding thENV
# FALSE POSITIVES REDUCTION
Define:
     IBI¯= median peak-to-peak distance between all
             the elements in tpeaks
     N = number of peaks in tpeaks
     i = 1
While i < N
  1. Take the occurrence time of the i-th peak (ti)

  2. Calculate the difference between ti and the occurrence time of all the other elements in tpeaks: ti t1, tit2, …, titN

  3. Compare these differences to IBI¯ by using Equation (2), from which d = [d1, d2, …, dN] is obtained

  4. For each i < kN, find the lowest dk and define:

      j = k-th peak that minimizes d

  5. Discard all the peaks included between i and j-1 from tpeaks, if any, as they are false positives

  6. Update IBI¯ as in Equation (4) and set i = j for the next iteration

End
# IBI CALCULATION
Compute:
     IBIENV = difference between consecutive elements
            of the remaining occurrence times in tpeaks
# PPG PROCESSING
Define:
     x(t) = PPG signal
     N = number of samples in x(t)
# HEARTBEAT DETECTION
Define:
     RP = refractory period; initialized to 0.6 s
     RPchange = multiplier for RP updates; set to 0.6
     slope = slope coefficient for the adaptive threshold;
       initialized to 0.2*max(x(t))
     tinit = occurrence time of the first increasing
       segment found in x(t)
     th(t) = adaptive threshold, initialized to x(tinit)
     i = sample of x(t) corresponding to tinit
While i < N
  1. Increase i until a peak is found on x(t); define j as the sample of x(t) corresponding to this peak

  2. Add tj (occurrence time of the peak) to the array of the peaks found so far (tpeaks)

  3. Make th(t) = x(t) until the j-th sample is reached

  4. Update the slope parameter as shown in Equation (2) of [41]

  5. Linearly decrease th(t) starting from the peak found on x(t), using the updated slope

  6. When th(t) intersects x(t):

         If RP has passed

          Proceed to step 7

         Else

          Continue to linearly decrease th(t) and

          repeat this check at the next point of

          intersection

         End

  7. Compute the average IBI (IBI¯) from the tpeaks found so far and update RP for the next iteration: RP = RPchangeIBI¯

  8. Update i to the sample where th(t) intersected x(t) and proceed with the next iteration

End
# IBI CALCULATION
Compute:
     IBISLOPE = difference between consecutive
           elements of tpeaks