-
Notifications
You must be signed in to change notification settings - Fork 0
/
ORIENT.m
369 lines (311 loc) · 15.1 KB
/
ORIENT.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
%*************************************************************************%
% %
% ORIENT %
% %
%*************************************************************************%
% CONTAINS:
% Retina
% Superior Colliculus (SC)
% FEF Basal Ganglia loop (BG subsystem)
% Saccadic Generator (SG)
% Frontal Eye Fields (FEF)
% On the sizes of locs:
% locs will either be of dimensions 1x1 - with the sigma projections
% required specified by number of neurons x scaling factor, or locs = dims
% and sigma represents number of neurons.
% Add subsystem
orient = sml_system();
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADD NEURAL LAYERS %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
outpars = defParsOut;
actpars = defParsAct;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RETINA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
actpars.sigma_membrane = 0;
orient = nw_modAddPop(orient, 'retina_in', fS, [ret_dims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
orient = nw_modAddPop(orient, 'retina_1', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
actpars.tau_membrane = 0.03;
orient = nw_modAddPop(orient, 'retina_2', fS, [layerDims], {[layerLocs]},[p2a 'leaky'], actpars, [p2o 'linear'], outpars);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
outpars = defParsOut;
actpars = defParsAct;
orient= nw_modAddPop(orient, 'SC_sup', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'tanh'], outpars);
actpars.p = 1;
orient= nw_modAddPop(orient, 'SC_buildup', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
orient= nw_modAddPop(orient, 'SG_in', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FEF etc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
outpars = defParsOut;
actpars = defParsAct;
outpars.c = -0.0;
actpars.p = 1;
actpars.sigma_membrane = BACKGROUND_NOISE
orient = nw_modAddPop(orient, 'FEF_input', fS, [In_dims], [In_locs], [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
outpars = defParsOut;
actpars = defParsAct;
if strcmp(taskType, 'TEST')
% actpars.sigma_membrane = BACKGROUND_NOISE;
end
orient = nw_modAddPop(orient, 'FEF', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
outpars = defParsOut;
actpars = defParsAct;
orient = nw_modAddPop(orient, 'THAL', fS, [layerDims], {[layerLocs]}, [p2a 'leakyThal'], actpars, [p2o 'linear'], outpars);
% orient = nw_modAddPop(orient, 'THAL_IL', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BG = sml_system();
% dopamine source
state = [];
state.data = DOPAMINE;
state.repeat = true;
state.ndims = 1;
BG = BG.addprocess('DA', 'std/2009/source/numeric', fS, state);
outpars = defParsOut;
actpars = defParsAct;
outpars.c = STRIATAL_OFFSET;
BG = nw_modAddPop(BG, 'STR_D1', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
BG = nw_modAddPop(BG, 'STR_D2', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
outpars = defParsOut;
actpars = defParsAct;
outpars.c = 0.9;
outpars.m = 1;
outpars.limits = [0 1];
actpars.tau_membrane = 0.005;
actpars.neg_reversal_potential = -0.4;
BG = nw_modAddPop(BG, 'STN', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'exp'], outpars);
outpars = defParsOut;
actpars = defParsAct;
BG = nw_modAddPop(BG, 'GPe', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
outpars.limits = [0.0 1.0];
BG = nw_modAddPop(BG, 'SNr', fS, [layerDims], {[layerLocs]}, [p2a 'leaky'], actpars, [p2o 'linear'], outpars);
outpars = defParsOut;
actpars = defParsAct;
%%%%%%%%%%%%%%%%%%%%%%%%%%%% SACCADIC GENERATOR %%%%%%%%%%%%%%%%%%%%%%%%%%%
state = [];
state.xRange = pantilt_scale*In_dims(2);
state.yRange = pantilt_scale*In_dims(1);
state.mode = 1.0;
in_layer_size = layerDims(1);
if targetMode > 0
state.target = targetVals;
end
% state.E_2 = 2.5/degrees_to_edge*(in_layer_size/2);
% state.M_f = in_layer_size/(state.E_2*log(1+(degrees_to_edge/state.E_2)));
state.E_2 = 2.5;
state.M_f = in_layer_size/(state.E_2*log(1+(degrees_to_edge/state.E_2)));
%state.quadraticFactor = 0.0006;%0.00146
state.threshold = 0.4;%15*(layerDims(1)/layerLocs(1))*(layerDims(2)/layerLocs(2));
if strcmp(taskType,'TEST_ROBOT')
state.xRange2 = 26/50;
state.yRange2 = 26/50;
state.xRange = degrees_to_edge*2 * 1.1;
state.yRange = degrees_to_edge*2 * 1.1;% 1.1 is a fix factor
state.mode = 1.0;
state.quadraticFactor = 0.0006;%0.00146
orient = orient.addprocess('SG', 'dev/abrg/2009/emSGLProbot', fS, state);
elseif strcmp(taskType,'FLAG')
state.xRange = In_dims(1);
state.yRange = In_dims(2);
orient = orient.addprocess('SG', 'dev/abrg/2009/emSG', fS, state);
else
orient = orient.addprocess('SG', 'dev/abrg/2009/emSGLP', fS, state);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADD PROJECTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RETINA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% add intrinsic projections (see "help nw_modAddProj")
projState = [];
projState.delay = 0.0;
projState.norm='aff';
projState.decimate = 0.0;
defParsProj = projState;
orient = nw_modAddProj(orient, fS, 'retina_2', 'retina_1', RETINA2_TO_RETINA1, [p2p 'onetoone'], projState, 'add');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
projState = defParsProj;
projState.sigma = 0.6;
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'SC_sup', 'SC_buildup', SC_SUPERIOR_TO_SC_BUILDUP, [p2p 'gaussianIIR'], projState, 'add');
projState.sigma = 2.0; % 2.0
projState.norm= 'none';
orient = nw_modAddProj(orient, fS, 'SC_buildup', 'SC_buildup', SC_BUILDUP_RECIP, [p2p 'gaussianIIR'], projState, 'add');%0.05
projState.norm='aff';
orient = nw_modAddProj(orient, fS, 'SC_buildup', 'SG_in', 1, [p2p 'onetoone'], projState, 'add');%0.05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FEF etc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
projState = defParsProj;
projState.sigma = 1.5;
projState.norm= 'aff';
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'FEF', 'THAL', FEF_2_THAL, [p2p 'onetoone'], projState, 'add');
orient = nw_modAddProj(orient, fS, 'THAL', 'FEF', THAL_2_FEF, [p2p 'onetoone'], projState, 'add');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
projState = defParsProj;
projState.srcDims = 1;
projState.norm = 'none';
BG = nw_modAddInput(BG, fS, 'DA', 'STR_D1', 1, [p2p 'diffuse'], projState, 'shunt');
BG = nw_modAddInput(BG, fS, 'DA', 'STR_D2', -1, [p2p 'diffuse'], projState, 'shunt');
projState = defParsProj;
if hack_model == false
projState.sigma = 1.0;
projState.norm = 'aff';
projState.edge_compensation = 'wrapV';
projState.delay = 0.0;
BG = nw_modAddProj(BG, fS, 'STR_D1', 'SNr', STR_D1_TO_SNR, [p2p 'gaussianIIR'], projState, 'add');
BG = nw_modAddProj(BG, fS, 'STR_D2', 'GPe', STR_D2_TO_GPE, [p2p 'gaussianIIR'], projState, 'add');
else
projState.sigma = 2.0;% 1.0
projState.norm = 'aff';
projState.edge_compensation = 'wrapV';
projState.delay = 0.0;
BG = nw_modAddProj(BG, fS, 'STR_D1', 'SNr', STR_D1_TO_SNR, [p2p 'gaussianIIR'], projState, 'add');
BG = nw_modAddProj(BG, fS, 'STR_D2', 'GPe', STR_D2_TO_GPE, [p2p 'gaussianIIR'], projState, 'add');
end
projState = defParsProj;
BG = nw_modAddProj(BG, fS, 'STN', 'SNr', STN_TO_SNR, [p2p 'diffuse'], projState, 'add');
BG = nw_modAddProj(BG, fS, 'STN', 'GPe', STN_TO_GPE, [p2p 'diffuse'], projState, 'add');
BG = nw_modAddProj(BG, fS, 'GPe', 'STN', GPE_TO_STN, [p2p 'onetoone'], projState, 'add');
BG = nw_modAddProj(BG, fS, 'GPe', 'SNr', GPE_TO_SNR, [p2p 'onetoone'], projState, 'add');
% % STN control source
% state = [];
% state.data = STN_CTRL;
% state.repeat = true;
% state.ndims = 1;
% BG = BG.addprocess('src_STN', 'std/2009/source/numeric', fS, state);
%
% projState = [];
% projState.norm = 'none';
% projState.srcDims = 1;
% BG = nw_modAddInput(BG, fS, 'src_STN>out', 'STN', 1.0, [p2p 'diffuse'], projState, 'add');
orient = orient.addsubsystem('BG', BG);
%%%%%%%%%%%%%%%%%%%%%%%%% links between subsystems %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% orient to BG ------------------------------------------------------------
projState = defParsProj;
if fovea_striatum_comp_v2 == true
projState.srci = zeros(layerDims(1)*layerDims(2),1);
projState.dsti = zeros(layerDims(1)*layerDims(2),1);
for i = 1:layerDims(1)
for j = 1:layerDims(2)
num = (i-1)*layerDims(2)+j;
projState.srci(num) = single(num-1);
projState.dsti(num) = single(num-1);
projState.weights(num) = single(tanh(j./2-layerDims(1)/4+ fovea_damping_offset).*0.5+0.5);% was 0.5 and 0.5
end
end
projState.sigma = STR_IN_SIGMA;
projState.norm = 'none';
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STR_D1', FEF_TO_STR_D1, [p2p 'manual'], projState, 'add');
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STR_D2', FEF_TO_STR_D2, [p2p 'manual'], projState, 'add');
projState.sigma = 3;
projState.norm = 'aff';
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STN', FEF_TO_STN, [p2p 'gaussianIIR'], projState, 'add');
projState.sigma = STR_IN_SIGMA;
projState.norm = 'none';
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STR_D1', THAL_TO_STR_D1, [p2p 'manual'], projState, 'add');
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STR_D2', THAL_TO_STR_D2, [p2p 'manual'], projState, 'add');
projState.sigma = 3;
projState.norm = 'aff';
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STN', THAL_TO_STN, [p2p 'gaussianIIR'], projState, 'add');
else
projState.sigma = STR_IN_SIGMA;
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STR_D1', FEF_TO_STR_D1, [p2p STR_IN_TYPE], projState, 'add');
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STR_D2', FEF_TO_STR_D2, [p2p STR_IN_TYPE], projState, 'add');
projState.sigma = 3;
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'FEF', 'BG.STN', FEF_TO_STN, [p2p 'gaussianIIR'], projState, 'add');
projState.sigma = STR_IN_SIGMA;
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STR_D1', THAL_TO_STR_D1, [p2p STR_IN_TYPE], projState, 'add');
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STR_D2', THAL_TO_STR_D2, [p2p STR_IN_TYPE], projState, 'add');
projState.sigma = 3;
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'THAL', 'BG.STN', THAL_TO_STN, [p2p 'gaussianIIR'], projState, 'add');
end
% Retina to orient --------------------------------------------------------
% sigma here can be decreased if necessary
projState = defParsProj;
projState.sigma = 0.6;
projState.delay = 0.05; % Wurtz and Albano
projState.norm = 'aff';
projState.edge_compensation = 'wrapV';
projState.sigma = 0.5;
orient = nw_modAddProj(orient, fS, 'retina_1', 'SC_sup', RETINA1_TO_SC_SUPERIOR, [p2p 'onetoone'], projState, 'add');
% orient to orient ------------------------------------------------------------
projState = defParsProj;
orient = nw_modAddProj(orient, fS, 'SC_sup', 'THAL', SC_SUPERIOR_TO_THAL, [p2p 'onetoone'], projState, 'add');
orient = nw_modAddProj(orient, fS, 'SC_buildup', 'THAL', SC_BUILDUP_TO_THAL, [p2p 'onetoone'], projState, 'add');
% BG to orient ------------------------------------------------------------
orient = nw_modAddProj(orient, fS, 'BG.SNr', 'THAL', SNR_TO_THAL, [p2p 'onetoone'], projState, 'shunt');
orient = nw_modAddProj(orient, fS, 'BG.SNr', 'THAL', SNR_TO_THAL_ADD, [p2p 'onetoone'], projState, 'add');
% orient to orient------------------------------------------------------------
projState = defParsProj;
projState.sigma = 0.6;
projState.edge_compensation = 'wrapV';
orient = nw_modAddProj(orient, fS, 'FEF', 'SC_buildup', FEF_TO_SC_BUILDUP, [p2p 'gaussianIIR'], projState, 'add');%0.3
% BG to orient----------------------------------------------------------------
projState = defParsProj;
projState.sigma = 4.0;
projState.edge_compensation = 'wrapVclampH';
if hack_model == false
orient = nw_modAddProj(orient, fS, 'BG.SNr', 'SC_buildup', SNR_TO_SC_BUILDUP, [p2p 'onetoone'], projState, 'shunt');
else
orient = nw_modAddProj(orient, fS, 'BG.SNr', 'SC_buildup', SNR_TO_SC_BUILDUP, [p2p 'onetoone'], projState, 'shunt');
% orient = nw_modAddProj(orient, fS, 'BG.SNr', 'SC_buildup', SNR_TO_SC_BUILDUP, [p2p 'gaussianIIR'], projState, 'shunt');
end
% orient = nw_modAddProj(orient, fS, 'BG.SNr', 'SC_buildup', SNR_TO_SC_BUILDUP_D, [p2p 'onetoone'], projState, 'shunt_div');
orient = nw_modAddProj(orient, fS, 'BG.SNr', 'SC_buildup', SNR_TO_SC_BUILDUP_ADD, [p2p 'onetoone'], projState, 'add');
orient= orient.link('SG_in>out', 'SG<<SC');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SCOPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if scopesOn == true
state = [];
state.dims = [layerDims];
state.scale=[0 1.01];
state.zoom = 8;
state.interval = inter;
state.position = [20 300];
state.colours = 'fire';
state.title = scopeTarg;
orient = orient.addprocess('scopeFEF', 'dev/abrg/2009/scope', fS, state);
orient =orient.link(scopeTarg, 'scopeFEF<<mono<in');
state = [];
state.dims = [layerDims];
state.scale=[0.0 1.01];
state.zoom = 8;
state.interval = inter;
state.position = [400 300];
state.colours = 'fire';
state.title = scopeTargA;
orient = orient.addprocess('scopeA', 'dev/abrg/2009/scope', fS, state);
orient =orient.link(scopeTargA, 'scopeA<<mono<in');
state = [];
state.dims = [layerDims];
state.scale=[0 1.01];
state.zoom = 8;
state.interval = inter;
state.position = [20 600];
state.colours = 'ice';
state.title = scopeTargB;
orient = orient.addprocess('scopeB', 'dev/abrg/2009/scope', fS, state);
orient =orient.link(scopeTargB, 'scopeB<<mono<in');
state = [];
state.dims = [layerDims];
state.scale=[0 1.01];
state.zoom = 8;
state.interval = inter;
state.position = [400 600];
state.colours = 'fire';
state.title = scopeTarg2;
orient = orient.addprocess('scope2', 'dev/abrg/2009/scope', fS, state);
orient =orient.link(scopeTarg2, 'scope2<<mono<in');
% state = [];
% state.scale = [-0.3 1.4];
% state.position = [20 900];
% state.title = 'SG_inhib';
% state.height = 100;
% state.length =200;
% state.interval = inter;
% orient = orient.addprocess('scopeOPN', 'dev/abrg/2008/scalarScope', fS, state);
% orient =orient.link('SG>inhib', 'scopeOPN<in');
end
%*************************************************************************%
% END ORIENT %
%*************************************************************************%
sys = sys.addsubsystem('orient', orient);