(Food for Thought) Peak Detection on ECG signal
1 view (last 30 days)
Show older comments
Hey guys,
I've been working on a ECG signal collected during exercise through my chest mount heart rate monitor. My goal is to accurately detect the location of the R-wave. (For those who are new to ECG signal, R-wave is the narrow peak similar to the ones I circled in red.) Can you guys suggest any method for preprocessing the data so that it will be easier to extract the signal? Like anything! I am just trying to learn new skills right now
I have tried wavelet transform but I am not getting any luck. Come on guys, show me the power of the internet! haha
if you want to try it out, this is the data.
The sampling frequency is 150 Hz.
0 Comments
Accepted Answer
David Wilson
on 21 Jun 2019
OK, here's my (ugly) solution (withou using findpeaks). I've re-named your data set, and did some pre-processig.
load ecg
y = ecgSamplePreProc;
Ts = 1/150; % sampling freq = 150 Hz;
t = Ts*[0:length(y)-1]';
%% Do some preliminary cleaning
idx = [1:600];
t(idx) = []; y(idx) = []; % drop start-u transients
y = y - mean(y); % remove any bias
plot(t,y,'.-')
Now we are ready to identify the peaks. (I'm not sure if that's the same as your R-wave, but it's a start.)
n = length(y);
thresh = 0.7;
pauseOn = false;
irange = [-5:5];
pk = [1];
pauseOn = true;
for i=10:n-10
if y(i) > thresh
yr = y(i+irange);
if y(i) >= max(yr) && pauseOn && (i > pk(end)+50)
pk = [pk;i];
pauseOn = true;
end
if y(i) < -thresh
pauseOn = false;
end % if
end
end
plot(t,y, ...
t(pk), y(pk), 'ro')
yline(thresh,'--','color',0.5*[1,1,1])
The results look like:
and a zoomed version is:
Of course you could try findpeaks as well.
1 Comment
lt c
on 28 Feb 2022
I'm new to matlab. Without annotation, I'm not fully understand your work.
1. what does "t(idx) = []; y(idx) = []; % drop start-u transients" mean?
I try to google start-u transients, unfortunately get start-up transients.
2. Also, what does following lines get us?
if y(i) >= max(yr) && pauseOn && (i > pk(end)+50)
pk = [pk;i];
pauseOn = true;
Do not mind me asking questions that may seem pretty simple to others, thank you.
Cheers
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!