-
Notifications
You must be signed in to change notification settings - Fork 3
/
SetDerivedParameters.m
246 lines (187 loc) · 13.9 KB
/
SetDerivedParameters.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
%% Set derived parameters for a specified model, that is paramters that
% are not supposed to be freely set but rather are calculated from other
% parameters.
%
% ARGUMENTS:
% options -- BrainNetwrorkModels options structure, with
% parameters set via SetDynamciParameters(),
% SetIntegrationParameters(), and GetConnectivity().
%
% OUTPUT:
% options -- An updated BrainNetwrorkModels options structure,
% with new derived parameter fields filled.
%
% REQUIRES:
% GetLinearIndex() --
% DiscreteLaplacian_1D() -- for Model=>BRRW
%
%
%
% USAGE:
%{
%Specify a connectivty matrix
options.Connectivity.WhichMatrix = 'RM_AC';
options.Connectivity = GetConnectivity(options.Connectivity);
%Specify a local dynamic model
options.Dynamics.WhichModel = 'FHN';
options.Dynamics = SetDynamicParameters(options.Dynamics);
options = SetIntegrationParameters(options);
options = SetDerivedParameters(options)
%}
%
% MODIFICATION HISTORY:
% SAK(<dd-mm-yyyy>) -- Original.
% SAK(Nov 2013) -- Move to git, future modification history is
% there...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function options = SetDerivedParameters(options)
options.Connectivity.maxdelay = max(options.Connectivity.delay(:)); %longest single step time delay
options.Integration.maxdelayiters = round(options.Connectivity.maxdelay/options.Integration.dt)+1; %maxdelay in integration steps
options.Integration.dtt = options.Integration.dt/2;
%-----------------------------------------------------------------------%
%%
switch options.Dynamics.WhichModel
case {'BRRWtess'}%%% Populations Sigma() acts on don't seem to make sense, but this is what MB's code did... %%%
options.Connectivity.maxdelay = max([options.Connectivity.delay(:).' options.Dynamics.CTdelay options.Dynamics.TCdelay]); %longest single step time delay
options.Integration.maxdelayiters = round(options.Connectivity.maxdelay/options.Integration.dt)+1; %maxdelay in integration steps
options.Dynamics.NumberOfModes = 1;
options.Dynamics.Discretization = options.Connectivity.NumberOfNodes;
options.Dynamics.gamma_e = options.Dynamics.v ./ options.Dynamics.r_e;
options.Dynamics.axb = options.Dynamics.alfa .* options.Dynamics.btta;
options.Dynamics.apb = options.Dynamics.alfa + options.Dynamics.btta;
options.Dynamics.dtcsf = options.Integration.dt*options.Dynamics.csf;
options.Dynamics.phi_n = 1e-3.*ones(options.Integration.iters+options.Integration.maxdelayiters, options.Connectivity.NumberOfNodes);
if numel(options.Dynamics.CTdelay) == 1,
options.Dynamics.CTlidelay = GetLinearIndex(options.Dynamics.CTdelay.*ones(1,options.Connectivity.NumberOfVertices), options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
else
options.Dynamics.CTlidelay = GetLinearIndex(options.Dynamics.CTdelay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
end
if numel(options.Dynamics.TCdelay) == 1,
options.Dynamics.TClidelay = GetLinearIndex(options.Dynamics.TCdelay.*ones(1,options.Connectivity.NumberOfVertices), options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
else
options.Dynamics.TClidelay = GetLinearIndex(options.Dynamics.TCdelay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
end
%%%keyboard
%-----------------------------------------------------------------------%
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
%Explicitly rotate matrices to avoid implicit rotation within integration loop.
options.Integration.lidelay = options.Integration.lidelay.';
if ~isfield(options.Connectivity, 'HaveRotatedWeights') || ~(options.Connectivity.HaveRotatedWeights == true), %FIXME: UGLY HACK...
options.Connectivity.weights = options.Connectivity.weights.';
options.Connectivity.HaveRotatedWeights = true;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'BRRW'}%%% Populations Sigma() acts on don't seem to make sense, but this is what MB's code did... %%%
options.Connectivity.maxdelay = max([options.Connectivity.delay(:).' options.Dynamics.CTdelay options.Dynamics.TCdelay]); %longest single step time delay
options.Integration.maxdelayiters = round(options.Connectivity.maxdelay/options.Integration.dt)+1; %maxdelay in integration steps
options.Dynamics.NumberOfModes = 1;
options.Dynamics.Discretization = options.Connectivity.NumberOfNodes;
options.Dynamics.gamma_e = options.Dynamics.v ./ options.Dynamics.r_e;
options.Dynamics.Delta_x = options.Dynamics.CorticalCircumference ./ options.Dynamics.Discretization;
options.Dynamics.LapOp = DiscreteLaplacian_1D(options.Connectivity.NumberOfNodes, 3) ./ options.Dynamics.Delta_x.^2;
options.Dynamics.axb = options.Dynamics.alfa .* options.Dynamics.btta;
options.Dynamics.apb = options.Dynamics.alfa + options.Dynamics.btta;
options.Dynamics.dtcsf = options.Integration.dt*options.Dynamics.csf;
options.Dynamics.phi_n = 1e-3.*ones(options.Integration.iters+options.Integration.maxdelayiters, options.Connectivity.NumberOfNodes);
if numel(options.Dynamics.CTdelay) == 1,
options.Dynamics.CTlidelay = GetLinearIndex(options.Dynamics.CTdelay.*ones(1,options.Connectivity.NumberOfNodes), options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
else
options.Dynamics.CTlidelay = GetLinearIndex(options.Dynamics.CTdelay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
end
if numel(options.Dynamics.TCdelay) == 1,
options.Dynamics.TClidelay = GetLinearIndex(options.Dynamics.TCdelay.*ones(1,options.Connectivity.NumberOfNodes), options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
else
options.Dynamics.TClidelay = GetLinearIndex(options.Dynamics.TCdelay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt);
end
%%%keyboard
%-----------------------------------------------------------------------%
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
%Explicitly rotate matrices to avoid implicit rotation within integration loop.
options.Integration.lidelay = options.Integration.lidelay.';
if ~isfield(options.Connectivity, 'HaveRotatedWeights') || ~(options.Connectivity.HaveRotatedWeights == true), %FIXME: UGLY HACK...
options.Connectivity.weights = options.Connectivity.weights.';
options.Connectivity.HaveRotatedWeights = true;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'AFR'}
options.Connectivity.maxdelay = max(1e-3.*options.Connectivity.delay(:)); %longest single step time delay
options.Integration.maxdelayiters = round(options.Connectivity.maxdelay/options.Integration.dt)+1; %maxdelay in integration steps
options.Dynamics.NumberOfModes = 1;
options.Dynamics.Discretization = options.Connectivity.NumberOfNodes;
options.Dynamics.gamma = options.Dynamics.v ./ options.Dynamics.r_e;
options.Dynamics.Delta_x = options.Dynamics.CorticalCircumference ./ options.Dynamics.Discretization;
load('LapOp_freesurftess.mat') ; % load('LapOp_AFR.mat')
options.Dynamics.LapOp = LapOp;
options.Dynamics.axb = options.Dynamics.alfa .* options.Dynamics.btta;
options.Dynamics.apb = options.Dynamics.alfa + options.Dynamics.btta;
options.Dynamics.dtcsf = options.Integration.dt*options.Dynamics.csf;
options.Dynamics.phi_n = repmat(double(options.Connectivity.ThalamicNodes(options.Connectivity.RegionMapping)), [options.Integration.iters+options.Integration.maxdelayiters 1]);
%%%options.Dynamics.phi_n = zeros(options.Integration.iters+options.Integration.maxdelayiters, options.Connectivity.NumberOfVertices);
%%%options.Dynamics.phi_n(options.Connectivity.ThalamicNodes) = 1;
%%%keyboard
%-----------------------------------------------------------------------%
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(1e-3.*options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
%Explicitly rotate matrices to avoid implicit rotation within integration loop.
options.Integration.lidelay = options.Integration.lidelay.';
if ~isfield(options.Connectivity, 'HaveRotatedWeights') || ~(options.Connectivity.HaveRotatedWeights == true), %FIXME: UGLY HACK...
options.Connectivity.weights = options.Connectivity.weights.';
options.Connectivity.HaveRotatedWeights = true;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'SNX'}
options.Dynamics.NumberOfModes = 1;
options.Dynamics.dtcsf = options.Integration.dt*options.Dynamics.csf;
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
%Explicitly rotate matrices to avoid implicit rotation within integration loop.
options.Integration.lidelay = options.Integration.lidelay.';
if ~isfield(options.Connectivity, 'HaveRotatedWeights') || ~(options.Connectivity.HaveRotatedWeights == true), %FIXME: UGLY HACK...
options.Connectivity.weights = options.Connectivity.weights.';
options.Connectivity.HaveRotatedWeights = true;
end
options.Dynamics.sqrtQxdt = sqrt(options.Dynamics.Qx * options.Integration.dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'FHN','FHNtess'}
options.Dynamics.NumberOfModes = 1;
options.Dynamics.dttauc = options.Integration.dt*options.Dynamics.tau*options.Dynamics.csf;
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
%Explicitly rotate matrices to avoid implicit rotation within integration loop.
options.Integration.lidelay = options.Integration.lidelay.';
if ~isfield(options.Connectivity, 'HaveRotatedWeights') || ~(options.Connectivity.HaveRotatedWeights == true), %FIXME: UGLY HACK...
options.Connectivity.weights = options.Connectivity.weights.';
options.Connectivity.HaveRotatedWeights = true;
end
options.Dynamics.sqrtQfdt = sqrt(options.Dynamics.Qf * options.Integration.dt);
options.Dynamics.sqrtQsdt = sqrt(options.Dynamics.Qs * options.Integration.dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'ReducedFHN','ReducedFHNtess' }
options = reduced_coefficients(options);
options.Dynamics.NumberOfModes = length(options.Dynamics.A);
options.Dynamics.dttauc = options.Integration.dt*options.Dynamics.tau*options.Dynamics.csf;
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
options.Dynamics.sqrtQxdt = sqrt(options.Dynamics.Qx * options.Integration.dt);
options.Dynamics.sqrtQydt = sqrt(options.Dynamics.Qy * options.Integration.dt);
options.Dynamics.sqrtQzdt = sqrt(options.Dynamics.Qz * options.Integration.dt);
options.Dynamics.sqrtQwdt = sqrt(options.Dynamics.Qw * options.Integration.dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'ReducedHMR', 'ReducedHMRtess'}
options = reduced_coefficients(options);
options.Dynamics.NumberOfModes = length(options.Dynamics.A);
options.Dynamics.dtcsf = options.Integration.dt*options.Dynamics.csf;
%% Convert the provided time delays into a linear index for use in integration...
options.Integration.lidelay = GetLinearIndex(options.Connectivity.delay, options.Integration.iters, options.Integration.maxdelayiters, options.Integration.dt, options.Dynamics.NumberOfModes);
options.Dynamics.sqrtQxdt = sqrt(options.Dynamics.Qx * options.Integration.dt);
options.Dynamics.sqrtQydt = sqrt(options.Dynamics.Qy * options.Integration.dt);
options.Dynamics.sqrtQzdt = sqrt(options.Dynamics.Qz * options.Integration.dt);
options.Dynamics.sqrtQwdt = sqrt(options.Dynamics.Qw * options.Integration.dt);
options.Dynamics.sqrtQvdt = sqrt(options.Dynamics.Qv * options.Integration.dt);
options.Dynamics.sqrtQudt = sqrt(options.Dynamics.Qu * options.Integration.dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
otherwise
end
end %function SetDerivedParameters()