Detecting and Quantifying T-Wave Alternans: The PhysioNet/Computing in Cardiology Challenge 2008 1.0.0
(1,848 bytes)
Rcount=Rcount-1;
RR=diff(R)*2;
R = circshift(R.',-1);
MeanRR=mean(RR);
for ii=1:60
ExCoef(ii)=1-0.15+ii/100;
end;
Tint=double(int32(MeanRR/5)); %T-wave interval length
Tstart=double(int32(MeanRR/17)); %T-wave interval start
ModelT(1:Tint,1)=[1:Tint];
ModelT(1:Tint,2)=0;
for ii=1:NrofLead
for i=1:Tint
ModelT(i,2)=ModelT(i,2)+EKG((R(1)+i+Tstart),ii)^2;
end;
end;
ExCoefG(1)=1;
xt=[1:Tint];
for j=2:Rcount
% for j=2:2
Tt(1:Tint,1)=[1:Tint];
Tt(1:Tint,2)=0;
for ii=1:NrofLead
for i=1:Tint
Tt(i,2)=Tt(i,2)+EKG((R(j)+i+Tstart),ii)^2;
end;
end;
for ii=1:60
Tt1(1:Tint,1)=Tt(1:Tint,1)*ExCoef(ii);
xt=double([1:Tint]);
T1(1:Tint,ii)=interp1(Tt1(1:Tint,1),Tt(1:Tint,2),xt,'spline','extrap');
CC=corrcoef(T1(:,ii),ModelT(:,2));
MaxC(ii)=CC(2,1);
end;
[C,I]=max(MaxC);
ExCoefG(j)=ExCoef(I);
ModelT(:,2)=(ModelT(:,2)+T1(:,I))/2;
Tt1(1:rint,1)=Tt(1:rint,1);
if ExCoefG(j)<=1
Tt1(3:rint-2,1)=Tt(3:rint-2,1)*ExCoefG(j);
else
Tt1(3:rint,1)=Tt(3:rint,1)*ExCoefG(j);
end;
xt=[1:Tint];
for ii=1:NrofLead
Tt(1:Tint,2)=EKG((R(j)+Tstart):(R(j)+Tstart)+Tint-1,ii);
Tder(1:Tint,ii)=interp1(Tt1(1:Tint,1),Tt(1:Tint,2),xt,'spline','extrap');
TderPr=mean(Tder(1:10,ii));
TderPb=mean(Tder(Tint-10:Tint,ii));
for i=1:Tint
TderCor(i,1)=TderPr+(i-1)*((TderPb-TderPr)/Tint);
end;
Tder(:,ii)=Tder(:,ii)-TderCor;
T((ii-1)*Tint+1:ii*Tint,j)=Tder(:,ii);
Tcon((j-1)*Tint+1:j*Tint,ii)=Tder(:,ii);
end;
end;
for ii=1:NrofLead
Tt(1:Tint,2)=EKG((R(1)+Tstart):(R(1)+Tstart)+Tint-1,ii);
T((ii-1)*Tint+1:ii*Tint,1)=Tt(:,2);
Tcon(1:Tint,ii)=Tt(1:Tint,2);
end;