Finding R peak from a heart signal input from a stethoscope

倖福魔咒の 提交于 2019-12-11 17:51:20

问题


Given an heart beat signal measured using a stethoscope to the audio card of the computer through a hardware(mainly amplifier and low pass filter having cutoff frequency 100hz). Now the signal is filtered with cutoff 100hz..the code to find the peak and beats per minute is given below..The code works only for certain cases. Please help me find the mistake

clear all
%input the signal into matlab


[x,fs]=wavread('heartbeat.wav');
figure(1)
subplot(2,1,1)
x1=x(:,2);
plot(x1(500:10000),'r-');
title('unfiltered input x(n),cut off frequency 0.0270,passband 60hz,stopband 70hz');
ylabel('amplitude in volts');
xlabel('number of samples')
grid on

%to filter the signal above 50-60 hz
order=4;
h=fir1(4,0.0270,hamming(order+1));
y=filter(h,1,x1);
subplot(2,1,2)
plot(y(500:10000),'b-')
title('filtered output y(n),cut off frequency 0.0270,passband 50hz,stopband 60hz');
ylabel('amplitude in volts');
xlabel('number of samples')
grid on
%sound(y,5000)


th = max(y) * 0.9; %So here I'm considering anything less than 90% of the max as not a real peak... this bit really depends on your logic of finding peaks though which you haven't explained
Yth = zeros(length(y), 1);
Yth(y > th) = y(y > th);

Ydiff = diff(Yth);
Ydiff_logical = Ydiff < 0;
Ypeaks = diff(Ydiff_logical) == 1;

p=sum(Ypeaks)

N = length(y);
duration_seconds=N/fs;
duration_minutes=duration_seconds/60;
BPM=p/duration_minutes;
bpm=ceil(BPM)




figure(2)
%frequency response of the filter
freqz(h,1)
title('Frequency response');
xlabel('normalized frequency (X pi) radians per sample');
ylabel('Magnitude');
grid on;

回答1:


Without example data I'm just guessing, but I don't think thresholding is going to get you the right data: in all likelihood, the peaks are different height each time (by "each time" I mean both each run and each individual beat). Therefore, if you use too high a peak, it will miss some real peaks because the heartbeat will be too low. If you use too low a peak, you risk double-counting some heartbeats beacuase each heartbeat contains multiple peaks (Sorry I don't remember what these are called). It's likely that things will change over time, as well, so I wouldn't even try to set the threshold for an individual recording and let it go, or even deriving threshold from the data could be problematic.

You will likely have better luck with other techniques such as cross-correlation or some sort of modified zero-crossing, or something specifically designed for the unique features of heartbeats (I imagine there is something. Have you searched the literature?).



来源:https://stackoverflow.com/questions/16210280/finding-r-peak-from-a-heart-signal-input-from-a-stethoscope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!