-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathload_dataset.m
699 lines (566 loc) · 23.3 KB
/
load_dataset.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load dataset and set as matrix with data and label vector:
% features selection
% select patients (optionally)
%
% Author: Mondejar Guerra, Victor M
% VARPA
% University of A Coruña
% 26 June 2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% .hea
% https://physionet.org/physiotools/wag/header-5.htm
% number of signals freq samples
% Gain ADC units per millivol (200)
% 11-bit resolution
% 1024 an offset such that its output was ADC units given an input exactly in the middle of its range
% -3609 and -27349 checksum!
% 2 360 650000
% 212 200 11 1024 960 -3609 0 MLII
% 212 200 11 1024 776 -27349 0 V1
function [data, label, signal_patients, db, index_per_record, selected_beat] = load_dataset(dataset_name,patient_list, window_l, window_r, morphology_type, use_HB, use_RR, use_normalized_RR, norm_RR, max_RR, remove_baseline, remove_high_freq, class_division, signals_used, align_R, use_ecgpuwave, use_construe)
% Example of use
% patients_train = [101, 106, 108, 109, 112, 114, 115, 116, 118, 119, 122, 124, 201, 203, 205, 207, 208, 209, 215, 220, 223, 230];
% patients_test = [100, 103, 105, 111, 113, 117, 121, 123, 200, 202, 210, 212, 213, 214, 219, 221, 222, 228, 231, 232, 233, 234];
% load_dataset('mitdb', patients_train, 90, 90, 3, true, false, false, false, true, true)
path_dataset = '/home/mondejar/dataset/ECG/';
full_path = [path_dataset, dataset_name, '/m_learning/'];
%full_path = ['/home/mondejar/Dropbox/ECG/code/'];
if window_l == 256
full_name_dataset = [full_path, 'data_'];
else
full_name_dataset = [full_path, 'data_w_', num2str(window_l), '_', num2str(window_r)];
end
if(max_RR == 1)
full_name_dataset = [full_name_dataset, '_max_RR'];
elseif max_RR == 2
full_name_dataset = [full_name_dataset, '_min_RR'];
end
if(remove_baseline)
full_name_dataset = [full_name_dataset, '_remove_baseline'];
end
if(remove_high_freq)
full_name_dataset = [full_name_dataset, '_remove_high_freq'];
end
if use_ecgpuwave
full_name_dataset = [full_name_dataset, '_ecgpuwave'];
end
if use_construe
full_name_dataset = [full_name_dataset, '_construe'];
end
disp(['loading', full_name_dataset]);
load(full_name_dataset);
signal_patients = [];
%signals_per_class{4} = [];
if(isempty(patient_list) == false)
datasetAux.patients = [];
subclasses{1} = {''};
for p=1:size(patient_list,2)
pos = find(db.patients == patient_list(p));
signal_patients(p) = size(db.signals{pos}, 2);
datasetAux.patients = [datasetAux.patients patient_list(p)];
datasetAux.signals{1, p} = db.signals{1, pos};
datasetAux.signals{2, p} = db.signals{2, pos};
datasetAux.classes{p} = db.classes{pos};
datasetAux.temporal_features{p} = db.temporal_features{pos};
if(use_HB)
datasetAux.HB_intervals{p} = db.HB_intervals{pos};
datasetAux.fiducial_points{p} = db.fiducial_points{pos};
else
datasetAux.selected_R{p} = db.selected_R{pos};
end
end
datasetAux.window_l = window_l; subclasses{1} = {''};
datasetAux.window_r = window_r;
db = datasetAux;
end
if( strcmp(dataset_name, 'mitdb'))
% Range of normalization depends on the info from .hea files!
%% Norm values in 0-1
max_Amp = 1024; % 2048 == [-1024, +1024]
min_Amp = -1024;
for(p = 1:size(db.signals, 2))
db.signals{1, p} = ([db.signals{1, p}] - min_Amp) / (max_Amp - min_Amp); % normalize between 0,1
db.signals{2, p} = ([db.signals{2, p}] - min_Amp) / (max_Amp - min_Amp); % normalize between 0,1
end
elseif( strcmp(dataset_name, 'incartdb'))
%% Norm values in 0-1
max_Amp = 4000;
min_Amp = -4000; subclasses{1} = {''};
for(p = 1:size(db.signals, 2))
%% TODO, revise that! how many signals we want to use with INCARTDB
db.signals{p} = ([db.signals{p}] - min_Amp) / (max_Amp - min_Amp); % normalize between 0,1
end
end
%% align R
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 1 Feature extraction (Create descriptor)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
db.features_wave = [];
%% no morphology
if (morphology_type == -1 )
features_wave{size(db.signals, 2)} = [];
db.features_wave = features_wave;
end
%% RAW Signal
if(sum(morphology_type == 0 ))
features_wave = [];
signals1 = [];
signals2 = []
if signals_used(1) == 1
signals1 = db.signals(1,:);
signals1 = [signals1{:}];
end
if signals_used(2) == 1
signals2 = db.signals(2,:);
signals2 = [signals2{:}];
end
features_wave = [signals1; signals2];
db.features_wave = features_wave;
end
%% Wave Signal
if(sum(morphology_type == 1 ))
% Wavelets
features_wave{size(db.signals, 2)} = [];
for(p = 1:size(db.signals, 2))
for(b =1:size(db.signals{1, p}, 2))
f_wave = [];
for s = 1:2
if signals_used(s)
%Daubechies
% Para size 181 usar un N en wavedec <= 7
% fix(log2(length(beat))) = 7
[C, L] = wavedec(db.signals{s, p}(:, b), 3, 'db1');
app_w = appcoef(C, L, 'db1', 3);
% [C, L] = wavedec(db.signals{s, p}(:, b), 2, 'db1');
% app_w = appcoef(C, L, 'db1', 2);
f_wave = [f_wave; app_w];
% Center app_w on its max?????
end
end
features_wave{p}(1:length(f_wave), b) = f_wave;
end
end
db.features_wave = features_wave;
end
%% HOS
if(sum(morphology_type == 3))
db_features = db.features_wave ;
% TODO transform signal to have zero-mean
% Compute the 2, 3 and 4 order statistics
% 30 lag
%lag = round(window_l/ 3); %30; % size of window for cumulants?¿
n_intervls = 6;
lag = round( (window_l + window_r )/ n_intervls);
flag = 0; % can take also the value = 1
features_wave = [];
% center the signal with the window of size = lag to compute each statistics
for(p = 1:size(db.signals, 2))
for(b =1:size(db.signals{1, p}, 2))
f_wave = [];
for s=1:2
if signals_used(s)
%features = zeros(5,3);
features = zeros(n_intervls-1,2);
for(n = 1:n_intervls - 1) % 5
% beat = db.signals{s}(:,b);
pose = lag * n;
interval = db.signals{s, p}((pose - lag/2):( pose + lag/2),b);
%pose = 1 + (lag * (n-1));
%interval = db.signals{s, p}(pose:((pose-1) + lag),b);
% 2 th
%features(n,1) = var(interval);
%if isnan(features(n,1))
% features(n,1) = 0.0;
%end
% 3 th
features(n,1) = skewness(interval);
%features(n,2) = skewness(interval);
if isnan(features(n,1))
features(n,1) = 0.0;
% features(n,2) = 0.0;
end
% 4-th
features(n,2) = kurtosis(interval);
%features(n,3) = kurtosis(interval);
if isnan(features(n,2))
features(n,2) = 0.0;
% features(n,3) = 0.0;
end
end
f_wave = [f_wave; features];
end
end
features_wave{p}(1:length(f_wave(:)), b) = f_wave(:);
end
if isempty(db_features)
db.features_wave{p} = features_wave{p};
else
db.features_wave{p} = [db_features{p}; features_wave{p}];
end
end
end
%% MULTIHOS
if(sum(morphology_type == 6))
db_features = db.features_wave ;
%% NEW HOS With 3 scales!!!
n_intervls = [6];%[6]
for ni=1:size(n_intervls, 2)
lag = round( (window_l + window_r )/ n_intervls(ni));
flag = 0; % can take also the value = 1
features_wave = [];
% center the signal with the window of size = lag to compute each statistics
for(p = 1:size(db.signals, 2))
for(b =1:size(db.signals{1, p}, 2))
f_wave = [];
for s=1:2
if signals_used(s)
%features = zeros(5,3);
features = zeros(n_intervls(ni)-1,2);
pose = 0;
for n = 1:(n_intervls(ni) - 1) % 5
% beat = db.signals{s}(:,b);
pose = lag * n; % pose + (lag / 2);
interval = db.signals{s, p}((pose - lag/2):( pose + lag/2),b); % ( 1+ (pose - lag/2):( pose + lag/2)-1,b);
%pose = 1 + (lag * (n-1));
%interval = db.signals{s, p}(pose:((pose-1) + lag),b);
% 2 th
%features(n,1) = var(interval);
%if isnan(features(n,1))
% features(n,1) = 0.0;
%end
% 3 th
features(n,1) = skewness(interval);
%features(n,2) = skewness(interval);
if isnan(features(n,1))
features(n,1) = 0.0;
% features(n,2) = 0.0;
end
% 4-th
features(n,2) = kurtosis(interval);
%features(n,3) = kurtosis(interval);
if isnan(features(n,2))
features(n,2) = 0.0;
% features(n,3) = 0.0;
end
end
f_wave = [f_wave; features];
end
end
features_wave{p}(1:length(f_wave(:)), b) = f_wave(:);
end
if isempty(db_features)
db.features_wave{p} = features_wave{p};
else
db.features_wave{p} = [db_features{p}; features_wave{p}];
end
end
end
end
%% my morphology
if(sum(morphology_type == 4))
% Distance from R-peak to most prominents fiducial points
% Adapta for V1-V5 ??? R is minimum then...
db_features = db.features_wave;
features_wave = [];
%% NOTE:
% Usar mas puntos en comparaciones? algun criterio basado en
% distribuciones, en general.. poder definir este descriptor de una
% manera matematica que quede mas vendible...y demostrar realmente su
% utilidad frente a no usarlo! o usar wavelets propuestos por otros
% trabajos.. es lo que me queda para vender como principal novedad en
% un posible paper (lo otro que si usar fusion (similar a otros
% trabajos) o incluso el oversampling, pueden quedar como pequeñas
% "novedades"...
% Realmente deberia basarme en las reglas que usen los medicos... o al
% menos usar como atributos la informacion que usen los medicos para
% diagnosticar una anomalia o no... ancho QRS, intervalo RR, presencia
% de P, distancia de PQ, ...
for(p = 1:size(db.signals, 2))
for(b =1:size(db.signals{1, p}, 2))
f_wave = [];
for s=1:2
if signals_used(s)
R_pos = 91;
% clean high freq noise
features = zeros(4, 1);
R_value = db.signals{s, p}(91, b);
x_values = zeros(4, 1);
y_values = zeros(4, 1);
% Obtain values and pos from the intervals
if s == 1
[y_values(1), x_values(1)] = max(db.signals{s, p}(1:40, b));
[y_values(2), x_values(2)] = min(db.signals{s, p}(75:85, b));
[y_values(3), x_values(3)] = min(db.signals{s, p}(95:105, b));
[y_values(4), x_values(4)] = max(db.signals{s, p}(150:181, b));
elseif s == 2
[y_values(1), x_values(1)] = min(db.signals{s, p}(1:40, b));
[y_values(2), x_values(2)] = max(db.signals{s, p}(75:85, b));
[y_values(3), x_values(3)] = max(db.signals{s, p}(95:105, b));
[y_values(4), x_values(4)] = min(db.signals{s, p}(150:181, b));
end
x_values(2) = x_values(2) + 74;
x_values(3) = x_values(3) + 94;
x_values(4) = x_values(4) + 149;
% Norm data before compute distance
x_max = max( [x_values; R_pos]);
y_max = max( [y_values; R_value]);
x_min = min( [x_values; R_pos]);
y_min = min( [y_values; R_value]);
R_pos = (R_pos - x_min) / (x_max - x_min);
R_value = (R_value - y_min) / (y_max - y_min);
for n = 1:4
x_values(n) = (x_values(n) - x_min) / (x_max - x_min);
y_values(n) = (y_values(n) - y_min) / (y_max - y_min);
x_diff = (R_pos - x_values(n)) ;
y_diff = R_value - y_values(n);
features(n) = norm([x_diff, y_diff]);
if isnan(features(n))
features(n) = 0.0;
end
end
% Add a feature that represent the difference between
% the next R-peak?
f_wave = [f_wave; features];
end
end
features_wave{p}(1:length(f_wave(:)), b) = f_wave(:);
end
if isempty(db_features)
db.features_wave{p} = features_wave{p};
else
db.features_wave{p} = [db_features{p}; features_wave{p}];
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
% Amplitude
if(sum(morphology_type == 5))
db_features = db.features_wave;
features_wave = [];
% center the signal with the window of size = lag to compute each statistics
for(p = 1:size(db.signals, 2))
for(b =1:size(db.signals{1, p}, 2))
f_wave = [];
for s=1:2
if signals_used(s)
if b > 1
pre = db.signals{s, p}(91, b-1);
else
pre = db.signals{s, p}(91, b);
end
if b+1 < size(db.signals{1, p}, 2)
post = db.signals{s, p}(91, b+1);
else
post = db.signals{s, p}(91, b);
end
features = [pre, db.signals{s, p}(91, b), post];
f_wave = [f_wave; features];
end
end
features_wave{p}(1:length(f_wave(:)), b) = f_wave(:);
end
if isempty(db_features)
db.features_wave{p} = features_wave{p};
else
db.features_wave{p} = [db_features{p}; features_wave{p}];
end
end
end
%% DTW
%if(sum(morphology_type == 6))
%end
% if(sum(morphology_type == 4))
% % Descriptor binario
%
% % Considerando ventanas equidistantes al centro se compara desde el
% % primero de la izquierda con el ultimo de la derecha hasta llegar al
% % centro... Si es mayor el punto de la izquierda se asigna un 1 sino un
% % 0. Si trabajmos con 90 y 90 puntos (a cada extremo) esto nos dejaria
% % con 90 valores binarios que podemos agrupar de 8 en 8 bits
% % 90/8 ~=11-12 valores enteros. Asi resumimos 180 valores en unos 12
% % valores enteros...
%
% bit_sets = 4;
%
% descriptor_size = ceil(window_l / bit_sets); % 8 (bits) we could use also * 4 bytes (int32) = 16 * 4 = 64
% descriptor_bit = [];
% descriptor_dec = [];
% features_wave{size(db.signals, 2)} = [];
% beat_size = size(db.signals{1}, 1);
% for(s = 1:size(db.signals, 2))
% for(b =1:size(db.signals{s}, 2))
% for(w =1:window_l)
% descriptor_bit(w) = db.signals{s}(w,b) > db.signals{s}(beat_size-w+1,b);
% end
% % Agrup to byte each 8 values
% for(d =1:descriptor_size)
% descriptor_dec(d) = bi2de(descriptor_bit( (((d-1)*bit_sets) + 1 ): (min( (d*bit_sets), size(descriptor_bit, 2))) ));
% end
% features_wave{s}(1:length(descriptor_dec), b) = descriptor_dec;
% end
% end
%
% end
%
% %% Shape Matching
% if(sum(morphology_type == 5))
% %Compute mean from interval = 10
% interval_size = 10;
%
% features_wave{size(db.signals, 2)} = [];
%
% for(s = 1:size(db.signals, 2))
% for(b =1:size(db.signals{s}, 2))
% index = 0;
% for(w=1:interval_size:size(db.signals{s}, 1))
% num_elems = min(w+interval_size, size(db.signals{s}, 1)) - w;
% if(num_elems > 0)
% index = index +1;
% mean_values(index) = sum( db.signals{s}(w:min(w+interval_size, size(db.signals{s}, 1)), b))/ num_elems;
% end
% end
% features_wave{s}(1:index, b) = mean_values;
% mean_values = [];
% end
% end
% end
%
% %% Hjorth
% if(sum(morphology_type == 6))
% features_wave{size(db.signals, 2)} = [];
%
% for(s = 1:size(db.signals, 2))
% for(b =1:size(db.signals{s}, 2))
%
% x0(1) = db.signals{s}(1, b);
% x0(2) = db.signals{s}(2, b);
% x0(3) = db.signals{s}(3, b);
%
% x1(1) = x0(2) - x0(1);
% x1(2) = x0(3) - x0(2);
%
% x2(1) = x1(2) - x1(1);
%
% for(w=4:size(db.signals{s}, 1))
% x0(w) = db.signals{s}(w, b);
% x1(w-1) = db.signals{s}(w, b) - db.signals{s}(w-1, b);
% x2(w-2) = x1(w-1) - x1(w-2);
% end
%
% % std(x, w): w = 1 -> then 1/N if not -> 1/(N-1)
% features_wave{s}(1:3, b) = [std(x0, 1), std(x0, 1), std(x0, 1)];
% end
% end
% end
num_classes = 4;
if class_division == 1 %zhang_class
subclasses{1} = {'N', 'L', 'R'};
subclasses{2} = {'A', 'a', 'J', 'S', 'e', 'j'};
subclasses{3} = {'V', 'E'};
subclasses{4} = {'F'};
%subclasses{5} = {'P', '/', 'f', 'u'};
elseif class_division == 2 %binary
num_classes = 2;
subclasses{1} = {'N', 'L', 'R'};
subclasses{2} = {'A', 'a', 'J', 'S', 'V', 'E', 'F', 'e', 'j'};
elseif class_division == 3 %considering all subclasses
num_classes = 12;
subclasses{1} = {'N'};
subclasses{2} = {'L'};
subclasses{3} = {'R'};
subclasses{4} = {'A'};
subclasses{5} = {'a'};
subclasses{6} = {'J'};
subclasses{7} = {'S'};
subclasses{8} = {'e'};
subclasses{9} = {'j'};
subclasses{10} = {'V'};
subclasses{11} = {'E'};
subclasses{12} = {'F'};
elseif class_division == 4 % my test maintaining only class that are similars to the super class or that contains enough number at train/test division
subclasses{1} = {'N'};
subclasses{2} = {'A', 'a'};
subclasses{3} = {'V'};
subclasses{4} = {'F'};
else % chazal
subclasses{1} = {'N', 'L', 'R', 'e', 'j'};
subclasses{2} = {'A', 'a', 'J', 'S'};
subclasses{3} = {'V', 'E'};
subclasses{4} = {'F'};
%subclasses{5} = {'P', '/', 'f', 'u'};
end
index_per_record{size(patient_list,2), num_classes} = [];
data = [];
label = [];
%test_label_per_record = [];
b_i = 0;
if(norm_RR)
max_temp_f = 1000;% definimos este valor suponiendo el max de valor temporal
else
max_temp_f = 1;
end
%tp_i = 0;
%if isempty(db.features_wave{p}) == false
for(p = 1:size(db.signals,2))
%% Compute AVG values
pre_R_avg = mean(db.temporal_features{p}.pre_R);
post_R_avg = mean(db.temporal_features{p}.post_R);
local_R_avg = mean(db.temporal_features{p}.local_R);
global_R_avg = mean(db.temporal_features{p}.global_R);
features_patient = db.features_wave{p};
if(use_RR)
features_patient = [features_patient;
db.temporal_features{p}.pre_R/ max_temp_f;
db.temporal_features{p}.post_R / max_temp_f;
db.temporal_features{p}.local_R / max_temp_f;
db.temporal_features{p}.global_R/ max_temp_f];
% Rhythm Labeling
% (Amp_pre, Amp_post, Amp, RR_interval, . )
% seven rhythm labels to discern between four beat rhythm types
end
if(use_normalized_RR)
features_patient = [features_patient; % And normalized_RR featureRR/avg(featureRR) *avg by patient
db.temporal_features{p}.pre_R / pre_R_avg;
db.temporal_features{p}.post_R / post_R_avg;
db.temporal_features{p}.local_R / local_R_avg;
db.temporal_features{p}.global_R / global_R_avg];
end
if(use_HB && use_ecgpuwave)
features_patient = [features_patient; % And normalized_RR featureRR/avg(featureRR) *avg by patient
db.HB_intervals{p}.qrs_durations;
db.HB_intervals{p}.t_durations;
db.HB_intervals{p}.t_nums;
db.HB_intervals{p}.qrs_t_spaces;
db.HB_intervals{p}.p_flags
db.HB_intervals{p}.heart_axis];
elseif( use_HB && use_construe)
features_patient = [features_patient; % And normalized_RR featureRR/avg(featureRR) *avg by patient
db.HB_intervals{p}.p_widths;
db.HB_intervals{p}.pq_intervals;
db.HB_intervals{p}.t_widths;
db.HB_intervals{p}.st_intervals;
db.HB_intervals{p}.qrs_widths];
end
data = [data [features_patient]];
end
%end
selected_beat = [];
for(p = 1:size(db.signals,2))
for(b=1:size(db.classes{p},2))
select = 0;
for(n=1:num_classes) % +1
if(sum(strcmp(db.classes{p}(b) , subclasses{n})))
label = [label n];
index_per_record{p,n} = [index_per_record{p,n}, b];
% signals_per_class{n} = [signals_per_class{n} db.signals{1,p}(:,b)];
% label_per_record{tp_i} = [label_per_record{tp_i} n]; % Only for test mitdb!!
select = 1;
end
end
selected_beat = [selected_beat, select];
end
end
data = data';
data = data(find(selected_beat == 1),:);
end