-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_code.py
1827 lines (1255 loc) · 69.4 KB
/
main_code.py
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
# Modeling ventral and dorsal BG circuits
# Ventral Striatum Modifies Activity of Basal Ganglia Circuit: A Computational Model
# With this code BG circuits is modelled; single neurons, synaptic currents, nucleus and circuits levels.
# The results are given with membrane potentials, synaptic currents, raster plots,
# frequency analysis (power spectrum density, frequency time plot) and local field potentials.
# Single neurons are modelled using Izhikevich neuron model and modified Izhikevich neuron model.
from brian2 import *
start_scope()
# Parameters
#neuron parameters
Vthr = 30 * mvolt
EL = -75 * mV
#synaptic parameters
tau_s = 1 * ms
we = 0.1 *amp/mV
wi = 0.1 *amp/mV
Vi = -90 * mV
Ve = 0 * mV
dly=(3+rand())*ms
### synaptic weigths
w_cse = 0.20 *we
w_tse = 0.25 *we
w_vse = 3.00 *we
w_vsi = 3.00 *wi
w_sse = 3.00 *we
w_ssi = 3.00 *wi
par_percent=10
number_of_neurons_in_ACA_pyramid = 900
number_of_neurons_in_ACA_in = 100
number_of_neurons_in_PFC_pyramid = 900
number_of_neurons_in_PFC_in = 100
number_of_neurons_in_MC_pyramid = 900
number_of_neurons_in_MC_in = 100
number_of_neurons_in_nacc=450
number_of_neurons_in_msnd1_core_121 = 100
number_of_neurons_in_msnd2_core_122 = 100
number_of_neurons_in_msnd1_shell_123 = 100
number_of_neurons_in_msnd2_shell_124 = 100
number_of_neurons_in_nacc_in = 50
number_of_neurons_in_msnd1_caudate_221 = 200
number_of_neurons_in_msnd2_caudate_222 = 200
number_of_neurons_in_caudate_in = 50
number_of_neurons_in_bg=300
number_of_neurons_in_GPe=100
number_of_neurons_in_thl = 100
number_of_neurons_in_vta = 100
############# ---- Poisson Groups ------ #####################
PG_ACA_pyramid_1011 = PoissonGroup(number_of_neurons_in_ACA_pyramid, 5 * Hz) #nominal value: 5*Hz
PG_ACA_in_1012 = PoissonGroup(number_of_neurons_in_ACA_in, 50 * Hz)
PG_BG_1040 = PoissonGroup(number_of_neurons_in_bg, 1 * Hz)
PG_Ventral_THL_1051 = PoissonGroup(number_of_neurons_in_thl, 5 * Hz)
PG_PFC_pyramid_2011 = PoissonGroup(number_of_neurons_in_PFC_pyramid, 5 * Hz) #nominal value: 5*Hz
PG_PFC_in_2012 = PoissonGroup(number_of_neurons_in_PFC_in, 50 * Hz) #nominal value: 50*Hz
PG_BG_2040 = PoissonGroup(number_of_neurons_in_bg, 1 * Hz)
PG_Dorsal_THL_2051 = PoissonGroup(number_of_neurons_in_thl, 5 * Hz)
print('Equations')
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
"""
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
"""
eqs_reset = '''
v = c
u = u+d
'''
ACA_Pyramid_111 = NeuronGroup(number_of_neurons_in_ACA_pyramid, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_ACA_pyramid):
ACA_Pyramid_111.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
ACA_Pyramid_111.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
ACA_Pyramid_111.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
ACA_Pyramid_111.d[i] = 8*(100-par_percent+2*par_percent*rand())/100* mvolt
ACA_Pyramid_111.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
ACA_Pyramid_111.u[i] = (-14.5*((100-par_percent+2*par_percent*rand())/100))*mvolt
ACA_Pyramid_111.tau_e = tau_s
ACA_Pyramid_111.tau_i = tau_s
ACA_in_112 = NeuronGroup(number_of_neurons_in_ACA_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_ACA_in):
ACA_in_112.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
ACA_in_112.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
ACA_in_112.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
ACA_in_112.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
ACA_in_112.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
ACA_in_112.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
ACA_in_112.tau_e = tau_s
ACA_in_112.tau_i = tau_s
###################################################
####### ----------- Ventral BG Groups -----#######
###################################################
####### ----------- NAcc -----#######
msnd1_core_121 = NeuronGroup(number_of_neurons_in_msnd1_core_121, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd1_core_121):
msnd1_core_121.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd1_core_121.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd1_core_121.c[i] = -62*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd1_core_121.d[i] = 0.6*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV: 1.9
msnd1_core_121.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd1_core_121.u[i] = 35*((100-par_percent+2*par_percent*rand())/100)*mV
msnd1_core_121.k[i] = 35*((100-2*par_percent+4*par_percent*rand())/100) #parametre araligi: 0.02 - 0.07
msnd1_core_121.V_DA = 0*mV
msnd2_core_122= NeuronGroup(number_of_neurons_in_msnd2_core_122, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd2_core_122):
msnd2_core_122.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd2_core_122.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd2_core_122.c[i] = -60*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd2_core_122.d[i] = 0.6*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd2_core_122.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd2_core_122.u[i] = 25*((100-par_percent+2*par_percent*rand())/100)*mV
msnd2_core_122.k[i] = 20*((100-2*par_percent+4*par_percent*rand())/100)
msnd2_core_122.V_DA = -90*mV
msnd1_shell_123= NeuronGroup(number_of_neurons_in_msnd1_shell_123, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd1_shell_123):
msnd1_shell_123.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell_123.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell_123.c[i] = -56*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd1_shell_123.d[i] = 0.4*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd1_shell_123.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd1_shell_123.u[i] = 35*((100-par_percent+2*par_percent*rand())/100)*mV
msnd1_shell_123.k[i] = 35*((100-2*par_percent+4*par_percent*rand())/100)
msnd1_shell_123.V_DA = 0*mV
msnd2_shell_124= NeuronGroup(number_of_neurons_in_msnd2_shell_124, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd2_shell_124):
msnd2_shell_124.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell_124.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell_124.c[i] = -55*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: -52
msnd2_shell_124.d[i] = 0.4*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd2_shell_124.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd2_shell_124.u[i] = 25*((100-par_percent+2*par_percent*rand())/100)*mV
msnd2_shell_124.k[i] = 20*((100-2*par_percent+4*par_percent*rand())/100)
msnd2_shell_124.V_DA = -90*mV
nacc_in_125= 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):
nacc_in_125.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
nacc_in_125.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
nacc_in_125.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
nacc_in_125.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
nacc_in_125.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
nacc_in_125.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
nacc_in_125.tau_e = tau_s
nacc_in_125.tau_i = tau_s
####### ----------- Ventral Pallidal -----#######
Ventral_GPe_141 = 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):
Ventral_GPe_141.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPe_141.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPe_141.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_GPe_141.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_GPe_141.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPe_141.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
Ventral_GPe_141.tau_e = tau_s
Ventral_GPe_141.tau_i = tau_s*2
Ventral_GPi_142 = 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):
Ventral_GPi_142.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPi_142.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPi_142.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_GPi_142.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_GPi_142.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Ventral_GPi_142.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
Ventral_GPi_142.tau_e = tau_s
Ventral_GPi_142.tau_i = tau_s*2
Ventral_STN_143 = 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):
Ventral_STN_143.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
Ventral_STN_143.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Ventral_STN_143.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_STN_143.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_STN_143.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Ventral_STN_143.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
Ventral_STN_143.tau_e = tau_s
Ventral_STN_143.tau_i = tau_s
VTA_DA_131 = 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_DA_131.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
VTA_DA_131.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
VTA_DA_131.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
VTA_DA_131.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
VTA_DA_131.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
VTA_DA_131.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
VTA_DA_131.tau_e = tau_s
VTA_DA_131.tau_i = tau_s
Ventral_THL_151 = NeuronGroup(number_of_neurons_in_thl, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_thl):
Ventral_THL_151.a[i] = 0.03*((100-par_percent+2*par_percent*rand())/100)
Ventral_THL_151.b[i] = 0.25*((100-par_percent+2*par_percent*rand())/100)
Ventral_THL_151.c[i] = -52*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_THL_151.d[i] = 0.01*((100-par_percent+2*par_percent*rand())/100) * mvolt
Ventral_THL_151.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Ventral_THL_151.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100) *mV
Ventral_THL_151.tau_e = tau_s
Ventral_THL_151.tau_i = tau_s*10
ACA_Pyramid_111.I = 0*amp
ACA_in_112.I = 0*amp
msnd1_core_121.I = 0*amp
msnd2_core_122.I = 0*amp
msnd1_shell_123.I = 0*amp
msnd2_shell_124.I = 0*amp
nacc_in_125.I = 0*amp
Ventral_GPe_141.I = 0*amp
Ventral_GPi_142.I = 0*amp
Ventral_STN_143.I = 0*amp
VTA_DA_131.I = 0*amp
Ventral_THL_151.I = 0*amp
###################################################
####### ----------- Dorsal BG Groups -----#######
###################################################
PFC_Pyramid_211 = NeuronGroup(number_of_neurons_in_PFC_pyramid, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_PFC_pyramid):
PFC_Pyramid_211.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
PFC_Pyramid_211.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
PFC_Pyramid_211.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
PFC_Pyramid_211.d[i] = 8*(100-par_percent+2*par_percent*rand())/100* mvolt
PFC_Pyramid_211.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
PFC_Pyramid_211.u[i] = (-14.5*((100-par_percent+2*par_percent*rand())/100))*mvolt
PFC_Pyramid_211.tau_e = tau_s
PFC_Pyramid_211.tau_i = tau_s
PFC_in_212 = NeuronGroup(number_of_neurons_in_PFC_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_ACA_in):
PFC_in_212.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
PFC_in_212.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
PFC_in_212.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
PFC_in_212.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
PFC_in_212.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
PFC_in_212.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
PFC_in_212.tau_e = tau_s
PFC_in_212.tau_i = tau_s
####### ----------- Caudate -----#######
msnd1_caudate_221 = NeuronGroup(number_of_neurons_in_msnd1_caudate_221, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd1_caudate_221):
msnd1_caudate_221.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd1_caudate_221.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd1_caudate_221.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd1_caudate_221.d[i] = 0.6*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV: 1.9
msnd1_caudate_221.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd1_caudate_221.u[i] = 35*((100-par_percent+2*par_percent*rand())/100)*mV
msnd1_caudate_221.k[i] = 35*((100-2*par_percent+4*par_percent*rand())/100) #parametre araligi: 0.02 - 0.07
msnd1_caudate_221.V_DA = 0*mV
msnd2_caudate_222= NeuronGroup(number_of_neurons_in_msnd2_caudate_222, model=eqs_msn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_msnd2_caudate_222):
msnd2_caudate_222.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
msnd2_caudate_222.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
msnd2_caudate_222.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt # NV:-52
msnd2_caudate_222.d[i] = 0.5*((100-par_percent+2*par_percent*rand())/100) * mvolt #NV: 1.9
msnd2_caudate_222.v[i] = (EL-15*mV)*((100-par_percent+2*par_percent*rand())/100)
msnd2_caudate_222.u[i] = 25*((100-par_percent+2*par_percent*rand())/100)*mV
msnd2_caudate_222.k[i] = 20*((100-2*par_percent+4*par_percent*rand())/100)
msnd2_caudate_222.V_DA = -90*mV
caudate_in_223= NeuronGroup(number_of_neurons_in_caudate_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_nacc_in):
caudate_in_223.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
caudate_in_223.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
caudate_in_223.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
caudate_in_223.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
caudate_in_223.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
caudate_in_223.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
caudate_in_223.tau_e = tau_s
caudate_in_223.tau_i = tau_s
####### ----------- Dorsal Pallidal -----#######
Dorsal_GPe_241 = 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):
Dorsal_GPe_241.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPe_241.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPe_241.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_GPe_241.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_GPe_241.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPe_241.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
Dorsal_GPe_241.tau_e = tau_s
Dorsal_GPe_241.tau_i = tau_s*2
Dorsal_GPi_242 = 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):
Dorsal_GPi_242.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPi_242.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPi_242.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_GPi_242.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_GPi_242.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Dorsal_GPi_242.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100)*mV
Dorsal_GPi_242.tau_e = tau_s
Dorsal_GPi_242.tau_i = tau_s*2
Dorsal_STN_243 = 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):
Dorsal_STN_243.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
Dorsal_STN_243.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
Dorsal_STN_243.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_STN_243.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_STN_243.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Dorsal_STN_243.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
Dorsal_STN_243.tau_e = tau_s
Dorsal_STN_243.tau_i = tau_s
SNc_DA_231 = 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):
SNc_DA_231.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
SNc_DA_231.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
SNc_DA_231.c[i] = -70*((100-par_percent+2*par_percent*rand())/100) * mvolt
SNc_DA_231.d[i] = 8*((100-par_percent+2*par_percent*rand())/100) * mvolt
SNc_DA_231.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
SNc_DA_231.u[i] = -14.5 *((100-par_percent+2*par_percent*rand())/100) *mV
SNc_DA_231.tau_e = tau_s
SNc_DA_231.tau_i = tau_s
Dorsal_THL_251 = NeuronGroup(number_of_neurons_in_thl, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_thl):
Dorsal_THL_251.a[i] = 0.03*((100-par_percent+2*par_percent*rand())/100)
Dorsal_THL_251.b[i] = 0.25*((100-par_percent+2*par_percent*rand())/100)
Dorsal_THL_251.c[i] = -52*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_THL_251.d[i] = 0.01*((100-par_percent+2*par_percent*rand())/100) * mvolt
Dorsal_THL_251.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
Dorsal_THL_251.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100) *mV
Dorsal_THL_251.tau_e = tau_s
Dorsal_THL_251.tau_i = tau_s*5
MC_Pyramid_311 = NeuronGroup(number_of_neurons_in_MC_pyramid, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_MC_pyramid):
MC_Pyramid_311.a[i] = 0.02*((100-par_percent+2*par_percent*rand())/100)
MC_Pyramid_311.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
MC_Pyramid_311.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
MC_Pyramid_311.d[i] = 8*(100-par_percent+2*par_percent*rand())/100* mvolt
MC_Pyramid_311.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
MC_Pyramid_311.u[i] = (-14.5*((100-par_percent+2*par_percent*rand())/100))*mvolt
MC_Pyramid_311.tau_e = tau_s
MC_Pyramid_311.tau_i = tau_s
MC_in_312 = NeuronGroup(number_of_neurons_in_MC_in, model=eqs_dyn, method='rk4', threshold='v>Vthr', reset=eqs_reset)
for i in range(number_of_neurons_in_MC_in):
MC_in_312.a[i] = 0.01*((100-par_percent+2*par_percent*rand())/100)
MC_in_312.b[i] = 0.2*((100-par_percent+2*par_percent*rand())/100)
MC_in_312.c[i] = -65*((100-par_percent+2*par_percent*rand())/100) * mvolt
MC_in_312.d[i] = 2*((100-par_percent+2*par_percent*rand())/100) * mvolt
MC_in_312.v[i] = EL*((100-par_percent+2*par_percent*rand())/100)
MC_in_312.u[i] = -14.5*((100-par_percent+2*par_percent*rand())/100)*mV
MC_in_312.tau_e = tau_s
MC_in_312.tau_i = tau_s
PFC_Pyramid_211.I = 0*amp
PFC_in_212.I = 0*amp
msnd1_caudate_221.I = 0*amp
msnd2_caudate_222.I = 0*amp
caudate_in_223.I = 0*amp
Dorsal_GPe_241.I = 0*amp
Dorsal_GPi_242.I = 0*amp
Dorsal_STN_243.I = 0*amp
SNc_DA_231.I = 0*amp
Dorsal_THL_251.I = 0*amp
MC_Pyramid_311.I = 0*amp
MC_in_312.I = 0*amp
###################################################
###### Synapses #############
#############################
print('Synapses')
################ ----- Ventral Synapses -------------- ######
## 111 ACA_Pyramid_111
S01_1011_111 = Synapses(PG_ACA_pyramid_1011, ACA_Pyramid_111, 'w :siemens', delay=dly, on_pre='ge += w')
S01_1011_111.connect(True, p = 0.25)
S02_112_111 = Synapses(ACA_in_112, ACA_Pyramid_111, delay=dly, on_pre='gi += wi')
S02_112_111.connect(True, p = 0.25)
#thalamocortical synapses
S55_151_111 = Synapses(Ventral_THL_151, ACA_Pyramid_111, 'w :siemens', delay=dly, on_pre='ge += w')
S55_151_111.connect(True, p = 0.25)
S55_151_111.w=we*.25
# 112 IN
S03_1012_112 = Synapses(PG_ACA_in_1012, ACA_in_112, delay=dly, on_pre='ge += 5*we')
S03_1012_112.connect(True, p = 0.25)
S04_111_112 = Synapses(ACA_Pyramid_111, ACA_in_112, delay=dly, on_pre='ge += we')
S04_111_112.connect(True, p = 0.25)
# 2 NAcc
# 121 Core MSND1
S05_111_121 = Synapses(ACA_Pyramid_111, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_glu += w')
S05_111_121.connect(True, p = 0.25)
S05_111_121.w=w_cse
S06_125_121 = Synapses(nacc_in_125, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S06_125_121.connect(True, p = 0.25)
S06_125_121.w=wi
S07_151_121 = Synapses( Ventral_THL_151, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_glu += w')
S07_151_121.connect(True, p = 0.25)
S07_151_121.w=w_tse
S08_131_121 = Synapses(VTA_DA_131, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_DA += w')
S08_131_121.connect(True, p = 0.25)
S08_131_121.w=w_vse
##### Colateral inhibitions from MSNs
S09_121_121 = Synapses(msnd1_core_121, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S09_121_121.connect(True, p = 0.05)
S09_121_121.w=wi
S10_122_121 = Synapses(msnd2_core_122, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S10_122_121.connect(True, p = 0.25)
S10_122_121.w=wi*2
S11_123_121 = Synapses(msnd1_shell_123, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S11_123_121.connect(True, p = 0.05)
S11_123_121.w=wi
S12_124_121 = Synapses(msnd2_shell_124, msnd1_core_121, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S12_124_121.connect(True, p = 0.25)
S12_124_121.w=wi*2
# 122 Core MSND2
S13_111_122 = Synapses(ACA_Pyramid_111, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_glu += w')
S13_111_122.connect(True, p = 0.25)
S13_111_122.w=w_cse
S14_125_122 = Synapses(nacc_in_125, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S14_125_122.connect(True, p = 0.25)
S14_125_122.w=wi
S15_151_122 = Synapses( Ventral_THL_151, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_glu += w')
S15_151_122.connect(True, p = 0.25)
S15_151_122.w=w_tse
S16_131_122 = Synapses(VTA_DA_131, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_DA += w')
S16_131_122.connect(True, p = 0.25)
S16_131_122.w=w_vsi
##### Colateral inhibitions from MSNs
S17_121_122 = Synapses(msnd1_core_121, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S17_121_122.connect(True, p = 0.25)
S17_121_122.w=wi*2
S18_122_122 = Synapses(msnd2_core_122, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S18_122_122.connect(True, p = 0.05)
S18_122_122.w=wi
S19_123_122 = Synapses(msnd1_shell_123, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S19_123_122.connect(True, p = 0.25)
S19_123_122.w=wi*2
S20_124_122 = Synapses(msnd2_shell_124, msnd2_core_122, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S20_124_122.connect(True, p = 0.05)
S20_124_122.w=wi
# 123 Shell MSND1
S21_111_123 = Synapses(ACA_Pyramid_111, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_glu += w')
S21_111_123.connect(True, p = 0.25)
S21_111_123.w=w_cse
S22_125_123 = Synapses(nacc_in_125, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S22_125_123.connect(True, p = 0.25)
S22_125_123.w=wi
S23_151_123 = Synapses(Ventral_THL_151, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_glu += w')
S23_151_123.connect(True, p = 0.25)
S23_151_123.w=w_tse
S24_131_123 = Synapses(VTA_DA_131, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_DA += w')
S24_131_123.connect(True, p = 0.25)
S24_131_123.w=w_vse
##### Colateral inhibitions from MSNs
S25_121_123 = Synapses(msnd1_core_121, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S25_121_123.connect(True, p = 0.05)
S25_121_123.w=wi
S26_122_123 = Synapses(msnd2_core_122, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S26_122_123.connect(True, p = 0.25)
S26_122_123.w=wi*2
S27_123_123 = Synapses(msnd1_shell_123, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S27_123_123.connect(True, p = 0.05)
S27_123_123.w=wi
S28_124_123 = Synapses(msnd2_shell_124, msnd1_shell_123, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S28_124_123.connect(True, p = 0.25)
S28_124_123.w=wi*2
# 124 Shell MSND2
S29_111_124 = Synapses(ACA_Pyramid_111, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_glu += w')
S29_111_124.connect(True, p = 0.25)
S29_111_124.w=w_cse
S30_125_124 = Synapses(nacc_in_125, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S30_125_124.connect(True, p = 0.25)
S30_125_124.w=wi
S31_151_124 = Synapses(Ventral_THL_151, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_glu += w')
S31_151_124.connect(True, p = 0.25)
S31_151_124.w=w_tse
S32_131_124 = Synapses(VTA_DA_131, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_DA += w')
S32_131_124.connect(True, p = 0.25)
S32_131_124.w=w_vsi
##### Colateral inhibitions from MSNs
S33_121_124 = Synapses(msnd1_core_121, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S33_121_124.connect(True, p = 0.25)
S33_121_124.w=wi*2
S34_122_124 = Synapses(msnd2_core_122, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S34_122_124.connect(True, p = 0.05)
S34_122_124.w=wi
S35_123_124 = Synapses(msnd1_shell_123, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S35_123_124.connect(True, p = 0.25)
S35_123_124.w=wi*2
S36_124_124 = Synapses(msnd2_shell_124, msnd2_shell_124, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S36_124_124.connect(True, p = 0.05)
S36_124_124.w=wi
# 125 IN
S37_111_125 = Synapses(ACA_Pyramid_111, nacc_in_125, delay=dly, on_pre='ge += 0.25*we')
S37_111_125.connect(True, p = 0.20)
S38_121_125 = Synapses(msnd1_core_121, nacc_in_125, delay=dly, on_pre='gi += wi')
S38_121_125.connect(True, p = 0.25)
S39_122_125 = Synapses(msnd2_core_122, nacc_in_125, delay=dly, on_pre='gi += wi')
S39_122_125.connect(True, p = 0.25)
S40_123_125 = Synapses(msnd1_shell_123, nacc_in_125, delay=dly, on_pre='gi += wi')
S40_123_125.connect(True, p = 0.25)
S41_124_125 = Synapses(msnd2_shell_124, nacc_in_125, delay=dly, on_pre='gi += wi')
S41_124_125.connect(True, p = 0.25)
# 141 Ventral_GPe_141
S42_1040_141 = Synapses(PG_BG_1040, Ventral_GPe_141, delay=dly, on_pre='ge += 2*we')
S42_1040_141.connect(True, p = 0.25)
S43_122_141 = Synapses(msnd2_core_122, Ventral_GPe_141, delay=dly, on_pre='gi += wi')
S43_122_141.connect(True, p = 0.25)
S44_124_141 = Synapses(msnd2_shell_124, Ventral_GPe_141, delay=dly, on_pre='gi += wi')
S44_124_141.connect(True, p = 0.25)
S45_143_141 = Synapses(Ventral_STN_143, Ventral_GPe_141, delay=dly, on_pre='ge += we')
S45_143_141.connect(True, p = 0.25)
# 142 Ventral_GPi_142
S46_1040_142 = Synapses(PG_BG_1040, Ventral_GPi_142, delay=dly, on_pre='ge += 2*we')
S46_1040_142.connect(True, p = 0.25)
S47_121_142 = Synapses(msnd1_core_121, Ventral_GPi_142, delay=dly, on_pre='gi += wi')
S47_121_142.connect(True, p = 0.25)
S48_123_142 = Synapses(msnd1_shell_123, Ventral_GPi_142, delay=dly, on_pre='gi += wi')
S48_123_142.connect(True, p = 0.25)
S49_141_142 = Synapses(Ventral_GPe_141, Ventral_GPi_142, delay=dly, on_pre='gi += wi')
S49_141_142.connect(True, p = 0.25)
S93_143_142 = Synapses(Ventral_STN_143, Ventral_GPi_142, delay=dly, on_pre='ge += .1*wi')
S93_143_142.connect(True, p = 0.25)
# 143 Ventral_STN_143
S50_111_143 = Synapses(ACA_Pyramid_111, Ventral_STN_143, delay=dly, on_pre='ge += 0.5*we')
S50_111_143.connect(True, p = 0.25)
S51_141_143 = Synapses(Ventral_GPe_141, Ventral_STN_143, delay=dly, on_pre='gi += wi')
S51_141_143.connect(True, p = 0.25)
S94_142_143 = Synapses(Ventral_GPi_142, Ventral_STN_143, delay=dly, on_pre='gi += .1*wi')
S94_142_143.connect(True, p = 0.25)
# 151 Ventral_THL_151
S52_1051_151 = Synapses(PG_Ventral_THL_1051, Ventral_THL_151, delay=dly, on_pre='ge += 0.20*we') #agirlik 0.20 ye indirildi. 20200429 re
S52_1051_151.connect(True, p = 0.25)
S53_142_151 = Synapses(Ventral_GPi_142, Ventral_THL_151, delay=dly, on_pre='gi += 2.5*wi')
S53_142_151.connect(True, p = 0.5)
# 131 VTA
S54_1011_131 = Synapses(PG_ACA_pyramid_1011, VTA_DA_131, 'w :siemens', delay=dly, on_pre='ge += w')
S54_1011_131.connect(True, p = 0.25)
S54_1011_131.w=we*0.5
S92_211_131 = Synapses(PFC_Pyramid_211, VTA_DA_131, 'w :siemens', delay=dly, on_pre='ge += w')
S92_211_131.connect(True, p = 0.25)
S92_211_131.w=we*0.5
###################################################
################ ----- Dorsal Synapses -------------- ######
## 211 PFC_Pyramid_211
S56_2011_211 = Synapses(PG_PFC_pyramid_2011, PFC_Pyramid_211, 'w :siemens', delay=dly, on_pre='ge += w')
S56_2011_211.connect(True, p = 0.25)
S56_2011_211.w=we*0
S57_212_211 = Synapses(PFC_in_212, PFC_Pyramid_211, delay=dly, on_pre='gi += wi')
S57_212_211.connect(True, p = 0.25)
#thalamocortical synapses
S58_151_211 = Synapses(Ventral_THL_151, PFC_Pyramid_211, 'w :siemens', delay=dly, on_pre='ge += w')
S58_151_211.connect(True, p = 0.5) # olasilik 0.5 e cikarildi re 20200429
S58_151_211.w=we*0.25
S59_251_211 = Synapses(Dorsal_THL_251, PFC_Pyramid_211, 'w :siemens', delay=dly, on_pre='ge += w')
S59_251_211.connect(True, p = 0.25)
S59_251_211.w=we*0.25
# 212 IN
S60_2012_212 = Synapses(PG_PFC_in_2012, PFC_in_212, delay=dly, on_pre='ge += 5*we')
S60_2012_212.connect(True, p = 0.25)
S61_211_212 = Synapses(PFC_Pyramid_211, PFC_in_212, delay=dly, on_pre='ge += we')
S61_211_212.connect(True, p = 0.25)
# 2 Caudate
# 221 Caudate MSND1
dorsal_w_factor=1.1
S62_211_221 = Synapses(PFC_Pyramid_211, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_glu += w')
S62_211_221.connect(True, p = 0.25)
S62_211_221.w=w_cse*dorsal_w_factor
S63_223_221 = Synapses(caudate_in_223, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S63_223_221.connect(True, p = 0.25)
S63_223_221.w=wi
S64_251_221 = Synapses( Dorsal_THL_251, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_glu += w')
S64_251_221.connect(True, p = 0.25)
S64_251_221.w=w_tse*dorsal_w_factor
S65_231_221 = Synapses(SNc_DA_231, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_DA += w')
S65_231_221.connect(True, p = 0.25)
S65_231_221.w=w_vse*dorsal_w_factor
##### Colateral inhibitions from MSNs
S66_221_221 = Synapses(msnd1_caudate_221, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S66_221_221.connect(True, p = 0.05)
S66_221_221.w=wi
S67_222_221 = Synapses(msnd2_caudate_222, msnd1_caudate_221, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S67_222_221.connect(True, p = 0.25)
S67_222_221.w=wi*2
# 222 Caudate MSND2
S68_211_222 = Synapses(PFC_Pyramid_211, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_glu += w')
S68_211_222.connect(True, p = 0.25)
S68_211_222.w=w_cse*dorsal_w_factor
S69_223_222 = Synapses(caudate_in_223, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_Ach += w')
S69_223_222.connect(True, p = 0.25)
S69_223_222.w=wi
S70_251_222 = Synapses(Dorsal_THL_251, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_glu += w')
S70_251_222.connect(True, p = 0.25)
S70_251_222.w=w_tse*dorsal_w_factor
S71_231_222 = Synapses(SNc_DA_231, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_DA += w')
S71_231_222.connect(True, p = 0.25)
S71_231_222.w=w_vsi*dorsal_w_factor
##### Colateral inhibitions from MSNs
S72_221_222 = Synapses(msnd1_caudate_221, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S72_221_222.connect(True, p = 0.25)
S72_221_222.w=wi*2
S73_222_222 = Synapses(msnd2_caudate_222, msnd2_caudate_222, 'w :siemens', delay=dly, on_pre='g_GABA += w')
S73_222_222.connect(True, p = 0.05)
S73_222_222.w=wi
# 223 Caudate IN
S74_211_223 = Synapses(PFC_Pyramid_211, caudate_in_223, delay=dly, on_pre='ge += 0.25*we')
S74_211_223.connect(True, p = 0.20)
S75_221_223 = Synapses(msnd1_caudate_221, caudate_in_223, delay=dly, on_pre='gi += wi')
S75_221_223.connect(True, p = 0.25)
S76_222_223 = Synapses(msnd2_caudate_222, caudate_in_223, delay=dly, on_pre='gi += wi')
S76_222_223.connect(True, p = 0.25)
# 31 Dorsal_GPe_241
S77_2040_241 = Synapses(PG_BG_2040, Dorsal_GPe_241, delay=dly, on_pre='ge += 2*we')
S77_2040_241.connect(True, p = 0.25)
S78_222_241 = Synapses(msnd2_caudate_222, Dorsal_GPe_241, delay=dly, on_pre='gi += wi')
S78_222_241.connect(True, p = 0.25)
S79_243_241 = Synapses(Dorsal_STN_243, Dorsal_GPe_241, delay=dly, on_pre='ge += we')
S79_243_241.connect(True, p = 0.25)
# 32 Dorsal_GPi_242
S80_2040_242 = Synapses(PG_BG_2040, Dorsal_GPi_242, delay=dly, on_pre='ge += 2*we')
S80_2040_242.connect(True, p = 0.25)
S81_221_242 = Synapses(msnd1_caudate_221, Dorsal_GPi_242, delay=dly, on_pre='gi += wi')
S81_221_242.connect(True, p = 0.25)
S82_241_242 = Synapses(Dorsal_GPe_241, Dorsal_GPi_242, delay=dly, on_pre='gi += wi')
S82_241_242.connect(True, p = 0.25)
# 33 Dorsal_STN_243
S83_211_243 = Synapses(PFC_Pyramid_211, Dorsal_STN_243, delay=dly, on_pre='ge += 0.5*we')
S83_211_243.connect(True, p = 0.25)
S84_241_243 = Synapses(Dorsal_GPe_241, Dorsal_STN_243, delay=dly, on_pre='gi += wi')
S84_241_243.connect(True, p = 0.25)
# 41 Dorsal_THL_251
S85_2051_251 = Synapses(PG_Dorsal_THL_2051, Dorsal_THL_251, delay=dly, on_pre='ge += 0.15*we')
S85_2051_251.connect(True, p = 0.25)
S86_242_251 = Synapses(Dorsal_GPi_242, Dorsal_THL_251, delay=dly, on_pre='gi += wi')
S86_242_251.connect(True, p = 0.25)
# 231 SNc
S87_2011_231 = Synapses(PG_PFC_pyramid_2011, SNc_DA_231, 'w :siemens', delay=dly, on_pre='ge += w')
S87_2011_231.connect(True, p = 0.25)
S87_2011_231.w=we
###############################################################################
############## ---------------- Motor Cortex ----------------------- #########
###############################################################################
#### MC 311
S88_312_311 = Synapses(MC_in_312, MC_Pyramid_311, delay=dly, on_pre='gi += wi')
S88_312_311.connect(True, p = 0.25)
#thalamocortical synapses
S89_251_311 = Synapses(Dorsal_THL_251, MC_Pyramid_311, 'w :siemens', delay=dly, on_pre='ge += w')
S89_251_311.connect(True, p = 0.25)
S89_251_311.w=we
# 312 IN
S90_2012_312 = Synapses(PG_PFC_in_2012, MC_in_312, delay=dly, on_pre='ge += 5*we')
S90_2012_312.connect(True, p = 0.25)
S91_311_312 = Synapses(MC_Pyramid_311, MC_in_312, delay=dly, on_pre='ge += we')
S91_311_312.connect(True, p = 0.25)
#==============================================================================
#==============================================================================
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
##Ventral Poisson
S01_1011_111.w=we*0
S54_1011_131.w=we*0
##Dorsal Poisson
S56_2011_211.w=we*0 #Poisson to PFC
S87_2011_231.w=we*0 #Poisson to SNc
print("----------------------------------------------")
print('100 ms initial conditions delay')
print("sim_time="+str(duration1))
run(duration1, report='text')
##Ventral Poisson
S01_1011_111.w=we*.75 ############# ACA Cortex
S54_1011_131.w=we ############# VTA DA
##Dorsal Poisson
S56_2011_211.w=we*0 ############# PFC Cortex
S87_2011_231.w=we*0.1 ############# SNc DA
###############################################################################
##################### ---- Monitors ---- ######################################
###############################################################################
print('Monitors')
############ Ventral ####################
trace_ACA_Pyramid_111 = StateMonitor(ACA_Pyramid_111, 'v', record=9)
spikes_ACA_Pyramid_111 = SpikeMonitor(ACA_Pyramid_111)
trace_ACA_in_112 = StateMonitor(ACA_in_112, 'v', record=9)
spikes_ACA_in_112 = SpikeMonitor(ACA_in_112)
trace_msnd1_core_121 = StateMonitor(msnd1_core_121, 'v', record=True)
spikes_msnd1_core_121 = SpikeMonitor(msnd1_core_121)
trace_I_s_msnd1_core = StateMonitor(msnd1_core_121, 'Is', record=True)
trace_msnd2_core_122 = StateMonitor(msnd2_core_122, 'v', record=True)
spikes_msnd2_core_122 = SpikeMonitor(msnd2_core_122)
trace_I_s_msnd2_core = StateMonitor(msnd2_core_122, 'Is', record=True)
trace_msnd1_shell_123 = StateMonitor(msnd1_shell_123, 'v', record=True)
spikes_msnd1_shell_123 = SpikeMonitor(msnd1_shell_123)
trace_I_s_msnd1_shell = StateMonitor(msnd1_shell_123, 'Is', record=True)