Скачиваний:
18
Добавлен:
08.04.2022
Размер:
3.12 Кб
Скачать
clc
clear all
close all

global hAxes1 hAxes2 hAxes3 hAxes4 hAxes5 hAxes6 hAxes7 hAxes8 hEdit hBtn

x0=200;
y0=50;
w0=1100;
h0=700;
figure('Color',[1 1 1],'Position',[x0,y0,w0,h0])

x1=50;
y1=50;
dy=30;
dx=50;
w=250;
h=140;
hAxes6=axes('Units','pixels','Position',[x1,y1,w,h]);
hAxes3=axes('Units','pixels','Position',[x1,y1+h+dy,w,h]);
hAxes7=axes('Units','pixels','Position',[x1+w+dx,y1,w,h]);
hAxes4=axes('Units','pixels','Position',[x1+w+dx,y1+h+dy,w,h]);
hAxes8=axes('Units','pixels','Position',[x1+2*w+2*dx,y1,w,h]);
hAxes5=axes('Units','pixels','Position',[x1+2*w+2*dx,y1+h+dy,w,h]);
hAxes2=axes('Units','pixels','Position',[x1,y1+2*h+2*dy,w0-x1*2,h/2]);
hAxes1=axes('Units','pixels','Position',...
[x1,y1+2*h+3*dy+h/2,w0-x1*2,h0-(y1*2+2*h+3*dy+h/2)+20]);

x2=950;
y2=300;
w2=70;
h2=15;
hEdit=uicontrol('Style','edit','Position',[x2,y2,w2,h2],...
'Backgroundcolor',[1 1 1],'HorizontalAlignment','left');
hBtn=uicontrol('Style','pushbutton','String','Применить',...
'Position',[x2,y2-30,w2,h2],'Callback','Classtype');

% вывод сигнала в 1 окно
ECG=load('R08-04-1.txt');
Ver=load('R08-04-2.txt');
Fs=250;
N=length(ECG);
tmax=N/Fs;
T=1/Fs;
t=0:T:tmax-T;
axes(hAxes1);
plot(t,ECG);
grid minor;

% вывод порядковых номеров QRS-комплексов и идентификаторов во 2 окно
set(hAxes2,'XLim',[0 10]);
NQRS=length(Ver(:,1));
for i=1:NQRS
x=Ver(i,1)*T;
axes(hAxes2);
text(x,0.85,num2str(i));
text(x,0.6,num2str(Ver(i,2)),'Color','b');
end

% вывод образцов нормы и патологии QRS в окна 3 и 6
N0=1;
P0=2;
N1=3;
P1=5;
L=51;
Smax=(L-1)/2;
ind1=Ver(N0,1);
QRS_N0=ECG(ind1-Smax:ind1+Smax);
ind2=Ver(P0,1);
QRS_P0=ECG(ind2-Smax:ind2+Smax);
ind3=Ver(N1,1);
QRS_N1=ECG(ind3-Smax:ind3+Smax);
ind4=Ver(P1,1);
QRS_P1=ECG(ind4-Smax:ind4+Smax);
tc=-T*Smax:T:T*Smax;
axes(hAxes3);
plot(tc,QRS_N0);
grid minor;
ylim([-1,1]);
axes(hAxes6);
plot(tc,QRS_P0);
grid minor;
ylim([-1,1]);

% удаление линейного тренда
QRS_N0=detrend(QRS_N0);
QRS_P0=detrend(QRS_P0);
QRS_N1=detrend(QRS_N1);
QRS_P1=detrend(QRS_P1);

% построение графиков сравниваемых комплексов и их ВКФ
axes(hAxes5);
c=xcorr(QRS_N0,QRS_P1,Smax,'coeff');
plot(tc,QRS_N0)
hold on
plot(tc,QRS_P1,'g')
plot(tc,c,':r')
set(hAxes5,'YLim',[-1 1]);
grid minor
title('N-P');

axes(hAxes4);
c=xcorr(QRS_N0,QRS_N1,Smax,'coeff');
plot(tc,QRS_N0)
hold on
plot(tc,QRS_N1,'g')
plot(tc,c,':r')
set(hAxes4,'YLim',[-1 1]);
grid minor
title('N-N');

axes(hAxes7);
c=xcorr(QRS_P0,QRS_N1,Smax,'coeff');
plot(tc,QRS_P0)
hold on
plot(tc,QRS_N1,'g')
plot(tc,c,':r')
set(hAxes7,'YLim',[-1 1]);
grid minor
title('P-N');

axes(hAxes8);
c=xcorr(QRS_P0,QRS_P1,Smax,'coeff');
plot(tc,QRS_P0)
hold on
plot(tc,QRS_P1,'g')
plot(tc,c,':r')
set(hAxes8,'YLim',[-1 1]);
grid minor
title('P-P');

% создание массивов максимальых значений ВКФ
ds=5;
for i=1:NQRS
iQRS=Ver(i,1);
QRS=ECG(iQRS-Smax:iQRS+Smax);
QRS=detrend(QRS);
c=xcorr(QRS_N0,QRS,ds,'coeff');
cN(i)=max(c);
c1=xcorr(QRS_P0,QRS,ds,'coeff');
cP(i)=max(c1);
end
Соседние файлы в папке Лаба 8