-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_code.py
More file actions
1473 lines (900 loc) · 48.3 KB
/
main_code.py
File metadata and controls
1473 lines (900 loc) · 48.3 KB
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Modelling Nucleus Accumbens
# A Computational Model from Single Cell to Circuit Level
# Created by Rahmi Elibol May, 2020.
#With this code Nucleus Accumbens is modelled; single neurons, synaptic currents and the over all behavior of medium spiny neurons under the effect of dopamine can be observed. The results are given with membrane potentials, synaptic currents, raster plots, frequency analysis (power spectrum density, frequency time plot) and local field potential.Single neurons are modelled using Izhikevich neuron model and modified Izhikevich neuro model.
# There are cortex and NAcc groups. The cortex has pyramid and interneurons.
# The NAcc has D1 , D2 type MSNs and interneurons.
from brian2 import *
start_scope()
# Parameters
#neuron parameters
Vthr = 30 * mvolt # threshold value for Izhikevich neuron
EL = -75 * mV # initial value of membrane potentials
#synaptic parameters
tau_s = 1 * ms # time constant for synatic dynamics
we = 0.1 *amp/mV # weights for excitatory synapses
wi = 0.1 *amp/mV # weights for inhibitory synapses
Vi = -90 * mV # resting potential for inhibitory synaptic currents.
Ve = 0 * mV # resting potential for excitatory synaptic currents.
dly=(3+rand())*ms # axonal and synaptic delay
par_percent=10 # The parameters a, b, c, d, and k are taken at random around 10% of the given values
# From the article: E. M. Izhikevich, "Simple model of spiking neurons," in IEEE Transactions on Neural Networks, vol. 14, no. 6, pp. 1569-1572, Nov. 2003, doi: 10.1109/TNN.2003.820440.
#Regular Spike (RS) parameters
#a = 0.02 / ms
#b = 0.2 / ms
#c = -65 * mvolt
#d = 8 * mvolt
#Fast Spike (FS) parameters
#a = 0.1 / ms
#b = 0.2 / ms
#c = -65 * mvolt
#d = 2 * mvolt
#Chattering (CH) parameters
#a = 0.02 / ms
#b = 0.2 / ms
#c = -50 * mvolt
#d = 2 * mvolt
#As circuit level model of nucleus accumbens is built, modelling its relation with cortex globus pallidus stn and thalamus, i.e. part of basal ganglia loop neuron groups are formed. Here are the numbers of neurons considered for each neural structure.
# cortex with excitatory and inhibitory neuron populations.
number_of_neurons_in_pyramid = 900
number_of_neurons_in_crtx_in = 100
# nucleus accumbens core and shell with D1 and D2 type dopamine effect on medium spiny neurons and inhibitory neurons.
number_of_neurons_in_nacc=450
number_of_neurons_in_msnd1_core = 100
number_of_neurons_in_msnd2_core = 100
number_of_neurons_in_msnd1_shell = 100
number_of_neurons_in_msnd2_shell = 100
number_of_neurons_in_nacc_in = 50
# Globus pallidus, STN and total of them
number_of_neurons_in_bg=300
number_of_neurons_in_GPe=100
# thalamus and ventral tegmental area
number_of_neurons_in_thl = 100
number_of_neurons_in_vta = 100
print('Equations')
# Other than nucleus accumbens , other structures have excitatory stimuli modelled with poisson group these correspond to background activity
PG_pyramid = PoissonGroup(number_of_neurons_in_pyramid, 5 * Hz) #nominal value: 5*Hz
PG_THL = PoissonGroup(number_of_neurons_in_thl, 5 * Hz)
PG_BG = PoissonGroup(number_of_neurons_in_bg, 1 * Hz)
PG_crtx_in = PoissonGroup(number_of_neurons_in_crtx_in, 50 * Hz) #nominal value: 50*Hz
# Izhikevich neuron model for cortex, golubs pallidus, STN, VTA and THL with synaptic dynamics defining synaptic current.
eqs_dyn = """
dv/dt=(0.04/ms/mV)*v**2+(5/ms)*v+140*mV/ms-u/ms+I*mV/(amp*ms)+Is*mV/(amp*ms) : volt
du/dt=a*(b*v-u)/ms : volt
I : amp
Is=ge*(Ve-v)+gi*(Vi-v) : amp
dge/dt=-ge/tau_e : amp/volt
dgi/dt=-gi/tau_i : amp/volt
a : 1
b : 1
c : volt
d : volt
tau_e : second
tau_i : second
"""
# Modified Izhikevich neuron model for nucleus accumbens core and shell with synaptic dynamics, defining synaptic current. This synaptic current has glutamate, GABA, Dopamine and acetylcholine components.
tau_glu=2*ms
tau_DA=1.5*ms
tau_i_msn=tau_s
eqs_msn = """
dv/dt=(0.04/ms/mV)*v**2+(5/ms)*v+140*mV/ms-u/ms+I*mV/(amp*ms)+Is*mV/(amp*ms) : volt
du/dt=a*(b*v+k*mV-u)/ms : volt
I : amp
I_Glu=g_glu*(Ve-v) : amp
I_DA=g_DA*(V_DA-v) : amp
I_Ach=g_Ach*(Vi-v) : amp
I_GABA=g_GABA*(Vi-v) : amp
Is=I_Glu+I_DA+I_Ach+I_GABA : amp
dg_glu/dt=-g_glu/tau_glu : amp/volt
dg_DA/dt=-g_DA/tau_DA : amp/volt
dg_Ach/dt=-g_Ach/tau_i_msn : amp/volt
dg_GABA/dt=-g_GABA/tau_i_msn : amp/volt
a : 1
b : 1
c : volt
d : volt
k : 1
V_DA : volt
"""
# reset condition for Izhikevich neuron.
eqs_reset = '''
v = c
u = u+d
'''
# Forming neuron population for each neural structure considered. “NeuronGroup” of BRIAN2 is used. Here, the parameters in the neuron model are taken randomly in a range that does not alter the behavior of the specific neuron type. This randomness is important to obtain a realistic behavior of population. Otherwise all neurons would fire exactly same which would not give rise to a realistic model.
pyramid = NeuronGroup(number_of_neurons_in_pyramid, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_pyramid):
pyramid.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
pyramid.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
pyramid.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
pyramid.d[i] = 8*(100-par_percent+2*par_percent*rand())/100* mvolt
pyramid.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
pyramid.u[i] = (-14.5*((100-par_percent+2*par_percent*rand())/100))*mvolt
pyramid.tau_e = tau_s
pyramid.tau_i = tau_s
crtx_in = NeuronGroup(number_of_neurons_in_crtx_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_crtx_in):
crtx_in.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
crtx_in.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
crtx_in.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
crtx_in.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
crtx_in.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
crtx_in.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
crtx_in.tau_e = tau_s
crtx_in.tau_i = tau_s
msnd1_core = NeuronGroup(number_of_neurons_in_msnd1_core, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd1_core):
msnd1_core.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd1_core.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd1_core.c[i] = -62*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd1_core.d[i] = 0.6*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV: 1.9
msnd1_core.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd1_core.u[i] = 35*((100-par_percent+2*par_percent*rand())/100)*mV
msnd1_core.k[i] = 35*((100-2*par_percent+4*par_percent*rand())/100) #parametre araligi: 0.02 - 0.07
msnd1_core.V_DA = 0*mV
msnd2_core= NeuronGroup(number_of_neurons_in_msnd2_core, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd2_core):
msnd2_core.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd2_core.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd2_core.c[i] = -60*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd2_core.d[i] = 0.6*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd2_core.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd2_core.u[i] = 25*((100-par_percent+2*par_percent*rand())/100)*mV
msnd2_core.k[i] = 20*((100-2*par_percent+4*par_percent*rand())/100)
msnd2_core.V_DA = -90*mV
msnd1_shell= NeuronGroup(number_of_neurons_in_msnd1_shell, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd1_shell):
msnd1_shell.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell.c[i] = -56*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd1_shell.d[i] = 0.4*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd1_shell.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell.u[i] = 35*((100-par_percent+2*par_percent*rand())/100)*mV
msnd1_shell.k[i] = 35*((100-2*par_percent+4*par_percent*rand())/100)
msnd1_shell.V_DA = 0*mV
msnd2_shell= NeuronGroup(number_of_neurons_in_msnd2_shell, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd2_shell):
msnd2_shell.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell.c[i] = -55*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: -52
msnd2_shell.d[i] = 0.4*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd2_shell.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell.u[i] = 25*((100-par_percent+2*par_percent*rand())/100)*mV
msnd2_shell.k[i] = 20*((100-2*par_percent+4*par_percent*rand())/100)
msnd2_shell.V_DA = -90*mV
str_in= NeuronGroup(number_of_neurons_in_nacc_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_nacc_in):
str_in.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
str_in.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
str_in.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
str_in.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
str_in.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
str_in.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
str_in.tau_e = tau_s
str_in.tau_i = tau_s
GPe = NeuronGroup(number_of_neurons_in_GPe, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_GPe):
GPe.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
GPe.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
GPe.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
GPe.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
GPe.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
GPe.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
GPe.tau_e = tau_s
GPe.tau_i = tau_s*2
GPi = NeuronGroup(number_of_neurons_in_GPe, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_GPe):
GPi.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
GPi.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
GPi.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
GPi.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
GPi.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
GPi.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
GPi.tau_e = tau_s
GPi.tau_i = tau_s*2
STN = NeuronGroup(number_of_neurons_in_GPe, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_GPe):
STN.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
STN.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
STN.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
STN.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
STN.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
STN.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
STN.tau_e = tau_s
STN.tau_i = tau_s
vta_dopamine = NeuronGroup(number_of_neurons_in_vta, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_vta):
vta_dopamine.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
vta_dopamine.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
vta_dopamine.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
vta_dopamine.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
vta_dopamine.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
vta_dopamine.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
vta_dopamine.tau_e = tau_s
vta_dopamine.tau_i = tau_s
thl = NeuronGroup(number_of_neurons_in_thl, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
##rebound burst
for i in range(number_of_neurons_in_thl):
thl.a[i] = 0.03*((100-par_percent+2*par_percent*rand())/100)
thl.b[i] = 0.25*((100-par_percent+2*par_percent*rand())/100)
thl.c[i] = -52*((100-par_percent+2*par_percent*rand())/100) * mvolt
thl.d[i] = 0.01*((100-par_percent+2*par_percent*rand())/100) * mvolt
thl.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
thl.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100) *mV
thl.tau_e = tau_s
thl.tau_i = tau_s*5
# Here, stimuli that activate the population is defined. But all these are choosen to be zero for the model.
pyramid.I = 0*amp
crtx_in.I = 0*amp
msnd1_core.I = 0*amp
msnd2_core.I = 0*amp
msnd1_shell.I = 0*amp
msnd2_shell.I = 0*amp
str_in.I = 0*amp
GPe.I = 0*amp
GPi.I = 0*amp
STN.I = 0*amp
vta_dopamine.I = 0*amp
thl.I = 0*amp
###### Synapses #############
#############################
print('Synapses')
# The synaptic connection between and within neural structures are defined with “synapse” of BRIAN2 is used.Each structure is coded with a number for example code of cortex is 1, pyramidal neuron population in cortex is coded with 11 and connection between pyramidal neurons and cortex IN is coded with 1112.
# 1 cortex
## 11 Pyramid
SP1111 = Synapses(PG_pyramid, pyramid, 'w :siemens', delay=dly, on_pre='ge += w')
SP1111.connect(True, p = 0.25)
SP1111.w=we
S1211 = Synapses(crtx_in, pyramid, delay=dly, on_pre='gi += wi')
S1211.connect(True, p = 0.25)
# 12 IN
SP1212 = Synapses(PG_crtx_in, crtx_in, delay=dly, on_pre='ge += 5*we')
SP1212.connect(True, p = 0.25)
S1112 = Synapses(pyramid, crtx_in, delay=dly, on_pre='ge += we')
S1112.connect(True, p = 0.25)
# 2 NAcc
# 21 Core MSND1
S1121 = Synapses(pyramid, msnd1_core, 'w :siemens', delay=dly, on_pre='g_glu += w')
S1121.connect(True, p = 0.25)
S1121.w=we
print("synapse number from cortex: "+str(S1121.N)+" average:"+str(S1121.N/100))
S2521 = Synapses(str_in, msnd1_core, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S2521.connect(True, p = 0.25)
S2521.w=wi
print("synapse number from IN: "+str(S2521.N)+" average:"+str(S2521.N/100))
S4121 = Synapses( thl, msnd1_core, 'w :siemens', delay=dly, on_pre='g_glu += w')
S4121.connect(True, p = 0.25)
S4121.w=we
print("synapse number from THL: "+str(S4121.N)+" average:"+str(S4121.N/100))
S5121 = Synapses(vta_dopamine, msnd1_core, 'w :siemens', delay=dly, on_pre='g_DA += w')
S5121.connect(True, p = 0.25)
S5121.w=we
print("synapse number from VTA: "+str(S5121.N)+" average:"+str(S5121.N/100))
##### Colateral inhibitions from MSNs
S2121 = Synapses(msnd1_core, msnd1_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2121.connect(True, p = 0.05)
S2121.w=wi
print("synapse number from MSND1C: "+str(S2121.N)+" average:"+str(S2121.N/100))
S2221 = Synapses(msnd2_core, msnd1_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2221.connect(True, p = 0.25)
S2221.w=wi*2
print("synapse number from MSND2C: "+str(S2221.N)+" average:"+str(S2221.N/100))
S2321 = Synapses(msnd1_shell, msnd1_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2321.connect(True, p = 0.05)
S2321.w=wi
print("synapse number from MSND1S: "+str(S2321.N)+" average:"+str(S2321.N/100))
S2421 = Synapses(msnd2_shell, msnd1_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2421.connect(True, p = 0.25)
S2421.w=wi*2
print("synapse number from MSND2S: "+str(S2421.N)+" average:"+str(S2421.N/100))
print("Total average synapse number:" +str((S1121.N+S2521.N+S4121.N+S5121.N+S2121.N+S2221.N+S2321.N+S2421.N)/100))
# 22 Core MSND2
S1122 = Synapses(pyramid, msnd2_core, 'w :siemens', delay=dly, on_pre='g_glu += w')
S1122.connect(True, p = 0.25)
S1122.w=we
S2522 = Synapses(str_in, msnd2_core, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S2522.connect(True, p = 0.25)
S2522.w=wi
S4122 = Synapses( thl, msnd2_core, 'w :siemens', delay=dly, on_pre='g_glu += w')
S4122.connect(True, p = 0.25)
S4122.w=we
S5122 = Synapses(vta_dopamine, msnd2_core, 'w :siemens', delay=dly, on_pre='g_DA += w')
S5122.connect(True, p = 0.25)
S5122.w=wi
##### Colateral inhibitions from MSNs
S2122 = Synapses(msnd1_core, msnd2_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2122.connect(True, p = 0.25)
S2122.w=wi*2
S2222 = Synapses(msnd2_core, msnd2_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2222.connect(True, p = 0.05)
S2222.w=wi
S2322 = Synapses(msnd1_shell, msnd2_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2322.connect(True, p = 0.25)
S2322.w=wi*2
S2422 = Synapses(msnd2_shell, msnd2_core, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2422.connect(True, p = 0.05)
S2422.w=wi
# 23 Shell MSND1
S1123 = Synapses(pyramid, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_glu += w')
S1123.connect(True, p = 0.25)
S1123.w=we
S2523 = Synapses(str_in, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S2523.connect(True, p = 0.25)
S2523.w=wi
S4123 = Synapses(thl, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_glu += w')
S4123.connect(True, p = 0.25)
S4123.w=we
S5123 = Synapses(vta_dopamine, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_DA += w')
S5123.connect(True, p = 0.25)
S5123.w=we
##### Colateral inhibitions from MSNs
S2123 = Synapses(msnd1_core, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2123.connect(True, p = 0.05)
S2123.w=wi
S2223 = Synapses(msnd2_core, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2223.connect(True, p = 0.25)
S2223.w=wi*2
S2323 = Synapses(msnd1_shell, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2323.connect(True, p = 0.05)
S2323.w=wi
S2423 = Synapses(msnd2_shell, msnd1_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2423.connect(True, p = 0.25)
S2423.w=wi*2
# 24 Shell MSND2
S1124 = Synapses(pyramid, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_glu += w')
S1124.connect(True, p = 0.25)
S1124.w=we
S2524 = Synapses(str_in, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S2524.connect(True, p = 0.25)
S2524.w=wi
S4124 = Synapses(thl, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_glu += w')
S4124.connect(True, p = 0.25)
S4124.w=we
S5124 = Synapses(vta_dopamine, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_DA += w')
S5124.connect(True, p = 0.25)
S5124.w=wi
##### Colateral inhibitions from MSNs
S2124 = Synapses(msnd1_core, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2124.connect(True, p = 0.25)
S2124.w=wi*2
S2224 = Synapses(msnd2_core, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2224.connect(True, p = 0.05)
S2224.w=wi
S2324 = Synapses(msnd1_shell, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2324.connect(True, p = 0.25)
S2324.w=wi*2
S2424 = Synapses(msnd2_shell, msnd2_shell, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S2424.connect(True, p = 0.05)
S2424.w=wi
# 25 IN
S1125 = Synapses(pyramid, str_in, delay=dly, on_pre='ge += 0.25*we')
S1125.connect(True, p = 0.20)
S2125 = Synapses(msnd1_core, str_in, delay=dly, on_pre='gi += wi')
S2125.connect(True, p = 0.25)
S2225 = Synapses(msnd2_core, str_in, delay=dly, on_pre='gi += wi')
S2225.connect(True, p = 0.25)
S2325 = Synapses(msnd1_shell, str_in, delay=dly, on_pre='gi += wi')
S2325.connect(True, p = 0.25)
S2425 = Synapses(msnd2_shell, str_in, delay=dly, on_pre='gi += wi')
S2425.connect(True, p = 0.25)
# 31 GPe
SP3031 = Synapses(PG_BG, GPe, delay=dly, on_pre='ge += 2*we')
SP3031.connect(True, p = 0.25)
S2231 = Synapses(msnd2_core, GPe, delay=dly, on_pre='gi += wi')
S2231.connect(True, p = 0.25)
S2431 = Synapses(msnd2_shell, GPe, delay=dly, on_pre='gi += wi')
S2431.connect(True, p = 0.25)
S3331 = Synapses(STN, GPe, delay=dly, on_pre='ge += we')
S3331.connect(True, p = 0.25)
# 32 GPi
SP3032 = Synapses(PG_BG, GPi, delay=dly, on_pre='ge += 2*we')
SP3032.connect(True, p = 0.25)
S2132 = Synapses(msnd1_core, GPi, delay=dly, on_pre='gi += wi')
S2132.connect(True, p = 0.25)
S2332 = Synapses(msnd1_shell, GPi, delay=dly, on_pre='gi += wi')
S2332.connect(True, p = 0.25)
S3132 = Synapses(GPe, GPi, delay=dly, on_pre='gi += wi')
S3132.connect(True, p = 0.25)
# 33 STN
S1133 = Synapses(pyramid, STN, delay=dly, on_pre='ge += 0.5*we')
S1133.connect(True, p = 0.25)
S3133 = Synapses(GPe, STN, delay=dly, on_pre='gi += wi')
S3133.connect(True, p = 0.25)
# 41 THL
SP4141 = Synapses(PG_THL, thl, delay=dly, on_pre='ge += 0.5*we')
SP4141.connect(True, p = 0.25)
S3241 = Synapses(GPi, thl, delay=dly, on_pre='gi += 0.5*wi')
S3241.connect(True, p = 0.25)
# 51 VTA
SP5151 = Synapses(PG_pyramid, vta_dopamine, 'w :siemens', delay=dly, on_pre='ge += w')
SP5151.connect(True, p = 0.25)
SP5151.w=we
#==============================================================================
#==============================================================================
#==============================================================================
import time
init_time=time.time()
# Simulation will begin now after defining everything needed to for neurons and the neural structures. But first 100ms of the simulation is just for settling all neurons to equilibrium. So this part will not be used in analysis.
######### First 100ms #########
################################
duration1=100*ms
SP1111.w=we*0
SP5151.w=we*0
print('100 ms initial conditions delay')
print("sim_time="+str(duration1))
run(duration1, report='text')
SP1111.w=we
SP5151.w=we
###### Monitors ###########
###########################
print('Monitors')
# “StateMonitor” and "SpikeMonitor" commands of BRIAN are used to follow the behavior of neurons during simulation.
trace_pyramid = StateMonitor(pyramid, 'v', record=9)
#monge_pyramid = StateMonitor(pyramid, 'ge', record=True)
#mongi_pyramid = StateMonitor(pyramid, 'gi', record=True)
spikes_pyramid = SpikeMonitor(pyramid)
trace_crtx_in = StateMonitor(crtx_in, 'v', record=9)
#monge_crtx_in = StateMonitor(crtx_in, 'ge', record=True)
#mongi_crtx_in = StateMonitor(crtx_in, 'gi', record=True)
spikes_crtx_in = SpikeMonitor(crtx_in)
trace_msnd1_core = StateMonitor(msnd1_core, 'v', record=True)
trace_g_glu_msnd1_core = StateMonitor(msnd1_core, 'g_glu', record=9)
trace_g_DA_msnd1_core = StateMonitor(msnd1_core, 'g_DA', record=9)
trace_g_Ach_msnd1_core = StateMonitor(msnd1_core, 'g_Ach', record=9)
trace_g_GABA_msnd1_core = StateMonitor(msnd1_core, 'g_GABA', record=9)
trace_I_Glu_msnd1_core = StateMonitor(msnd1_core, 'I_Glu', record=9)
trace_I_DA_msnd1_core = StateMonitor(msnd1_core, 'I_DA', record=9)
trace_I_Ach_msnd1_core = StateMonitor(msnd1_core, 'I_Ach', record=9)
trace_I_GABA_msnd1_core = StateMonitor(msnd1_core, 'I_GABA', record=9)
trace_I_s_msnd1_core = StateMonitor(msnd1_core, 'Is', record=True)
spikes_msnd1_core = SpikeMonitor(msnd1_core)
trace_msnd2_core = StateMonitor(msnd2_core, 'v', record=True)
trace_g_glu_msnd2_core = StateMonitor(msnd2_core, 'g_glu', record=9)
trace_g_DA_msnd2_core = StateMonitor(msnd2_core, 'g_DA', record=9)
trace_g_Ach_msnd2_core = StateMonitor(msnd2_core, 'g_Ach', record=9)
trace_g_GABA_msnd2_core = StateMonitor(msnd2_core, 'g_GABA', record=9)
trace_I_Glu_msnd2_core = StateMonitor(msnd2_core, 'I_Glu', record=9)
trace_I_DA_msnd2_core = StateMonitor(msnd2_core, 'I_DA', record=9)
trace_I_Ach_msnd2_core = StateMonitor(msnd2_core, 'I_Ach', record=9)
trace_I_GABA_msnd2_core = StateMonitor(msnd2_core, 'I_GABA', record=9)
trace_I_s_msnd2_core = StateMonitor(msnd2_core, 'Is', record=True)
spikes_msnd2_core = SpikeMonitor(msnd2_core)
trace_msnd1_shell = StateMonitor(msnd1_shell, 'v', record=True)
#monge_msnd1_shell = StateMonitor(msnd1_shell, 'ge', record=True)
#mongi_msnd1_shell = StateMonitor(msnd1_shell, 'gi', record=True)
spikes_msnd1_shell = SpikeMonitor(msnd1_shell)
trace_I_s_msnd1_shell = StateMonitor(msnd1_shell, 'Is', record=True)
trace_msnd2_shell = StateMonitor(msnd2_shell, 'v', record=True)
#monge_msnd2_shell = StateMonitor(msnd2_shell, 'ge', record=True)
#mongi_msnd2_shell = StateMonitor(msnd2_shell, 'gi', record=True)
spikes_msnd2_shell = SpikeMonitor(msnd2_shell)
trace_I_s_msnd2_shell = StateMonitor(msnd2_shell, 'Is', record=True)
trace_str_in = StateMonitor(str_in, 'v', record=True)
#monge_str_in = StateMonitor(str_in, 'ge', record=True)
#mongi_str_in = StateMonitor(str_in, 'gi', record=True)
spikes_str_in = SpikeMonitor(str_in)
trace_I_s_nacc_in = StateMonitor(str_in, 'Is', record=True)
trace_GPe = StateMonitor(GPe, 'v', record=9)
#monge_GPe = StateMonitor(GPe, 'ge', record=True)
#mongi_GPe = StateMonitor(GPe, 'gi', record=True)
spikes_GPe = SpikeMonitor(GPe)
trace_GPi = StateMonitor(GPi, 'v', record=9)
#monge_GPi = StateMonitor(GPi, 'ge', record=True)
#mongi_GPi = StateMonitor(GPi, 'gi', record=True)
spikes_GPi = SpikeMonitor(GPi)
trace_STN = StateMonitor(STN, 'v', record=9)
#monge_STN = StateMonitor(STN, 'ge', record=True)
#mongi_STN = StateMonitor(STN, 'gi', record=True)
spikes_STN = SpikeMonitor(STN)
trace_vta_dopamine = StateMonitor(vta_dopamine, 'v', record=9)
#monge_vta_dopamine = StateMonitor(vta_dopamine, 'ge', record=True)
#mongi_vta_dopamine = StateMonitor(vta_dopamine, 'gi', record=True)
spikes_vta_dopamine = SpikeMonitor(vta_dopamine)
trace_thl = StateMonitor(thl, 'v', record=9)
#monge_pyramid = StateMonitor(pyramid, 'ge', record=True)
#mongi_pyramid = StateMonitor(pyramid, 'gi', record=True)
spikes_thl = SpikeMonitor(thl)
########### Excitation currents ##########
##########################################
print("start")
SP1111.w=we*2
SP5151.w=we
number_of_scenario=0
######################### ----- Scenarios -------------- ####################
##-------------------- Scenario 0 --------------------------------##
## It is used for testing purposes.
# The scenario is used to test whether the code works.
if number_of_scenario==0:
wcne = 0.20 *we
wtne = 0.25 *we
wvne = 3.00 *we
wvni = 3.00 *wi
SP1111.w=we
SP5151.w=we
S1121.w=wcne # from pyramid to msnd1 core
S4121.w=wtne # from THL to msnd1 core
S5121.w=wvne # from VTA to msnd1 core
S1122.w=wcne # from pyramid to msnd2 core
S4122.w=wtne # from THL to msnd2 core
S5122.w=wvni # from VTA to msnd2 core
S1123.w=wcne # from pyramid to msnd1 shell
S4123.w=wtne # from THL to msnd1 shell
S5123.w=wvne # from VTA to msnd1 shell
S1124.w=wcne # from pyramid to msnd2 shell
S4124.w=wtne # from THL to msnd2 shell
S5124.w=wvni # from VTA to msnd2 shell
print('Scenario 0')
run(100*ms,report='text')
##-------------------- Scenario 1 --------------------------------##
##### Changing cortex and VTA input, investigate the relation of stimulus and reward
elif number_of_scenario==1:
print('Scenario 1')
duration1=100*ms
duration2=1000*ms
wcne = 0.20 *we
wtne = 0.25 *we
wvne = 3.00 *we
wvni = 3.00 *wi
SP1111.w=we*0
SP5151.w=we*0
S1121.w=wcne # from pyramid to msnd1 core
S4121.w=wtne # from THL to msnd1 core
S5121.w=wvne # from VTA to msnd1 core
S1122.w=wcne # from pyramid to msnd2 core
S4122.w=wtne # from THL to msnd2 core
S5122.w=wvni # from VTA to msnd2 core
S1123.w=wcne # from pyramid to msnd1 shell
S4123.w=wtne # from THL to msnd1 shell
S5123.w=wvne # from VTA to msnd1 shell
S1124.w=wcne # from pyramid to msnd2 shell
S4124.w=wtne # from THL to msnd2 shell
S5124.w=wvni # from VTA to msnd2 shell
print('Scenario 1: D1 Resting')
S1121.w=wcne*0 # from pyramid to msnd1 core
S1122.w=wcne*0 # from pyramid to msnd2 core
S1123.w=wcne*0 # from pyramid to msnd1 shell
S1124.w=wcne*0 # from pyramid to msnd2 shell
SP1111.w=we*0
SP5151.w=we*0
print("sim_time="+str(duration1))
run(duration1, report='text')
print('Scenario 1: D2 Only Cortex')
S1121.w=wcne # from pyramid to msnd1 core
S1122.w=wcne # from pyramid to msnd2 core
S1123.w=wcne # from pyramid to msnd1 shell
S1124.w=wcne # from pyramid to msnd2 shell
SP1111.w=we
SP5151.w=we*0.1
print("sim_time="+str(duration2))
run(duration2, report='text')
print('Scenario 1: D3 Resting')
SP1111.w=we*0
SP5151.w=we*0
print("sim_time="+str(duration1))
run(duration1, report='text')
print('Scenario 1: D4 Only VTA')
S1121.w=wcne*0.1 # from pyramid to msnd1 core
S1122.w=wcne*0.1 # from pyramid to msnd2 core
S1123.w=wcne*0.1 # from pyramid to msnd1 shell
S1124.w=wcne*0.1 # from pyramid to msnd2 shell
SP1111.w=we
SP5151.w=we
print("sim_time="+str(duration2))
run(duration2, report='text')
print('Scenario 1: D5 Resting')
SP1111.w=we*0
SP5151.w=we*0
print("sim_time="+str(duration1))
run(duration1, report='text')
print('Scenario 1: D6 Cortex and VTA')
S1121.w=wcne # from pyramid to msnd1 core
S1122.w=wcne # from pyramid to msnd2 core
S1123.w=wcne # from pyramid to msnd1 shell
S1124.w=wcne # from pyramid to msnd2 shell
SP1111.w=we
SP5151.w=we
print("sim_time="+str(duration2))
run(duration2, report='text')
print('Scenario 1: D7 Resting')
SP1111.w=we*0
SP5151.w=we*0