-
Notifications
You must be signed in to change notification settings - Fork 0
/
printRegisterTable_15_classes.m
257 lines (213 loc) · 8.28 KB
/
printRegisterTable_15_classes.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
% Autores : Eduardo Luz
% Função : Imprime tabele de registros em arquivo
function printRegisterTable_15_classes(file_path)
s = char(file_path);
fileNamed = ['results\',s(10:end-1),'\regTable_15_classes.tex'];
arq = fopen(fileNamed,'w');
dataset1 = {'101';'106';'108';'109';'112';'114';'115';'116';'118';'119';'122';'124';'201';'203';'205';'207';'208';'209';'215';'220';'223';'230'};
dataset2 = {'100';'103';'105';'111';'113';'117';'121';'123';'200';'202';'210';'212';'213';'214';'219';'221';'222';'228';'231';'232';'233';'234'};
%----------------- inicializacao das variaveis
dados1 = [];
rotulo1 = [];
dados2 = [];
rotulo2 = [];
%-------------------------------
% Tabela latex dos registros
fprintf(arq,'\\documentclass{article}\n');
fprintf(arq,'\\usepackage{graphicx}\n');
fprintf(arq,'\\usepackage[latin1]{inputenc}\n');
fprintf(arq,'\\usepackage{tabularx}\n');
fprintf(arq,'\\usepackage{multirow}\n');
fprintf(arq,'\\usepackage[dvips]{color}');
fprintf(arq,'\\usepackage{colortab}');
fprintf(arq,'\\definecolor{lightgray}{gray}{0.8}');
fprintf(arq,'\\definecolor{darkgray}{gray}{0.5}');
fprintf(arq,'\\newcommand{\\lgray}{\\color{lightgray}}');
fprintf(arq,'\\newcommand{\\dgray}{\\color{darkgray}}');
fprintf(arq,'\\newcommand{\\citep}{\\cite}\n');
fprintf(arq,'\\newcommand{\\citet}{\\cite}\n');
fprintf(arq,'\\newcommand{\\TFigure}{Fig.}\n');
fprintf(arq,'\\begin{document}\n');
fprintf(arq,'\n');
fprintf(arq,'\\begin{table*} \n');
fprintf(arq,'\\footnotesize \n');
s2 = char('\\caption{Tebela dos registros do método ');
s2 = [s2 s(10:end-1) '} \n'];
fprintf(arq,s2);
%fprintf(arq,' \\caption{Tebela dos registros do método} \n');
fprintf(arq,' \\label{tab:regtable} \n');
fprintf(arq,' \\begin{center} \n');
fprintf(arq,' \\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n');
fprintf(arq,' \\hline \n');
fprintf(arq,' Registro & N & L & R & j & e & A & a & S & J & V & E & F & f & pace & Q & Total \\\\ \n');
fprintf(arq,' \\hline \n');
%carrega dos arquivos e separa apenas os batimentos desejados
for i=1:size(dataset1,1)
% if nargin < 4
% dataset1(i) = str2double(dataset1(i));
% end
filename = strcat(dataset1(i),'.txt');
filename = strcat(file_path,filename);
[data target] = loadarq(char(filename));
sizeClass = [];
for tt=1:15
sizeClass(tt) = size(find(target(:,tt)==1),1);
end
%sN = size(find(target(:,1)==1),1);
%sSVEB = size(find(target(:,2)==1),1);
%sVEB = size(find(target(:,3)==1),1);
%sF = size(find(target(:,4)==1),1);
%sQ = size(find(target(:,5)==1),1);
total = sum(sizeClass);
fprintf(arq,'\\textbf{ %6d }',str2double(dataset1(i)));
for tt=1:15
fprintf(arq,'& %6.0f ',sizeClass(tt));
end
fprintf(arq,'& %6.0f \\\\ \n',total);
%& %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f \\\\ \n', str2double(dataset2(i)), sN, sSVEB, sVEB, sF, sQ, total );
fprintf(arq,'\n');
dados1 = [dados1;data];
rotulo1 = [rotulo1;target];
end
fprintf(arq,' \\hline \n');
fprintf(arq,' \\hline \n');
for i=1:size(dataset2,1)
% if nargin < 4
% dataset2(i) = str2double(dataset2(i));
% end
filename = strcat(dataset2(i),'.txt');
filename = strcat(file_path,filename);
[data target] = loadarq(char(filename));
sizeClass = [];
for tt=1:15
sizeClass(tt) = size(find(target(:,tt)==1),1);
end
%sN = size(find(target(:,1)==1),1);
%sSVEB = size(find(target(:,2)==1),1);
%sVEB = size(find(target(:,3)==1),1);
%sF = size(find(target(:,4)==1),1);
%sQ = size(find(target(:,5)==1),1);
total = sum(sizeClass);
fprintf(arq,'%6d ', str2double(dataset2(i)));
for tt=1:15
fprintf(arq,'& %6.0f ',sizeClass(tt));
end
fprintf(arq,'& %6.0f \\\\ \n',total);
%& %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f \\\\ \n', str2double(dataset2(i)), sN, sSVEB, sVEB, sF, sQ, total );
fprintf(arq,'\n');
dados2 = [dados2;data];
rotulo2 = [rotulo2;target];
end
fprintf(arq,' \\hline \n');
fprintf(arq,' \\hline \n');
%fprintf(arq,' \\begin{tabular}{|c|c|c|c|c|c|} \n')
%fprintf(arq,'DS1 & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f\\\\ \n', sN1, sSVEB1, sVEB1, sF1, sQ1, total1 );
for tt=1:15
sizeClass1(tt) = size(find(rotulo1(:,tt)==1),1);
end
total1 = sum(sizeClass1);
fprintf(arq,'\\textbf{ DS1 }');
for tt=1:15
fprintf(arq,'& %6.0f ',sizeClass1(tt));
end
fprintf(arq,'& %6.0f \\\\ \n',total1);
%& %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f \\\\ \n', str2double(dataset2(i)), sN, sSVEB, sVEB, sF, sQ, total );
fprintf(arq,'\n');
for tt=1:15
sizeClass2(tt) = size(find(rotulo2(:,tt)==1),1);
end
total2 = sum(sizeClass2);
fprintf(arq,'DS2');
for tt=1:15
fprintf(arq,'& %6.0f ',sizeClass2(tt));
end
fprintf(arq,'& %6.0f \\\\ \n',total2);
fprintf(arq,'\n');
%fprintf(arq,'TOTAL & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f & %6.0f\\\\ \n ' , sN1+sN2, sSVEB1+sSVEB2, sVEB1+sVEB2, sF1+sF2, sQ1+sQ2, total1+total2 );
fprintf(arq,'TOTAL');
for tt=1:15
fprintf(arq,'& %6.0f ',sizeClass1(tt)+sizeClass2(tt));
end
fprintf(arq,'& %6.0f \\\\ \n',total1+total2);
fprintf(arq,'\n');
fprintf(arq,' \\hline \n');
fprintf(arq,' \\end{tabular} \n');
fprintf(arq,' \\end{center} \n');
fprintf(arq,'\\end{table*} \n');
fprintf(arq,'\n');
fprintf(arq,'\n');
fprintf(arq,'\\end{document}\n');
fclose(arq);
end
%-------------------- Função de separação dos tipos
% os rótulos estão em ascii code
% Seguindo o padrão AAMI heartbeat classes, Normal (N), supraventricular
% ectopic beat (SVEB), Ventricular ectopic beat(VEB), fusion beat(F) e
% unknown beat (Q)
%
function [data target]=loadarq(arq)
amostra = load(arq);
tam = size(amostra,2);
pos = find(amostra(:,tam)==78); % N -> N
N = amostra(pos,1:tam-1);
sz = size(N,1);
tN = repmat([1 0 0 0 0 0 0 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==76); % L -> N
L = amostra(pos,1:tam-1);
sz = size(L,1);
tL = repmat([0 1 0 0 0 0 0 0 0 0 0 0 0 0 00],sz,1);
pos = find(amostra(:,tam)==82); % R -> N
R = amostra(pos,1:tam-1);
sz = size(R,1);
tR = repmat([0 0 1 0 0 0 0 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==106); % j -> N
j = amostra(pos,1:tam-1);
sz = size(j,1);
tj = repmat([0 0 0 1 0 0 0 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==101); % e -> N
e = amostra(pos,1:tam-1);
sz = size(e,1);
te = repmat([0 0 0 0 1 0 0 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==65); % A -> SVEB
A = amostra(pos,1:tam-1);
sz = size(A,1);
tA = repmat([0 0 0 0 0 1 0 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==97); % a -> SVEB
a = amostra(pos,1:tam-1);
sz = size(a,1);
ta = repmat([0 0 0 0 0 0 1 0 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==83); % S -> SVEB
S = amostra(pos,1:tam-1);
sz = size(S,1);
tS = repmat([0 0 0 0 0 0 0 1 0 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==74); % J -> SVEB
J = amostra(pos,1:tam-1);
sz = size(J,1);
tJ = repmat([0 0 0 0 0 0 0 0 1 0 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==86); % V -> VEB
V = amostra(pos,1:tam-1);
sz = size(V,1);
tV = repmat([0 0 0 0 0 0 0 0 0 1 0 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==69); % E -> VEB
E = amostra(pos,1:tam-1);
sz = size(E,1);
tE = repmat([0 0 0 0 0 0 0 0 0 0 1 0 0 0 0],sz,1);
pos = find(amostra(:,tam)==70); % F -> F
F = amostra(pos,1:tam-1);
sz = size(F,1);
tF = repmat([0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 ],sz,1);
pos = find(amostra(:,tam)==102); % f -> Q
f = amostra(pos,1:tam-1);
sz = size(f,1);
tf = repmat([0 0 0 0 0 0 0 0 0 0 0 0 1 0 0],sz,1);
pos = find(amostra(:,tam)==47); % paced (/) -> Q
P = amostra(pos,1:tam-1);
sz = size(P,1);
tP = repmat([0 0 0 0 0 0 0 0 0 0 0 0 0 1 0],sz,1);
pos = find(amostra(:,tam)==81); % Q -> Q
Q = amostra(pos,1:tam-1);
sz = size(Q,1);
tQ = repmat([0 0 0 0 0 0 0 0 0 0 0 0 0 0 1],sz,1);
data = [N;L;R;A;V;P;a;F;S;j;f;E;J;e;Q];
target = [tN;tL;tR;tA;tV;tP;ta;tF;tS;tj;tf;tE;tJ;te;tQ];
end