0

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:

1

SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • Try this function instead: https://www.mathworks.com/help/signal/ref/findpeaks.html – Cris Luengo Jul 13 '20 at 00:52
  • Perhaps you want to have a look at [`findpeaks`](https://www.mathworks.com/help/signal/ref/findpeaks.html). You can set a threshold here or a minimum distance between peaks... – max Jul 13 '20 at 05:41
  • Hey , I have tried using findpeaks blackbox ,it works well in removing the false peaks.But here im using differentiation technique to find peask and trying to write my own algorithm.Can you please tell me how to get rid of them ?. – suvvi kn Jul 13 '20 at 05:56
  • The problem is that inside the for loop, the index of X that you try to remove will be always 0 (that should produce an error...) or 1, because you have a logical condition in it. You can do it with `if X(i)<0.6*X(i-1), X(i) = []; end` – Adiel Jul 13 '20 at 12:12
  • Yes I tried using if statement & I could eliminate the false peaks .But now I have logical array of X = 268 *1.The original Ypeaks was 12087 *1. How do I convert this correct X back to the original Ypeaks dimension ???? Because im not able to plot this on my figure properly !! – suvvi kn Jul 13 '20 at 13:15

0 Answers0