2016-03-30 6 views
-3

Ich arbeite an EKG-Signalverarbeitung Da ich alle Daten von MATLAB sammeln muss, um es als Testsignal zu verwenden, finde ich es schwierig, die Annotationsdateien zu lesen, deren Erweiterung .atr ist.lesen EKG Annotation mit bih

Ich verwende MIT Arrhythmia database. Wie kann ich die Annotationsdateien lesen?

ich versucht, dieses

[ann,type,subtype,chan,num,comments] = rdann('102','atr'); 

aber ich bin die Länge des ann nicht sicher, ob ich richtig erhalten ist.

Antwort

0

auf der gegebenen Implementierung basiert here

Hier ist ein Code-Schnipsel eine Annotation-Datei zu lesen.

PATH= 'PATH TO DIRECTORY'; % path, where data are saved 

ATRFILE= '100.atr';   % attributes-file in binary format 
atrd= fullfile(PATH, ATRFILE);  % attribute file with annotation data 
fid3=fopen(atrd,'r'); 
A= fread(fid3, [2, inf], 'uint8')'; 
sfreq=A(2); 
fclose(fid3); 
SAMPLES2READ=1; 
ATRTIME=[]; 
ANNOT=[]; 
TIME=(0:(SAMPLES2READ-1))/sfreq; 
sa=size(A); 
saa=sa(1); 
i=1; 
while i<=saa 
    annoth=bitshift(A(i,2),-2); 
    if annoth==59 
     ANNOT=[ANNOT;bitshift(A(i+3,2),-2)]; 
     ATRTIME=[ATRTIME;A(i+2,1)+bitshift(A(i+2,2),8)+... 
       bitshift(A(i+1,1),16)+bitshift(A(i+1,2),24)]; 
     i=i+3; 
    elseif annoth==60 
     % nothing to do! 
    elseif annoth==61 
     % nothing to do! 
    elseif annoth==62 
     % nothing to do! 
    elseif annoth==63 
     hilfe=bitshift(bitand(A(i,2),3),8)+A(i,1); 
     hilfe=hilfe+mod(hilfe,2); 
     i=i+hilfe/2; 
    else 
     ATRTIME=[ATRTIME;bitshift(bitand(A(i,2),3),8)+A(i,1)]; 
     ANNOT=[ANNOT;bitshift(A(i,2),-2)]; 
    end; 
    i=i+1; 
end; 
ANNOT(length(ANNOT))=[];  % last line = EOF (=0) 
ATRTIME(length(ATRTIME))=[]; % last line = EOF 
clear A; 
ATRTIME= (cumsum(ATRTIME))/sfreq; 
ind= find(ATRTIME <= TIME(end)); 
ATRTIMED= ATRTIME(ind); 
ANNOT=round(ANNOT); 

ANNOT ist ein Array mit allen Anmerkungen