clc;
close all;
clear all;
load 100_ECG_0_5 ; %The ECG data MAT file
END=length(ECG_1);
main=ECG_1(1:end,1) ; % first ECG signal
% rpeakdetect(main,256)
main=transpose(main);
slen=length(main);
time=(1:slen);
% subplot(2,1,1);
% plot(time,main,'r');
% [filename, pathname] = uigetfile({'*.xls';'*.*'},'Select file');
% [A,txt,raw]=xlsread(strcat(pathname,filename));
le=input('Enter No. of samples ');
samp_freq=input('Enter sampling time');
time=0:1/samp_freq:(le-1)/samp_freq;
% main=cell2mat(raw(1:le,1));
plot(time,main);
%grid;
max=0:0:1000;
pos=0.000000:0:1000;
distance=0.00000:0:999;
c=1;
thresh=input('Enter threshold point (check Graph)');
max(c)=main(c);
pos(c)=time(c);
for i=1:le-1
if main(i)>=thresh
if max(c)< main(i)
max(c)=main(i);
pos(c)=time(i);
end
if (main(i+1)<=thresh);
c=c+1;
max(c)=-1000;
pos(c)=-1000;
end
end
end
d=le+1;
max(c)=0;
pos(c)=0;
c=c-1;
for i=1:c-1
distance(i)=pos(i+1)-pos(i);
end
distance
% [fn,pn]=uiputfile('*.xls','Give a Name');
% fileID = fopen([pn,fn],'w');
% fprintf(fileID,'%5f\t\n ',distance);
% fclose(fileID);
%%%%%%%%%%%%%%MEAN(1ST ORDER CENTRAL MOMENT) OF RR INTERVAL%%%%%%%%%%%%%
RRdistance=0;
n=length(distance);
for (i=1:c-1)
RRdistance=RRdistance+distance(i);
end
meanRR=RRdistance/n
%%%%%%%%%%%By direct Formula%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
meanRR=mean(distance)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%VARIANCE(2ND ORDER CENTRAL MOMENT)%%%%%%%%%%%%%
vari=0;
for(i=1:c-1)
d(i)=(distance(i)-meanRR)^2;
vari=vari+d(i);
end
vari=vari/(n-1)
%%%%%%%%%%%%%%%%%BY direct Formula%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
variance= var(distance)
%%%%%%%%%%%%%%%%%STANDARD DEVIATION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SD=sqrt(variance);
%%%%%%%%%%%%%%%%%%%%%%3RD ORDER CENTRAL MOMENT%%%%%%%%%%%%%%%%%%%%%%%%%
m3=0;
for(i=1:n)
c(i)=(distance(i)-meanRR)^3;
m3=m3+c(i);
end
m3=m3/n; % 3rd order center moment
%%%%%%%%%%%%%%%%%%%By direct Formula%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mm3=moment(distance, 3); % 3rd order center moment
%%%%%%%%%%%%%%%%%%%%%%%SKEWNESS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
m2=variance;
skew=m3/(m2)^(3/2)
a=skewness(distance)
%%%%%%%%%%%%%%%%%MAX OF RR INTERVAL%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
max=distance(1);
for(i=1:n)
if(max<distance(i))
max=distance(i);
end
end
maxRR=max;
%%%%%%%%%%%%%%%%%MIN OF RR INTERVAL%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
min=distance(1);
for(i=1:n)
if(min>distance(i))
min=distance(i);
end
end
minRR=min;
%%%%%%%%%%%%%%%%%%%%%%%R PEAK POSITION%%%%%%%%%%%%%%%%%%%%%%
Rpos=pos(1:n);
%%%%%%%%%%%%%%%%%%%%%%%Heart Rate%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%% check format of data %%%%%%%%%%
% [a b] = size(main);
% 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 = main;
% end
% %%%%%%%%%% check if data is in columns or rows
% if (a == 2)
% x=main(:,1);
% t=main(:,2);
% end
% if (b == 2)
% t=main(:,1);
% x=main(:,2);
% end
%
% %%%%%%%%% bandpass filter data - assume 256hz data %%%%%
% % 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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(1,round(7*samp_freq/256))];
% end
% % integrate
% mdfint = medfilt1(filter(d,1,sqr),10);
% % remove filter delay for scanning back through ECG
% delay = ceil(length(d)/2);
% mdfint = mdfint(delay:length(mdfint));
%
% %%%%%%%%% segment search area %%%%%%%%%%%%%%%%%%%%%%%
% %%%% first find the highest bumps in the data %%%%%%
% max_h = max (mdfint(round(len/4):round(3*len/4)))
%
% %%%% then build an array of segments to look in %%%%%
% %thresh = 0.2;
% poss_reg = mdfint>(thresh*max_h);
%
% %%%%%%%%% and find peaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%% find indices into boudaries of each segment %%%
% left = find(diff([0 poss_reg'])==1); % remember to zero pad at start
% right = find(diff([poss_reg' 0])==-1); % remember to zero pad at end
%
% %%%% loop through all possibilities
% for(i=1:length(left))
% [maxval(i) maxloc(i)] = max( bpf(left(i):right(i)) );
% [minval(i) minloc(i)] = min( bpf(left(i):right(i)) );
% maxloc(i) = maxloc(i)-1+left(i); % add offset of present location
% minloc(i) = minloc(i)-1+left(i); % add offset of present location
% minval2(i)=min(left(i));
% end
% q_t=t(left);
% q_amp= minval2;
% R_index = maxloc;
% R_t = t(maxloc);
% R_amp = maxval;
% S_amp = minval; %%%% Assuming the S-wave is the lowest
% %%%% amp in the given window
% S_t = t(minloc);
% %need=s_t-q_t;
% %%%%%%%%%% check for lead inversion %%%%%%%%%%%%%%%%%%%
% % i.e. do minima precede maxima?
% if (minloc(length(minloc))<maxloc(length(minloc)))
% R_t = t(minloc);
% R_amp = minval;
% S_t = t(maxloc);
% S_amp = maxval;
% end
% length(left)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QRS COMPLEX
%
% %%%%%%%%%%%%
% hrv = diff(R_t);
% resp = R_amp-S_amp;
rr-interval.zip_ECG MATLAB_ECG signal_RR_ecg rr _to rr entkitty
版权申诉
5星 · 超过95%的资源 182 浏览量
2022-07-15
17:44:29
上传
评论
收藏 10KB ZIP 举报
小贝德罗
- 粉丝: 70
- 资源: 1万+
最新资源
- 937712277954201实习5.word
- 2程序语言基础知识pdf1_1716337722703.jpeg
- 简单的Python示例,演示了如何使用TCP/IP协议进行基本的客户端和服务器通信
- 考试.sql
- keil2 + proteus + 8051.exe
- 1961ee27df03bd4595d28e24b00dde4e_744c805f7e4fb4d40fa3f695bfbab035_8(1).c
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- windows注册表编辑工具
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- 校园通行码预约管理系统20240522075502
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈