Debian Codegraph @

examples/frompapers/Jansen_Rit_1995_single_column.py

raw
1 #!/usr/bin/env python
2 # coding: utf-8
3 """
4 [Jansen and Rit 1995 model](https://link.springer.com/content/pdf/10.1007/BF00199471.pdf) (Figure 3) in Brian2.
5
6 Equations are the system of differential equations number (6) in the original paper.
7 The rate parameters $a=100 s^{-1}$ and $b=200 s^{-1}$ were changed to excitatory $\tau_e = 1000ms/a =10ms$ and inhibitory $\tau_i = 1000ms/b =20ms$ time constants as in
8 [Thomas Knosche review](https://link.springer.com/referenceworkentry/10.1007%2F978-1-4614-6675-8_65),
9 [Touboul et al. 2011](https://direct.mit.edu/neco/article-abstract/23/12/3232/7717/Neural-Mass-Activity-Bifurcations-and-Epilepsy?redirectedFrom=fulltext), or
10 [David & Friston 2003](https://www.sciencedirect.com/science/article/pii/S1053811903004579).
11 Units were removerd from parameters $e_0$, $v_0$, $r_0$, $A$, $B$, and $p$ to stop Brian's confusion.
12
13 Ruben Tikidji-Hamburyan 2021 ([email protected])
14 """
15
16
17
18 from numpy import *
19 from numpy import random as rnd
20 from matplotlib.pyplot import *
21 from brian2 import *
22
23 defaultclock.dt = .1*ms #default time step
24
25 te,ti = 10.*ms, 20.*ms #taus for excitatory and inhibitory populations
26 e0 = 5. #max firing rate
27 v0 = 6. #(max FR)/2 input
28 r0 = 0.56 #gain rate
29 A,B,C = 3.25, 22., 135 #standard parameters as in the set (7) of the original paper
30 P,deltaP = 120, 320.-120 #random input uniformly distributed between 120 and
31 #320 pulses per second
32
33 # Random noise
34 nstim = TimedArray(rnd.rand(70000),2*ms)
35
36 # Equations as in the system (6) of the original paper
37 equs = """
38 dy0/dt = y3 /second : 1
39 dy3/dt = (A * Sp -2*y3 -y0/te*second)/te : 1
40 dy1/dt = y4 /second : 1
41 dy4/dt = (A*(p+ C2 * Se)-2*y4 -y1/te*second)/te : 1
42 dy2/dt = y5 /second : 1
43 dy5/dt = (B * C4 * Si -2*y5 -y2/ti*second)/ti : 1
44 p = P0+nstim(t)*dlP : 1
45 Sp = e0/(1+exp(r0*(v0 - (y1-y2) ))) : 1
46 Se = e0/(1+exp(r0*(v0 - C1*y0 ))) : 1
47 Si = e0/(1+exp(r0*(v0 - C3*y0 ))) : 1
48 C1 : 1
49 C2 = 0.8 *C1 : 1
50 C3 = 0.25*C1 : 1
51 C4 = 0.25*C1 : 1
52 P0 : 1
53 dlP : 1
54 """
55
56 n = NeuronGroup(6,equs,method='euler') #creates 6 JR models for different connectivity parameters
57
58 #set parameters as for different traces on figure 3 of the original paper
59 n.C1[0] = 68
60 n.C1[1] = 128
61 n.C1[2] = C
62 n.C1[3] = 270
63 n.C1[4] = 675
64 n.C1[5] = 1350
65 #set stimulus offset and noise magnitude
66 n.P0 = P
67 n.dlP = deltaP
68
69 #just record everything
70 sm = StateMonitor(n,['y4','y1','y3','y0','y5','y2'],record=True)
71
72 #Runs for 5 second
73 run(5*second,report='text')
74
75
76 #This code goes over all models with different parameters and plot activity of each population.
77
78 figure(1,figsize=(22,16))
79 idx1 = where(sm.t/second>2.)[0]
80
81 o = 0
82 for p in [0,1,2,3,4,5]:
83 if o == 0: ax = subplot(6,3,1)
84 else :subplot(6,3,1+o,sharex=ax)
85 if o == 0: title("E")
86 plot(sm.t[idx1]/second, sm[p].y1[idx1],'g-')
87 ylabel(f"C={n[p].C1[0]}")
88 if o == 15: xlabel("Time (seconds)")
89 subplot(6,3,2+o,sharex=ax)
90 if o == 0: title("P")
91 plot(sm.t[idx1]/second, sm[p].y0[idx1],'b-')
92 if o == 15: xlabel("Time (seconds)")
93 subplot(6,3,3+o,sharex=ax)
94 if o == 0: title("I")
95 plot(sm.t[idx1]/second, sm[p].y2[idx1],'r-')
96 if o == 15: xlabel("Time (seconds)")
97 o += 3
98
99 show()