How to generate the curve from valley point to peak of a single cycle of reference ppg signal and take its symmetrical curve?
3 次查看(过去 30 天)
显示 更早的评论
I am trying to generate a PPG signal using symmetrical curve fitting method( From valley to peak trace and plot the signal,then take the symmetrical signal of it). I will attach the sample ppg signal.
2 个评论
Image Analyst
2023-1-30
Can you post a screenshot to let people know what you're talking about and so they can see if they want to download and run your code?
回答(1 个)
Ranjeet
2023-5-3
Hi Anupama,
After going through your query, I deduce that you want to take a portion of plot between a valley and peak point from the provided PPG data, generate its symmetric.
Here the modified code that you provided to achieve the target you mentioned.
clc;
close all;
clear all;
data = load('0128_8min.mat');
ppg = data.signal.pleth.y();
ppg=ppg(1:21000);
% indentify all peaks
[all_peak_value,all_peak_location]= findpeaks(ppg,'MinPeakProminence',5);
% identify all troughs in data
[all_trough_value,all_trough_location]= findpeaks(-ppg);
all_trough_value = -all_trough_value;
counter = 0;
M=1;
for i = 2:length(all_peak_location)
start=all_peak_location(i)-100;
ending=all_peak_location(i);
index = all_trough_location>start & all_trough_location<ending;
ind1=all_trough_location(index==1);
ind(M)=ind1(1);
M=M+1;
end
Lv = ismember(all_trough_location,ind); %check if notch is part of valley % Indices Of Valley Locations In Dicrotic Notch Locations
all_valley_location = all_trough_location(Lv); % 'Pure' Valley Locations
all_trough_value1 = all_trough_location(~Lv);
figure
%% Define start, peak and end ids for a section and its symmetric curve
start_id = all_trough_value1(int16(end/2));
peak_id = all_peak_location(int16(end/2));
end_id = (2*peak_id-start_id);
% plot one section, valley and peak points
ppg_one_section = ppg(start_id:peak_id);
plot(start_id:peak_id, ppg_one_section,'r')
xlim([start_id, end_id]);
hold on
plot(peak_id,all_peak_value(int16(end/2)),'ko')
plot(start_id,ppg(start_id),'g*')
% plot reflection of a section between valley and peak
ppg_reflection = flipud(ppg_one_section);
plot(peak_id:end_id, ppg_reflection, 'b');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1373314/image.jpeg)
Here, I have taken the middle part of PPG signal between a valley and adjacent peak. The blue curve is the reflection of red part. Here, flipud flips an array up to down.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!