Skip to main content
. 2021 Oct 30;21(21):7233. doi: 10.3390/s21217233
Algorithm 1. Pseudocode of peak detection algorithm and feature detection for dataset D.
FORxi in D (ECG or PPG data instance from dataset, where i = {0…size(D))
Filtered signal S[n] = BandpassFilter(xi)
Let peaklist={} (Peak amplitudes)
Let timelist={} (Peak times)
Let BlocksOfInterest={}
Let yi={}
Set W1 = Average ECG or PPG peak duration
Set W2 = Average ECG or PPG beat duration
Set MApeak = MovingAverage(S[n], W1)
Set MAbeat = MovingAverage(S[n], W2)
Set threshold α = W1+β
FOR n = 1 to length(MApeak)
IF MApeak[n] > MAbeat[n] THEN
BlocksOfInterest[n]=1
ELSE
BlocksOfInterest[n]=0
END IF
END FOR
FOR j = 0 to length(BlocksOfInterest)
IF width(BlocksOfInterest[j])  α THEN
peaklist[j] = max(BlockOfInterest[j])
timelist[j] = time(BlockOfInterest[j])
ELSE;
reject block
END IF
END FOR
{rMSSD, ,pRR50}= Calculate HRV/PRV (peaklist, timelist)
Transformed data instance  yi = {rMSSD, ,pRR50}
Save yi to updated dataset D¯
END FOR