% VESCHNY HODNOTY DESKRIPTORU 36 SIGNALU
%vsechny signaly jsou na CD 
clear all
clc
close all
senz_spec=zeros(10,46);
Ar_vsechny_PVC=zeros(1,2);
Ar_vsechny_ostatni=zeros(1,2186);
Av1_vsechny_PVC=zeros(1,2);
Av1_vsechny_ostatni=zeros(1,2186);
pozitivpik_vsechny_PVC=zeros(1,2);
pozitivpik_vsechny_ostatni=zeros(1,2186);
negativpik_vsechny_PVC=zeros(1,2);
negativpik_vsechny_ostatni=zeros(1,2186);
plocha_vsechny_PVC=zeros(1,2);
plocha_vsechny_ostatni=zeros(1,2186);
plochaneg_vsechny_PVC=zeros(1,2);
plochaneg_vsechny_ostatni=zeros(1,2186);
widthh_vsechny_PVC=zeros(1,2);
widthh_vsechny_ostatni=zeros(1,2186);
imi_vsechny_PVC=zeros(1,2);
imi_vsechny_ostatni=zeros(1,2186);
ima_vsechny_PVC=zeros(1,2);
ima_vsechny_ostatni=zeros(1,2186);
sjedna_vsechny_PVC=zeros(1,2);
sjedna_vsechny_ostatni=zeros(1,2186);
sdva_vsechny_PVC=zeros(1,2);
sdva_vsechny_ostatni=zeros(1,2186);
Cpred_vsechny_PVC=zeros(1,2);
Cpred_vsechny_ostatni=zeros(1,2186);
Bpo_vsechny_PVC=zeros(1,2);
Bpo_vsechny_ostatni=zeros(1,2186);

save Ar_vsechny_PVC Ar_vsechny_PVC
save Ar_vsechny_ostatni Ar_vsechny_ostatni
save Av1_vsechny_PVC Av1_vsechny_PVC
save Av1_vsechny_ostatni Av1_vsechny_PVC
save pozitivpik_vsechny_PVC pozitivpik_vsechny_PVC
save pozitivpik_vsechny_ostatni pozitivpik_vsechny_ostatni
save negativpik_vsechny_PVC negativpik_vsechny_PVC
save negativpik_vsechny_ostatni negativpik_vsechny_ostatni
save plocha_vsechny_PVC plocha_vsechny_PVC
save plocha_vsechny_ostatni plocha_vsechny_ostatni
save plochaneg_vsechny_PVC plochaneg_vsechny_PVC
save plochaneg_vsechny_ostatni plochaneg_vsechny_ostatni
save widthh_vsechny_PVC widthh_vsechny_PVC
save widthh_vsechny_ostatni widthh_vsechny_ostatni
save imi_vsechny_PVC imi_vsechny_PVC
save imi_vsechny_ostatni imi_vsechny_ostatni
save ima_vsechny_PVC ima_vsechny_PVC
save ima_vsechny_ostatni ima_vsechny_ostatni
save sjedna_vsechny_PVC sjedna_vsechny_PVC
save sjedna_vsechny_ostatni sjedna_vsechny_ostatni
save sdva_vsechny_PVC sdva_vsechny_PVC
save sdva_vsechny_ostatni sdva_vsechny_ostatni
save Cpred_vsechny_PVC Cpred_vsechny_PVC
save Cpred_vsechny_ostatni Cpred_vsechny_ostatni
save Bpo_vsechny_PVC Bpo_vsechny_PVC
save Bpo_vsechny_ostatni Bpo_vsechny_ostatni
save senz_spec senz_spec
%4:49
% pro prohlizeni box plotu jednotliveho signalu zakomentovat rady skriptu 649-651 clear all clc close all a vybrat si signal treba q=7.
for q=4:49
files = dir;
directoryNames = {files([files.isdir]).name};
directoryNames = directoryNames(~ismember(directoryNames,{'.','..'}));
k=struct(files);
sign=files(q).name;
o=char(sign)
load(o)
load('senz_spec.mat')
load('Ar_vsechny_PVC.mat')
load('Ar_vsechny_ostatni.mat')
load('Av1_vsechny_PVC.mat')
load('Av1_vsechny_ostatni.mat')
load('pozitivpik_vsechny_PVC.mat')
load('pozitivpik_vsechny_ostatni.mat')
load('negativpik_vsechny_PVC.mat')
load('negativpik_vsechny_ostatni.mat')
load('plocha_vsechny_PVC.mat')
load('plocha_vsechny_ostatni.mat')
load('plochaneg_vsechny_PVC.mat')
load('plochaneg_vsechny_ostatni.mat')
load('widthh_vsechny_PVC.mat')
load('widthh_vsechny_ostatni.mat')
load('imi_vsechny_PVC.mat')
load('imi_vsechny_ostatni.mat')
load('ima_vsechny_PVC.mat')
load('ima_vsechny_ostatni.mat')
load('sjedna_vsechny_PVC.mat')
load('sjedna_vsechny_ostatni.mat')
load('sdva_vsechny_PVC.mat')
load('sdva_vsechny_ostatni.mat')
load('Cpred_vsechny_PVC.mat')
load('Cpred_vsechny_ostatni.mat')
load('Bpo_vsechny_PVC.mat')
load('Bpo_vsechny_ostatni.mat')

time = 1/360:1/360:tm(end,1);  %casova osa signalu v sekundach
[~,y1]=size(time);
% figure(1)
% plot(time,x(1:y1,1)) % zobrazeni 1. signalu
% xlabel('t[s]')
% ylabel('U[mV]')

%pozice a pocty ruznych patologii
[pozice_V]=find(type=='V');%pvc
%% pokud signal bude obsahovat 0 pocet PVC --> konec
if length(pozice_V)>0 
[pozice_N]=find(type=='N');%normalni
[pozice_x]=find(type=='x');
[pozice_R]=find(type=='R');%Right brunch bundle boundaries
[pozice_L]=find(type=='L');%Left brunch bundle boundaries
[pozice_J]=find(type=='J');%Junctional premature	
[pozice_j]=find(type=='j');%Junctional escape	
[pozice_F]=find(type=='F');%fusion pvc
[pozice_A]=find(type=='A');%APC
[pozice_plus]=find(type=='+'); %sum a dalsi
[pozice_vlnka]=find(type=='~');%sum a dalsi

pozice_V=(pozice_V)';
[y,~]=size(ann);
A=zeros(1,y);
Bpo=zeros(1,y);
Cpred=zeros(1,y);
Detekce=zeros(1,y);

for i=1:y 
A(i)=time(1,ann(i,1));
end

for j=3:length(ann)-2
Bpo(1,j)=A(j+1)-A(j); % deskriptor RR po aktualni pozice QRS
Cpred(1,j)=A(j)-A(j-1); % deskriptor RR pred aktualni pozice QRS
end 

for i=1:y
Rvse(i)=ann(i,1)   ;
% plot(time(1,Rvse(i)),x(Rvse(i),1),'*b');
end
% hold on
% plot(time(1,Rvse(3:20)),x(Rvse(3:20),1),'*b');
%vymena PVC na 1
for i=1:length(ann)-2
    if type(i,1)=='V'
type_1(i,1)=1;
else
    type_1(i,1)=2;
    end
end

%% Detekce zacatku QRS, 73 vzorku = 200ms , vypocet nejvetsi diference
for j=3:length(Rvse)-2
txR=time(1,Rvse(1,j));
tyR=x(Rvse(1,j),1);
tx=time(1,Rvse(1,j)-72);
ty=x(Rvse(1,j)-72,1);

xuyrok(1,1:73)=x(Rvse(1,j)-72:Rvse(1,j),1);
krok=(abs(xuyrok(1,1))+xuyrok(1,end))/73;
kroknasobeni(1,:)=[1:1:150];

for i=2:74
xrovnomerne(1,1)=x(Rvse(1,j)-72,1);
xrovnomerne(1,i)=xrovnomerne(1,1)+krok*kroknasobeni(1,i-1);
end

for i=1:73
diference(1,i)=abs(xrovnomerne(1,i)-(xuyrok(1,i)));
end
m=max(diference);
[~,ymaxl]=find(diference==m);
[~,maxl]=size(ymaxl);
if maxl>1
    ymaxl=ymaxl(1);
end
ymax=ymaxl;
dvesektime=time(1,Rvse(1,j)-(73-ymaxl));
% xx=[dvesektime,dvesektime];
% yy=[xuyrok(1,ymax),2];
% plot(xx,yy,'r')
% line([dvesektime,dvesektime],[xuyrok(1,ymax),2])
padsekbodtime=time(1,Rvse(1,j)-(73-ymax)-18);
padsekbodampl=x(Rvse(1,j)-(73-ymax)-18,1);
% xx=[padsekbodtime,dvesektime];
% yy=[padsekbodampl,xuyrok(1,ymax)];
% plot(xx,yy,'r')
% line([padsekbodtime,dvesektime ],[padsekbodampl,xuyrok(1,ymax)])
%% 19 vzorku = 50 ms, vypocet nejvetsi diference -> zacatek detekovan
krokpades=(abs(x(Rvse(1,j)-(73-ymax),1)-padsekbodampl))/18;
for i=2:19
rovnopades(1,1)=x(Rvse(1,j)-(73-ymax)-18,1);
rovnopades(1,i)=rovnopades(1,1)-krokpades*kroknasobeni(1,i-1);
% plot(time(Rvse(1,3)-72:Rvse(1,3)),xrovnomerne(1,i-1),'*r')
end
xpadesxyrok(1,1:19)=x(Rvse(1,j)-(73-ymax)-18:Rvse(1,j)-(73-ymax),1);
for i=1:19
diferencepades(1,i)=abs(rovnopades(1,i)-(xpadesxyrok(1,i)));
end
mpad=max(diferencepades);
[~,ymaxx]=find(diferencepades==mpad);
[~,maxx]=size(ymaxx);
if maxx>1
ymaxx=ymaxx(1);
end
ymaxpad=ymaxx;
onset(1,j)=time(1,Rvse(1,j)-(73-ymax)-(19-ymaxpad));
pozice_a1(1,j)=Rvse(1,j)-(73-ymax)-(19-ymaxpad);
[~,tim]=find(time==onset(1,j));
timm(1,j)=tim;
posun(1,j)=abs(x(timm(1,j),1));
%% vykreskeni cervenou hvezdickou zacatku QRS
% hold on
% plot(onset(1,j),x(Rvse(1,j)-(73-ymax)-(19-ymaxpad),1),'*r')

%% Detekce konce QRS, 90 vzorku = 248 ms a vypocet nejvetsi diference
a3=diff(x(Rvse(1,j):Rvse(1,j)+90,1));
mdvapet=max(a3);
[ymaxdvapet]=find(a3==mdvapet);
if length(ymaxdvapet)>1
    ymaxdvapet=ymaxdvapet(1);
end
dvapetktime=time(1,Rvse(1,j)+ymaxdvapet+19);
offsettime(1,j)=dvapetktime;
pozice_a2(1,j)=Rvse(1,j)+ymaxdvapet;
%% vykresleni konce QRS zelenou hvezdickou
% hold on
% plot(dvapetktime,x(Rvse(1,j)+ymaxdvapet,1),'*g')
end
%% kratke nazvy deskriptoru, viz tabulka 3.1 v BP
for j=3:length(Rvse)-2
pik(1,j)=x(Rvse(1,j),1);
if pik(1,j)>=0
    pozitivpik(1,j)=pik(1,j); %Pp   
    negativpik(1,j)=x(pozice_a2(1,j),1);
 else
     pozitivpik(1,j)=x(pozice_a2(1,j)+10,1);
     negativpik(1,j)=pik(1,j); %Pn
    end
end
for j=3:length(Rvse)-2
   if x(pozice_a1(1,j),1)>0  
        pozitivpik(1,j)=pozitivpik(1,j)-posun(1,j);
     negativpik(1,j)=negativpik(1,j)-posun(1,j); %Pn  
     if x(pozice_a1(1,j),1)<0 
         pozitivpik(1,j)=pozitivpik(1,j)+posun(1,j); %Pp   
    negativpik(1,j)=negativpik(1,j)+posun(1,j);
     if x(pozice_a1(1,j),1)==0 
         pozitivpik(1,j)=pozitivpik(1,j); %Pp   
    negativpik(1,j)=negativpik(1,j);
     end
   end
end         
delkaosnov(1,j)=time(1,Rvse(1,j))-onset(1,j);
delkapik(1,j)=pozitivpik(1,j);
gipot(1,j)=(delkaosnov(1,j)*delkapik(1,j))/2;
plocha(1,j)=abs(2*gipot(1,j)); % ArP

ima(1,j)=time(1,Rvse(1,j))-onset(1,j); % ima
sjedna(1,j)=sqrt((delkaosnov(1,j))^2+(pozitivpik(1,j))^2); % S1

negativpikabs(1,j)=abs(negativpik(1,j));
delkaosneg(1,j)=offsettime(1,j)-time(1,Rvse(j));
delkapikneg(1,j)=negativpikabs(1,j);
gipotneg(1,j)=(delkaosneg(1,j)*delkapikneg(1,j))/2;
plochaneg(1,j)=abs(2*gipotneg(1,j)); % ArN

imi(1,j)=dvapetktime-onset(1,j); % imi
sdva(1,j)=sqrt((dvapetktime-time(1,Rvse(1,j)))^2+(pozitivpik(1,j)+negativpikabs(1,j))^2);
[~,ons]=find(time==onset(1,j))  ;   
sdva(1,j)=sqrt((time(1,Rvse(j))-time(1,ons))^2+(pozitivpik(1,j)+negativpikabs(1,j))^2); % S2
%  sirka QRS
widthh(1,j)=offsettime(1,j)-onset(1,j);
end
% Ar
for i=1:length(plocha)
    Ar(1,i)=plocha(1,i)+plochaneg(1,i);
end
% Av1
for i=1:length(imi)
Av1(1,i)=ima(1,i)+imi(1,i);
end

if length(pozice_V)>0
%% boxplot Ar
for i=1:length(pozice_V)-2
Ar_u_PVC(1,i)=Ar(pozice_V(1,i));
Ar(pozice_V(1,i))=0;
end
j=1;
for i=1:length(Ar)
    if Ar(1,i)~=0
        Ar_ostatni(1,j)=Ar(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
Ar_vsechny_PVC=Ar_u_PVC;
Ar_vsechny_ostatni=Ar_ostatni;
else
kik=length(Ar_vsechny_PVC); 
hih=length(Ar_u_PVC);
Ar_vsechny_PVC(1,kik+1:kik+hih)=Ar_u_PVC;
kik2=length(Ar_vsechny_ostatni) ;
hih2=length(Ar_ostatni);
Ar_vsechny_ostatni(1,kik2+1:kik2+hih2)=Ar_ostatni;
end
end
%% boxplot Av1
for i=1:length(pozice_V)-2
Av1_u_PVC(1,i)=Av1(pozice_V(1,i));
Av1(pozice_V(1,i))=0;
end
j=1;
for i=1:length(Av1)
    if Av1(1,i)~=0
        Av1_ostatni(1,j)=Av1(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
Av1_vsechny_PVC=Av1_u_PVC;
Av1_vsechny_ostatni=Av1_ostatni;
else
v1=length(Av1_vsechny_PVC); 
vv=length(Av1_u_PVC);
Av1_vsechny_PVC(1,v1+1:v1+vv)=Av1_u_PVC;
v12=length(Av1_vsechny_ostatni) ;
vv2=length(Av1_ostatni);
Av1_vsechny_ostatni(1,v12+1:v12+vv2)=Av1_ostatni;
end
end
%% boxplot pozitivpik
for i=1:length(pozice_V)-2
pozitivpik_u_PVC(1,i)=pozitivpik(pozice_V(1,i));
pozitivpik(pozice_V(1,i))=0;
end
j=1;
for i=1:length(pozitivpik)
    if pozitivpik(1,i)~=0
        pozitivpik_ostatni(1,j)=pozitivpik(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
pozitivpik_vsechny_PVC=pozitivpik_u_PVC;
pozitivpik_vsechny_ostatni=pozitivpik_ostatni;
else
po1=length(pozitivpik_vsechny_PVC); 
po2=length(pozitivpik_u_PVC);
pozitivpik_vsechny_PVC(1,po1+1:po1+po2)=pozitivpik_u_PVC;
po12=length(pozitivpik_vsechny_ostatni) ;
pp2=length(pozitivpik_ostatni);
pozitivpik_vsechny_ostatni(1,po12+1:po12+pp2)=pozitivpik_ostatni;
end
end
%% boxplot negativpik
for i=1:length(pozice_V)-2
negativpik_u_PVC(1,i)=negativpik(pozice_V(1,i));
negativpik(pozice_V(1,i))=0;
end
j=1;
for i=1:length(negativpik)
    if negativpik(1,i)~=0
        negativpik_ostatni(1,j)=negativpik(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
negativpik_vsechny_PVC=negativpik_u_PVC;
negativpik_vsechny_ostatni=negativpik_ostatni;
else
kpn=length(negativpik_vsechny_PVC); 
hipn=length(negativpik_u_PVC);
negativpik_vsechny_PVC(1,kpn+1:kpn+hipn)=negativpik_u_PVC;
kpn2=length(negativpik_vsechny_ostatni) ;
hipn2=length(negativpik_ostatni);
negativpik_vsechny_ostatni(1,kpn2+1:kpn2+hipn2)=negativpik_ostatni;
end
end
%% boxplot plocha pozitiv. vzorku
for i=1:length(pozice_V)-2
plocha_u_PVC(1,i)=plocha(pozice_V(1,i));
plocha(pozice_V(1,i))=0;
end
j=1;
for i=1:length(plocha)
    if plocha(1,i)~=0
        plocha_ostatni(1,j)=plocha(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
plocha_vsechny_PVC=plocha_u_PVC;
plocha_vsechny_ostatni=plocha_ostatni;
else
kpl=length(plocha_vsechny_PVC); 
hipl=length(plocha_u_PVC);
plocha_vsechny_PVC(1,kpl+1:kpl+hipl)=plocha_u_PVC;
kpl2=length(plocha_vsechny_ostatni) ;
hipl2=length(plocha_ostatni);
plocha_vsechny_ostatni(1,kpl2+1:kpl2+hipl2)=plocha_ostatni;
end
end
%% boxplot plochaneg
for i=1:length(pozice_V)-2
plochaneg_u_PVC(1,i)=plochaneg(pozice_V(1,i));
plochaneg(pozice_V(1,i))=0;
end
j=1;
for i=1:length(plochaneg)
    if plochaneg(1,i)~=0
        plochaneg_ostatni(1,j)=plochaneg(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
plochaneg_vsechny_PVC=plochaneg_u_PVC;
plochaneg_vsechny_ostatni=plochaneg_ostatni;
else
kpln=length(plochaneg_vsechny_PVC); 
hipln=length(plochaneg_u_PVC);
plochaneg_vsechny_PVC(1,kpln+1:kpln+hipln)=plochaneg_u_PVC;
kpnl2=length(plochaneg_vsechny_ostatni) ;
hipnl2=length(plochaneg_ostatni);
plochaneg_vsechny_ostatni(1,kpnl2+1:kpnl2+hipnl2)=plochaneg_ostatni;
end
end
%% boxplot imi
for i=1:length(pozice_V)-2
imi_u_PVC(1,i)=imi(pozice_V(1,i));
imi(pozice_V(1,i))=0;
end
j=1;
for i=1:length(imi)
    if imi(1,i)~=0
        imi_ostatni(1,j)=imi(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
imi_vsechny_PVC=imi_u_PVC;
imi_vsechny_ostatni=imi_ostatni;
else
kpim=length(imi_vsechny_PVC); 
hiim=length(imi_u_PVC);
imi_vsechny_PVC(1,kpim+1:kpim+hiim)=imi_u_PVC;
kiml2=length(imi_vsechny_ostatni) ;
himl2=length(imi_ostatni);
imi_vsechny_ostatni(1,kiml2+1:kiml2+himl2)=imi_ostatni;
end
end
%% boxplot ima
for i=1:length(pozice_V)-2
ima_u_PVC(1,i)=ima(pozice_V(1,i));
ima(pozice_V(1,i))=0;
end
j=1;
for i=1:length(ima)
    if ima(1,i)~=0
        ima_ostatni(1,j)=ima(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
ima_vsechny_PVC=ima_u_PVC;
ima_vsechny_ostatni=ima_ostatni;
else
kpima=length(ima_vsechny_PVC); 
hiima=length(ima_u_PVC);
ima_vsechny_PVC(1,kpima+1:kpima+hiima)=ima_u_PVC;
kimal2=length(ima_vsechny_ostatni) ;
himal2=length(ima_ostatni);
ima_vsechny_ostatni(1,kimal2+1:kimal2+himal2)=ima_ostatni;
end
end
%% boxplot widthh
for i=1:length(pozice_V)-2
widthh_u_PVC(1,i)=widthh(pozice_V(1,i));
widthh(pozice_V(1,i))=0;
end
j=1;
for i=1:length(widthh)
    if widthh(1,i)~=0
        widthh_ostatni(1,j)=widthh(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
widthh_vsechny_PVC=widthh_u_PVC;
widthh_vsechny_ostatni=widthh_ostatni;
else
kpiwid=length(widthh_vsechny_PVC); 
hiiwid=length(widthh_u_PVC);
widthh_vsechny_PVC(1,kpiwid+1:kpiwid+hiiwid)=widthh_u_PVC;
kiwidl2=length(widthh_vsechny_ostatni) ;
hiwidl2=length(widthh_ostatni);
widthh_vsechny_ostatni(1,kiwidl2+1:kiwidl2+hiwidl2)=widthh_ostatni;
end
end
%% boxplot sjedna
for i=1:length(pozice_V)-2
sjedna_u_PVC(1,i)=sjedna(pozice_V(1,i));
sjedna(pozice_V(1,i))=0;
end
j=1;
for i=1:length(sjedna)
    if sjedna(1,i)~=0
        sjedna_ostatni(1,j)=sjedna(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
sjedna_vsechny_PVC=sjedna_u_PVC;
sjedna_vsechny_ostatni=sjedna_ostatni;
else
kpis=length(sjedna_vsechny_PVC); 
hiiwis=length(sjedna_u_PVC);
sjedna_vsechny_PVC(1,kpis+1:kpis+hiiwis)=sjedna_u_PVC;
kpisl2=length(sjedna_vsechny_ostatni) ;
hiiwisl2=length(sjedna_ostatni);
sjedna_vsechny_ostatni(1,kpisl2+1:kpisl2+hiiwisl2)=sjedna_ostatni;
end
end
%% boxplot sdva
for i=1:length(pozice_V)-2
sdva_u_PVC(1,i)=sdva(pozice_V(1,i));
sdva(pozice_V(1,i))=0;
end
j=1;
for i=1:length(sdva)
    if sdva(1,i)~=0
        sdva_ostatni(1,j)=sdva(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
sdva_vsechny_PVC=sdva_u_PVC;
sdva_vsechny_ostatni=sdva_ostatni;
else
kpisd=length(sdva_vsechny_PVC); 
hiiwisd=length(sdva_u_PVC);
sdva_vsechny_PVC(1,kpisd+1:kpisd+hiiwisd)=sdva_u_PVC;
kpisdl2=length(sdva_vsechny_ostatni) ;
hiiwisdl2=length(sdva_ostatni);
sdva_vsechny_ostatni(1,kpisdl2+1:kpisdl2+hiiwisdl2)=sdva_ostatni;
end
end
%% boxplot Cpred
for i=1:length(pozice_V)-2
Cpred_u_PVC(1,i)=Cpred(pozice_V(1,i));
Cpred(pozice_V(1,i))=0;
end
j=1;
for i=1:length(Cpred)
    if Cpred(1,i)~=0
        Cpred_ostatni(1,j)=Cpred(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
Cpred_vsechny_PVC=Cpred_u_PVC;
Cpred_vsechny_ostatni=Cpred_ostatni;
else
kpic=length(Cpred_vsechny_PVC); 
hiiwic=length(Cpred_u_PVC);
Cpred_vsechny_PVC(1,kpic+1:kpic+hiiwic)=Cpred_u_PVC;
kpicl2=length(Cpred_vsechny_ostatni) ;
hiiwicl2=length(Cpred_ostatni);
Cpred_vsechny_ostatni(1,kpicl2+1:kpicl2+hiiwicl2)=Cpred_ostatni;
end
end
%% boxplot Bpo
for i=1:length(pozice_V)-2
Bpo_u_PVC(1,i)=Bpo(pozice_V(1,i));
Bpo(pozice_V(1,i))=0;
end
j=1;
for i=1:length(Bpo)
    if Bpo(1,i)~=0
        Bpo_ostatni(1,j)=Bpo(1,i); 
        j=j+1;
    else
    end
end
if length(pozice_V)>2
if q==4
Bpo_vsechny_PVC=Bpo_u_PVC;
Bpo_vsechny_ostatni=Bpo_ostatni;
else
kpib=length(Bpo_vsechny_PVC); 
hiiwib=length(Bpo_u_PVC);
Bpo_vsechny_PVC(1,kpib+1:kpib+hiiwib)=Bpo_u_PVC;
kpibl2=length(Bpo_vsechny_ostatni) ;
hiiwibl2=length(Bpo_ostatni);
Bpo_vsechny_ostatni(1,kpibl2+1:kpibl2+hiiwibl2)=Bpo_ostatni;
end
end

save Ar_vsechny_PVC Ar_vsechny_PVC
save Ar_vsechny_ostatni Ar_vsechny_ostatni
save Av1_vsechny_PVC Av1_vsechny_PVC
save Av1_vsechny_ostatni Av1_vsechny_ostatni
save pozitivpik_vsechny_PVC pozitivpik_vsechny_PVC
save pozitivpik_vsechny_ostatni pozitivpik_vsechny_ostatni
save negativpik_vsechny_PVC negativpik_vsechny_PVC
save negativpik_vsechny_ostatni negativpik_vsechny_ostatni
save plocha_vsechny_PVC plocha_vsechny_PVC
save plocha_vsechny_ostatni plocha_vsechny_ostatni
save plochaneg_vsechny_PVC plochaneg_vsechny_PVC
save plochaneg_vsechny_ostatni plochaneg_vsechny_ostatni
save imi_vsechny_PVC imi_vsechny_PVC
save imi_vsechny_ostatni imi_vsechny_ostatni
save ima_vsechny_PVC ima_vsechny_PVC
save ima_vsechny_ostatni ima_vsechny_ostatni
save widthh_vsechny_PVC widthh_vsechny_PVC
save widthh_vsechny_ostatni widthh_vsechny_ostatni
save sjedna_vsechny_PVC sjedna_vsechny_PVC
save sjedna_vsechny_ostatni sjedna_vsechny_ostatni
save sdva_vsechny_PVC sdva_vsechny_PVC
save sdva_vsechny_ostatni sdva_vsechny_ostatni
save Cpred_vsechny_PVC Cpred_vsechny_PVC
save Cpred_vsechny_ostatni Cpred_vsechny_ostatni
save Bpo_vsechny_PVC Bpo_vsechny_PVC
save Bpo_vsechny_ostatni Bpo_vsechny_ostatni
clear all
clc
close all
end
else
%     sprintf('spuste,prosim,dalsi signal,v tomto signalu PVC nejsou')
%     senz_spec(:,q-3)=0; % signal neobsahuje PVC
%     save senz_spec senz_spec
end
end

load('Ar_vsechny_PVC')
load('Ar_vsechny_ostatni')
load('Av1_vsechny_PVC')
load('Av1_vsechny_ostatni')
load('pozitivpik_vsechny_PVC')
load('pozitivpik_vsechny_ostatni')
load('negativpik_vsechny_PVC')
load('negativpik_vsechny_ostatni')
load('plocha_vsechny_PVC')
load('plocha_vsechny_ostatni')
load('plochaneg_vsechny_PVC')
load('plochaneg_vsechny_ostatni')
load('imi_vsechny_PVC')
load('imi_vsechny_ostatni')
load('ima_vsechny_PVC')
load('ima_vsechny_ostatni')
load('widthh_vsechny_PVC')
load('widthh_vsechny_ostatni')
load('sjedna_vsechny_PVC')
load('sjedna_vsechny_ostatni')
load('sdva_vsechny_PVC')
load('sdva_vsechny_ostatni')
load('Cpred_vsechny_PVC')
load('Cpred_vsechny_ostatni')
load('Bpo_vsechny_PVC')
load('Bpo_vsechny_ostatni')
%%  boxplot Ar
Ar_vsechny_PVC(Ar_vsechny_PVC==0)=[];
Ar_vsechny_ostatni(Ar_vsechny_ostatni==0)=[];
figure(2)
x1 = (Ar_vsechny_PVC)';
x2 = (Ar_vsechny_ostatni)';
xx = [x1;x2];
gi = [ones(size(x1)); 2*ones(size(x2))];
boxplot(xx,gi,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Ar')
%%  boxplot Av1
Av1_vsechny_PVC(Av1_vsechny_PVC==0)=[];
Av1_vsechny_ostatni(Av1_vsechny_ostatni==0)=[];
figure(3)
x11 = (Av1_vsechny_PVC)';
x22 = (Av1_vsechny_ostatni)';
xxx = [x11;x22];
gig = [ones(size(x11)); 2*ones(size(x22))];
boxplot(xxx,gig,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Av1')

%%  boxplot pozitivpik Pp
pozitivpik_vsechny_PVC(pozitivpik_vsechny_PVC==0)=[];
pozitivpik_vsechny_ostatni(pozitivpik_vsechny_ostatni==0)=[];
figure(4)
p11 = (abs(pozitivpik_vsechny_PVC))';
p22 = (abs(pozitivpik_vsechny_ostatni))';
xxp = [p11;p22];
gip = [ones(size(p11)); 2*ones(size(p22))];
boxplot(xxp,gip,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Pp')
%%  boxplot negativpik Pn
negativpik_vsechny_PVC(negativpik_vsechny_PVC==0)=[];
negativpik_vsechny_ostatni(negativpik_vsechny_ostatni==0)=[];
figure(5)
n11 = (negativpik_vsechny_PVC(negativpik_vsechny_PVC<0))';
n22 = (negativpik_vsechny_ostatni(negativpik_vsechny_ostatni<0))';
xxcpk = [n11;n22];
gipk = [ones(size(n11)); 2*ones(size(n22))];
boxplot(xxcpk,gipk,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Pn')
%%  boxplot plocha pozitivnich vzorku ArP
plocha_vsechny_PVC(plocha_vsechny_PVC==0)=[];
plocha_vsechny_ostatni(plocha_vsechny_ostatni==0)=[];
figure(6)
p11p = (plocha_vsechny_PVC)';
p22p = (plocha_vsechny_ostatni)';
xxpp = [p11p;p22p];
gipp = [ones(size(p11p)); 2*ones(size(p22p))];
boxplot(xxpp,gipp,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('ArP')
%%  boxplot plocha negativnich vzorku ArN
plochaneg_vsechny_PVC(plochaneg_vsechny_PVC==0)=[];
plochaneg_vsechny_ostatni(plochaneg_vsechny_ostatni==0)=[];
figure(7)
p11pn = (plochaneg_vsechny_PVC)';
p22pn = (plochaneg_vsechny_ostatni)';
xxpn = [p11pn;p22pn];
gippn = [ones(size(p11pn)); 2*ones(size(p22pn))];
boxplot(xxpn,gippn,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('ArN')
%%  boxplot imi
imi_vsechny_PVC(imi_vsechny_PVC==0)=[];
imi_vsechny_ostatni(imi_vsechny_ostatni==0)=[];
figure(8)
p11imi = (imi_vsechny_PVC)';
p22ima = (imi_vsechny_ostatni)';
xximi = [p11imi;p22ima];
giimi = [ones(size(p11imi)); 2*ones(size(p22ima))];
boxplot(xximi,giimi,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Imi')
%%  boxplot ima
ima_vsechny_PVC(ima_vsechny_PVC==0)=[];
ima_vsechny_ostatni(ima_vsechny_ostatni==0)=[];
figure(9)
p11ima = (ima_vsechny_PVC)';
p22imaa = (ima_vsechny_ostatni)';
xxima = [p11ima;p22imaa];
giima = [ones(size(p11ima)); 2*ones(size(p22imaa))];
boxplot(xxima,giima,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Ima')
%%  boxplot sjedna
sjedna_vsechny_PVC(sjedna_vsechny_PVC==0)=[];
sjedna_vsechny_ostatni(sjedna_vsechny_ostatni==0)=[];
figure(10)
p11ijedna = (sjedna_vsechny_PVC)';
p22ijedna = (sjedna_vsechny_ostatni)';
xxijedna = [p11ijedna;p22ijedna];
giijedna = [ones(size(p11ijedna)); 2*ones(size(p22ijedna))];
boxplot(xxijedna,giijedna,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('S1')
%%  boxplot  sdva
sdva_vsechny_PVC(sdva_vsechny_PVC==0)=[];
sdva_vsechny_ostatni(sdva_vsechny_ostatni==0)=[];
figure(11)
p11idva = (sdva_vsechny_PVC)';
p22idva = (sdva_vsechny_ostatni)';
xxidva = [p11idva;p22idva];
giidva = [ones(size(p11idva)); 2*ones(size(p22idva))];
boxplot(xxidva,giidva,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('S2')
%%  boxplot Cpred
Cpred_vsechny_PVC(Cpred_vsechny_PVC==0)=[];
Cpred_vsechny_ostatni(Cpred_vsechny_ostatni==0)=[];
figure(12)
p11icpred = (Cpred_vsechny_PVC)';
p22icpred = (Cpred_vsechny_ostatni)';
xxicpred = [p11icpred;p22icpred];
giicpred = [ones(size(p11icpred)); 2*ones(size(p22icpred))];
boxplot(xxicpred,giicpred,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Interval pred R pikem')
%%  boxplot Bpo
Bpo_vsechny_PVC(Bpo_vsechny_PVC==0)=[];
Bpo_vsechny_ostatni(Bpo_vsechny_ostatni==0)=[];
figure(13)
p11ibpo = (Bpo_vsechny_PVC)';
p22ibpo = (Bpo_vsechny_ostatni)';
xxicbpo = [p11ibpo;p22ibpo];
giicpbpo = [ones(size(p11ibpo)); 2*ones(size(p22ibpo))];
boxplot(xxicbpo ,giicpbpo,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('Interval po R piku')
%%  boxplot sirka QRS
widthh_vsechny_PVC(widthh_vsechny_PVC==0)=[];
widthh_vsechny_ostatni(widthh_vsechny_ostatni==0)=[];
figure(14)
p11iwidthh = (widthh_vsechny_PVC)';
p22iwidthh = (widthh_vsechny_ostatni)';
xxiwidthh = [p11iwidthh;p22iwidthh];
giiwidthh = [ones(size(p11iwidthh)); 2*ones(size(p22iwidthh))];
boxplot(xxiwidthh ,giiwidthh,'labels',{'Komorove extrasystoly' 'Ostatni'})
title('sirka QRS')
%%



