-
Notifications
You must be signed in to change notification settings - Fork 0
/
WCOExperiment.m
117 lines (108 loc) · 5.42 KB
/
WCOExperiment.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
%% REFERENCE
% [1] Thomas Schreiber and Andreas Schmitz (2009)
% "Surrogate time series Thomas"
function varargout = WCOExperiment(ts_x1, ts_x2, labels_vec, parameter_space)
%% number of surrogates
% approximation possible (eg., |2/(0.99-1)| = 200), see [1] here larger number to increase discrimination power due to still increasing statistics after 100 surrogates
if str2num(string(parameter_space.signilevel)) < 0.05
nSurr = 33;
else
nSurr = 18; % 18
end
disp = false; % display options
source = 'J'; % use Matlab for Matlab implementation of the CWT
%% continious wavelet transform
[cwt_1,scales,periods,coi,time] = CWT(ts_x1, ...
'wave_normalization', char(parameter_space.wave_normalization),...
'morse_space', char(parameter_space.morse_space),...
'K', 1, ...
'be', parameter_space.be,...
'ga', parameter_space.ga,...
'disp_cwt', false,...
'wavelet_type', char(parameter_space.wavelet_type),...
'source', source...
);
cwt_2 = CWT(ts_x2,...
'wave_normalization', char(parameter_space.wave_normalization),...
'morse_space', char(parameter_space.morse_space),...
'K', 1, ...
'be', parameter_space.be,...
'ga', parameter_space.ga,...
'disp_cwt', false,...
'wavelet_type', char(parameter_space.wavelet_type),...
'source', source...
);
%% wavelet coherence
inputWCO = WCO(cwt_1,cwt_2,scales,periods,...
'smoothing', char(parameter_space.smoothing),...
'ws_size', parameter_space.ws_size,...
'wt_size', parameter_space.wt_size,...
'disp_coherence', false,...
'coi',cwt_1,...
'time_series',[ts_x1 ts_x2],...
'y_axis', 'scale',...
'coherence', char(parameter_space.coherence)...
);
%% create surrogates
surr_1 = surrogates(ts_x1, 'surr_name', char(parameter_space.surr_name), ...
'nSurr', nSurr,...
'maxiter', 1000,...
'accerror', .01,...
'error_change', 100,...
'p', 1,...
'q', 0, ...
'preprocessing', false ...
);
surr_2 = surrogates(ts_x2, 'surr_name', char(parameter_space.surr_name),...
'nSurr', nSurr,...
'maxiter', 1000,...
'accerror', .01,...
'error_change', 100,...
'p', 1,...
'q', 0, ...
'preprocessing', false ...
);
%% test cardiac attributes
Cardiac_1 = cardiac_test(surr_1, 'disp_pdf', false);
Cardiac_1.surrogate = repmat(string(parameter_space.surr_name),nSurr,1);
Cardiac_2 = cardiac_test(surr_2, 'disp_pdf', false);
Cardiac_2.surrogate = repmat(string(parameter_space.surr_name),nSurr,1);
%% continious wavelet transform of surrogates
cwt_surr_1 = CWT(surr_1,...
'wave_normalization', char(parameter_space.wave_normalization),...
'morse_space', char(parameter_space.morse_space),...
'K', 1, ...
'be', parameter_space.be,...
'ga', parameter_space.ga,...
'disp_cwt', disp,...
'wavelet_type', char(parameter_space.wavelet_type),...
'source', source...
);
cwt_surr_2 = CWT(surr_2,...
'wave_normalization', char(parameter_space.wave_normalization),...
'morse_space', char(parameter_space.morse_space),...
'K', 1, ...
'be', parameter_space.be,...
'ga', parameter_space.ga,...
'disp_cwt', disp,...
'wavelet_type', char(parameter_space.wavelet_type),...
'source', source...
);
%% calculate significantly wavelet coherence
[sigWCO, pWCO, classifier] = SigniWCO(inputWCO, cwt_surr_1, cwt_surr_2, scales, periods,...
'smoothing', char(parameter_space.smoothing),...
'ws_size', parameter_space.ws_size,...
'wt_size', parameter_space.wt_size,...
'coi',coi,...
'time_series',[ts_x1 ts_x2],...
'disp_coherence', disp,...
'y_axis', 'period',...
'signilevel', str2num(char(parameter_space.signilevel)),... %str2num(char(parameter_space.signilevel)),...
'coherence', char(parameter_space.coherence),...
'connectivity_vector', labels_vec...
);
Taskperformance = PM(labels_vec,classifier, 'soi', [2.02 12.8], 'space', periods);
Taskperformance.surrogate = string(parameter_space.surr_name);
Objective = 1-Taskperformance.f_score;
varargout = {Objective, struct2table(Taskperformance), Cardiac_1, Cardiac_2}
end