matlab - Finding R peak from a heart signal input from a stethoscope -


given heart beat signal measured using stethoscope audio card of computer through hardware(mainly amplifier , low pass filter having cutoff frequency 100hz). signal filtered cutoff 100hz..the code find peak , beats per minute given below..the code works cases. please me find mistake

clear %input signal 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 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 less 90% of max not real peak... bit depends on logic of finding peaks though 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 filter freqz(h,1) title('frequency response'); xlabel('normalized frequency (x pi) radians per sample'); ylabel('magnitude'); grid on; 

without example data i'm guessing, don't think thresholding going right data: in likelihood, peaks different height each time (by "each time" mean both each run , each individual beat). therefore, if use high peak, miss real peaks because heartbeat low. if use low peak, risk double-counting heartbeats beacuase each heartbeat contains multiple peaks (sorry don't remember these called). it's things change on time, well, wouldn't try set threshold individual recording , let go, or deriving threshold data problematic.

you have better luck other techniques such cross-correlation or sort of modified zero-crossing, or designed unique features of heartbeats (i imagine there something. have searched literature?).


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -