I have a PPG signal, and I'm trying to find peaks and troughs using differentiation technique. However along with peaks detection, this method also gives rise to many false peaks in the signal. The code and wave form are given below, but I want to get rid of the false peaks and I'm not able to.
Ydiff=diff(green); %First derivative of the input signal
Peakdiff_logical=Ydiff<0;% positive values to 0 and negative values to 1
A=diff(Peakdiff_logical);
Ypeaks=diff(Peakdiff_logical) == 1;
Ypeaks=[false;Ypeaks;false];
X= green(Ypeaks);
for i = 2:length(X) %% for loop to get rid of false peaks whose amplitude is 60 % less than previous amplitude
X(X(i)<0.6*X(i-1))=[];
end
The for loop is checking every peak with previous peak amplitude, if the present amplitude of peak is < 60% of previous amplitude peak, then delete that peak. But this for loop is not doing the job in eliminating the peaks, please let me know where I'm going wrong and how can I correct the mistake .
Here is the PPG signal on which I'm trying to find true peaks and get rid of false peaks: