-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_signiWCO.m
144 lines (133 loc) · 5.35 KB
/
test_signiWCO.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
nSurr = 33;
ts = 0.1;
%% FourierFactor Centerfrequency and Scale
ga=3;
be=20;
load('test_cwt_equal_JoVe.mat');
x1 = filtert_p1.hbo(:,1);
x2 = filtert_p2.hbo(:,12);
% test periods
% [WX1,scales_J,periods_J,coi1,time1] = CWT(x1, ...
% 'wave_normalization', 'bandpass',...
% 'morse_space', 'ag_manuel',...
% 'K', 1, ...
% 'be', 20,...
% 'source', 'J');
% [WX1,scales_Matlab,periods_Matlab,coi1,time1] = CWT(x1, ...
% 'be', 20,...
% 'source', 'Matlab');
% scales_Matlab = flipud(scales_Matlab);
% figure;
% plot(periods_Matlab,'DisplayName','Matlab');hold on;
% plot(periods_J,'DisplayName','Jlab');hold on;
% delta = periods_Matlab-periods_J;
% sum(delta)
% plot(delta,'DisplayName','Delta');hold off;
% figure;
% plot(scales_Matlab,'DisplayName','Matlab');hold on;
% plot(scales_J,'DisplayName','Jlab');hold on;
% delta = scales_Matlab-scales_J;
% sum(delta)
% plot(delta,'DisplayName','Delta');hold off;
%
% figure;
% Frq_mat = centfrq('morl', 8, 'plot')./scales_Matlab;
% f = centfrq('morl')./(scales_Matlab.*ts); % normalized to [samples/s]
% [peak_freq_J, energy_freq_J ,inst_freq_J]=morsefreq(ga,be); % in rad/s
% peak_freq_J = peak_freq_J /(2*pi*ts); %
% Frq_J = peak_freq_J./(scales_J.*ts); % normalized to [samples/s]
% [energy_freq ,inst_freq, peak_freq] = gmw_peakf(ga,be);
% peak_freq = peak_freq/(2*pi*ts); % in Hz
% inst_freq = inst_freq/(2*pi*ts); % in Hz
% energy_freq = energy_freq/(2*pi*ts); % in Hz
% Frq_G = peak_freq./(scales_J.*ts); % [samples/s]
% figure;
% plot(Frq_mat,'DisplayName','Matlab');hold on;
% plot(Frq_J,'DisplayName','Jlab');hold on;
% plot(Frq_G,'DisplayName','G');hold off;
%
% test_matlab = flipud(1./Frq_mat) - flipud(periods_Matlab'); % kann matlab sein ergebnis rekonstruieren (sollte 0 sein)
% test_J = flipud(1./Frq_G) - flipud(periods_J');
% figure;
% plot(test_matlab,'DisplayName','Matlab');hold on;
% plot(test_J,'DisplayName','Jlab');hold off;
% morsespace -- > rad / sample pointtest
%% Simulation
figure;
wcoherence(x1, x2,10,'numscales',16);
[x1, x2, labels_vec, rect_vec, labels_shifted_vec] = LISS(x1,x2, ...
'filter','bandstop',...
'shift_time', 0,...
'shift_freq', 0.1,...
'snr',1,...
'T', [100, 110, 120, 200, 200, 500],... % periodlength of short RECT (see HDR duration)
'tr', [500, 800, 1100, 1500, 2000, 2800],... % translatation of short RECT
'disp_info',true);
figure;
wcoherence(x1, x2,10,'numscales',16);
%% Coherence
[WX1,scales1,periods1,coi1,time1] = CWT(x1, ...
'wave_normalization', 'energy',...
'morse_space', 'matfreq',...
'K', 1, ...
'be', be,...
'disp_cwt', false,...
'source', 'J');
[WX2,scales2,periods2,coi2,time2] = CWT(x2, ...
'wave_normalization', 'energy',...
'morse_space', 'matfreq',...
'K', 1, ...
'be', be,...
'source', 'J');
%TLWPCO(WX1,WX2,scales1,periods1, ...
% 'disp_coherence', true,...
% 'coi',coi1,'time_series',[x1 x2], 'y_axis', 'scale');%[asd, sdss] = WPCO(WX1,WX2);
%Phase_Slope_Index = PSLI(WX1,WX2,periods1);
inputWCO = WCO(WX1,WX2,scales1,periods1, ...
'smoothing', 'Aguiar', ...
'ws_size', 5, ...
'wt_size', 5, ...
'disp_coherence', false,...
'coi',coi1,'time_series',[x1 x2], 'y_axis', 'scale',...
'coherence', 'WCO2');
Surr1 = surrogates(x1, 'surr_name', 'IAAFT', ...
'nSurr', nSurr,...
'maxiter', 1000,...
'accerror', .01,...
'error_change', 100,...
'p', 1,...
'q', 0, ...
'preprocessing', false);
Surr2 = surrogates(x2, 'surr_name', 'IAAFT', ...
'nSurr', nSurr,...
'maxiter', 1000,...
'accerror', .01,...
'error_change', 100,...
'p', 1,...
'q', 0, ...
'preprocessing', false);
cwt_Surr_1= CWT(Surr1, ...
'wave_normalization', 'energy',...
'K', 1, ...
'be', be, ...
'disp_cwt', true,...
'source', 'J');
cwt_Surr_2= CWT(Surr2, ...
'wave_normalization', 'energy',...
'K', 1, ...
'be', be,...
'source', 'J'...
);
cardiac1 = cardiac_test(Surr1, 'disp_pdf', false);
cardiac2 = cardiac_test(Surr2, 'disp_pdf', false);
[sigWCO, pWCO, classifier] = SigniWCO(inputWCO, cwt_Surr_1, cwt_Surr_2, scales1, periods1,...
'smoothing', 'Aguiar', ...
'ws_size', 5, ...
'wt_size', 5, ...
'coi',coi1,...
'time_series',[x1 x2],...
'disp_coherence', true,...
'y_axis', 'period',...
'signilevel', 0.05,...
'coherence', 'WCO2');
taskperformance = PM(labels_vec,classifier, 'soi', [2.02 12.8], 'space', periods1);