How to find the peaks of a PPG signal?

28 views (last 30 days)
GIULIA BERTULEZZI
GIULIA BERTULEZZI on 2 Apr 2022
Answered: Chandra on 5 Apr 2022
Hi everyone, I wrote a code to read and plot the data contained in a four column text file. Each column contains the data extracted from a sensor (in total there are four sensors) and between one row and the other there is a time range of 10 milliseconds. I would like to determine the peaks of each of the four graphs, without using the peakdetection function, but I don't know how. Thanks to anyone who can answer me!

Answers (1)

Chandra
Chandra on 5 Apr 2022
Hi,
To find peaks of any signal initially it needs to be filtered through low pass in order to clear the local peaks
>>windowSize = 10; % window size can be changed as required
>>b = (1/windowSize)*ones(1,windowSize);
>>a = 1;
>>A = filter(b,a,A); %filtering using low pass
find the difference between the samples and find zero crossing points
>>A1 = [0;A(1:end-1)]; % for the purpose of calculating differentiation
>>A2 = A1-A; % difference gives the differentiation w.r.t to time sample
>>A4 = [A2(2:end);0]; %A4 is used to comparing the previous value to present
>>A3 = find(A2<0 & A4>0); % it contains the location of peaks
>>A3(end+1) = length(A2); % the last index value is added so that A5 have same length of A
In that location add the original values
>>A5(A3) = A(A3); %A5 have the all max values of give data
Then use the stem plot and appropriate limits to plot to see the data accurately and for viewing, adjust the values for data (like normalizing the data)
The reference code can be applied to different columns as well
The condition to A3 can also be optimized accordingly to eliminate the local peaks.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by