資源簡介
應用于心電信號的提取,R波檢測,不過要自己好好研究
代碼片段和文件信息
%可自動檢測RSRR間期;如果你仔細研究代碼還會發現它能自動檢測QRS
%[hrv?R_t?R_amp?R_index?S_t?S_amp]?=?ECGpeak(一維心電數據A/D轉換率);???
%代碼:??
data=load(‘Ecgdata.txt‘);
samp_freq=0;
[hrv?R_t?R_amp?R_index?S_t?S_amp]?=?ECGpeak(datasamp_freq)?
%?[hrv?R_t?R_amp?R_index?S_t?S_amp]?=?ECGpeak(data?samp_freq);?
%?R_t?==?RR?points?in?time;
%?R_amp?==?amplitude?of?R?peak?in?bpf?data;????
%?S_amp?==?amplitude?of?following?minmum;?
thresh?=?0.2;?
testmode?=?1;?
nargin=1
%%%%%%%%%%%?make?sample?frequency?default?256?Hz?
if?nargin?2
??samp_freq?=?256;?
??if(testmode==1)?
????fprintf(‘Assuming?sampling?frequency?of?%iHz\n‘samp_freq);??
??end?
end
??
%%%%%%%%%%%?check?format?of?data?%%%%%%%%%%?
[a?b]?=?size(data);?
if(a>b)?
len?=a;???
end???
if(b>a)?
len?=b;?
end?
%%%%%%%%%%?if?there‘s?no?time?axis?-?make?one?
if?(a?|?b?==?1);
%?make?time?axis??
tt?=?1/samp_freq:1/samp_freq:ceil(len/samp_freq);?
t?=?tt(1:len);?
x?=?data;??
end?
%%%%%%%%%%?check?if?data?is?in?columns?or?rows?
if?(a?==?2)
x=data(:1);?
t=data(:2);
end??
if?(b?==?2)???
t=data(:1);?
x=data(:2);?
end??
%%%%%%%%%?bandpass?filter?data?-?assume?256hz?data?%%%%%??y??
%?remove?mean??
x?=?x-mean(x);??
?
%?FIR?filtering?stage?
bpf=x;?%Initialise??
if(?(samp_freq==128)?&?(exist(‘filterECG128Hz‘)~=0)?)?
????bpf?=?filterECG128Hz(x);??
end?
if(?(samp_freq==256)?&?(exist(‘filterECG256Hz‘)~=0)?)???
????bpf?=?filterECG256Hz(x);??
end??
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%?
%%%%%%%%%?differentiate?data?%%%%%%%%%%%%%%%%%%%%%%%%%%%?F?
dff?=?diff(bpf);?%?now?it‘s?one?datum?shorter?than?before
%%%%%%%%%square?data???%%%%%%%%%%%%%%%%%%%%%%%%%%%?
sqr?=?dff.*dff;???
len?=?len-1;?%?how?long?is?the?new?vector?now??
%%%%%%%%%?integrate?data?over?window?‘d‘?%%%%%%%%%%%%%%%%%%%%%%%%%??
d=[1?1?1?1?1?1?1];?%?window?size?-?intialise???
if?(samp_freq>=256)?%?adapt?for?higher?sampling?rates????
??d?=?[ones(1round(7*samp_freq/256))];?
end????
%?integrate?
mdfint?=?medfilt1(filter(d1sqr)10);
%?remove?filter?delay?for?scanning?back?through?ECG?Z“?~.Y@]@T??
delay?=?ceil(length(d)/2);???
mdfint?=?mdfint(delay:length(mdfint));??
%%%%%%%%%?segment?search?area?%%%%%%%%%%%%%%%%%%%%%%%?
- 上一篇:一種pid控制跟蹤SIN函數的
- 下一篇:matlab實現經典功率譜估計
評論
共有 條評論