Skip to content

Commit 8cdd9ba

Browse files
authored
Differentiale static and time-dependent inputs in WC and WW model (#241)
* differentiate static and time-dependent inputs * update example * revert example change * update aln model with correct input_vars
1 parent f940967 commit 8cdd9ba

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

neurolib/models/wc/loadDefaultParams.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ def loadDefaultParams(Cmat=None, Dmat=None, seed=None):
6767
params.mu_inh = 3.0 # inhibitory firing threshold
6868

6969
# values of the external inputs
70-
params.exc_ext = 0 # baseline external input to E
71-
params.inh_ext = 0 # baseline external input to I
70+
params.exc_ext_baseline = 0 # baseline external input to E (static)
71+
params.inh_ext_baseline = 0 # baseline external input to I (static)
72+
params.exc_ext = 0 # time-dependent external input to E
73+
params.inh_ext = 0 # time-dependent external input to I
7274

7375
# ------------------------------------------------------------------------
7476

neurolib/models/wc/timeIntegration.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def timeIntegration(params):
8080
excs = np.zeros((N, startind + len(t)))
8181
inhs = np.zeros((N, startind + len(t)))
8282

83+
exc_ext_baseline = params["exc_ext_baseline"]
84+
inh_ext_baseline = params["inh_ext_baseline"]
85+
8386
exc_ext = mu.adjustArrayShape(params["exc_ext"], excs)
8487
inh_ext = mu.adjustArrayShape(params["inh_ext"], inhs)
8588

@@ -125,6 +128,8 @@ def timeIntegration(params):
125128
inhs,
126129
exc_input_d,
127130
inh_input_d,
131+
exc_ext_baseline,
132+
inh_ext_baseline,
128133
exc_ext,
129134
inh_ext,
130135
tau_exc,
@@ -162,6 +167,8 @@ def timeIntegration_njit_elementwise(
162167
inhs,
163168
exc_input_d,
164169
inh_input_d,
170+
exc_ext_baseline,
171+
inh_ext_baseline,
165172
exc_ext,
166173
inh_ext,
167174
tau_exc,
@@ -192,10 +199,8 @@ def S_I(x):
192199
return 1.0 / (1.0 + np.exp(-a_inh * (x - mu_inh)))
193200

194201
for i in range(startind, startind + len(t)):
195-
196202
# loop through all the nodes
197203
for no in range(N):
198-
199204
# To save memory, noise is saved in the activity array
200205
noise_exc[no] = excs[no, i]
201206
noise_inh[no] = inhs[no, i]
@@ -217,8 +222,9 @@ def S_I(x):
217222
c_excexc * excs[no, i - 1] # input from within the excitatory population
218223
- c_inhexc * inhs[no, i - 1] # input from the inhibitory population
219224
+ exc_input_d[no] # input from other nodes
220-
+ exc_ext[no, i - 1]
221-
) # external input
225+
+ exc_ext_baseline # baseline external input (static)
226+
+ exc_ext[no, i - 1] # time-dependent external input
227+
)
222228
+ exc_ou[no] # ou noise
223229
)
224230
)
@@ -231,8 +237,9 @@ def S_I(x):
231237
* S_I(
232238
c_excinh * excs[no, i - 1] # input from the excitatory population
233239
- c_inhinh * inhs[no, i - 1] # input from within the inhibitory population
234-
+ inh_ext[no, i - 1]
235-
) # external input
240+
+ inh_ext_baseline # baseline external input (static)
241+
+ inh_ext[no, i - 1] # time-dependent external input
242+
)
236243
+ inh_ou[no] # ou noise
237244
)
238245
)
@@ -246,7 +253,7 @@ def S_I(x):
246253
excs[no, i] = 1.0
247254
if excs[no, i] < 0.0:
248255
excs[no, i] = 0.0
249-
256+
250257
if inhs[no, i] > 1.0:
251258
inhs[no, i] = 1.0
252259
if inhs[no, i] < 0.0:

neurolib/models/ww/loadDefaultParams.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ def loadDefaultParams(Cmat=None, Dmat=None, seed=None):
6565
params.tau_exc = 100.0 # ms
6666
params.gamma_exc = 0.641
6767
params.w_exc = 1.0
68-
params.exc_current = 0.382 # nA
68+
params.exc_current_baseline = 0.382 # nA, baseline external input current (static)
69+
params.exc_current = 0 # time-dependent external input current to E
6970

7071
params.a_inh = 0.615 # nC^-1
7172
params.b_inh = 0.177 # kHz
7273
params.d_inh = 87.0 # ms
7374
params.tau_inh = 10.0 # ms
7475
params.w_inh = 0.7
75-
params.inh_current = 0.382 # nA
76+
params.inh_current_baseline = 0.382 # nA, baseline external input current (static)
77+
params.inh_current = 0 # time-dependent external input current to E
7678

7779
params.J_NMDA = 0.15 # nA, excitatory synaptic coupling
7880
params.J_I = 1.0 # nA, inhibitory synaptic coupling

neurolib/models/ww/timeIntegration.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ def timeIntegration(params):
2525
tau_exc = params["tau_exc"]
2626
gamma_exc = params["gamma_exc"]
2727
w_exc = params["w_exc"]
28-
exc_current = params["exc_current"]
28+
exc_current_baseline = params["exc_current_baseline"]
2929

3030
a_inh = params["a_inh"]
3131
b_inh = params["b_inh"]
3232
d_inh = params["d_inh"]
3333
tau_inh = params["tau_exc"]
3434
w_inh = params["w_inh"]
35-
inh_current = params["inh_current"]
35+
inh_current_baseline = params["inh_current_baseline"]
3636

3737
J_NMDA = params["J_NMDA"]
3838
J_I = params["J_I"]
@@ -102,6 +102,9 @@ def timeIntegration(params):
102102
r_exc = np.zeros((N, startind + len(t)))
103103
r_inh = np.zeros((N, startind + len(t)))
104104

105+
exc_current = mu.adjustArrayShape(params["exc_current"], r_exc)
106+
inh_current = mu.adjustArrayShape(params["inh_current"], r_inh)
107+
105108
# ------------------------------------------------------------------------
106109
# Set initial values
107110
# if initial values are just a Nx1 array
@@ -152,12 +155,14 @@ def timeIntegration(params):
152155
gamma_exc,
153156
w_exc,
154157
exc_current,
158+
exc_current_baseline,
155159
a_inh,
156160
b_inh,
157161
d_inh,
158162
tau_inh,
159163
w_inh,
160164
inh_current,
165+
inh_current_baseline,
161166
J_NMDA,
162167
J_I,
163168
w_ee,
@@ -197,12 +202,14 @@ def timeIntegration_njit_elementwise(
197202
gamma_exc,
198203
w_exc,
199204
exc_current,
205+
exc_current_baseline,
200206
a_inh,
201207
b_inh,
202208
d_inh,
203209
tau_inh,
204210
w_inh,
205211
inh_current,
212+
inh_current_baseline,
206213
J_NMDA,
207214
J_I,
208215
w_ee,
@@ -232,16 +239,15 @@ def timeIntegration_njit_elementwise(
232239
r = (a * I - b) / (1.0 - exp(-d * (a * I - b)))
233240
234241
"""
242+
235243
# firing rate transfer function
236244
def r(I, a, b, d):
237245
return (a * I - b) / (1.0 - np.exp(-d * (a * I - b)))
238246

239247
### integrate ODE system:
240248
for i in range(startind, startind + len(t)):
241-
242249
# loop through all the nodes
243250
for no in range(N):
244-
245251
# To save memory, noise is saved in the activity array
246252
noise_se[no] = ses[no, i]
247253
noise_si[no] = sis[no, i]
@@ -257,8 +263,13 @@ def r(I, a, b, d):
257263
se = ses[no, i - 1]
258264
si = sis[no, i - 1]
259265

260-
I_exc = w_exc * exc_current + w_ee * J_NMDA * se - J_I * si + J_NMDA * ses_input_d[no]
261-
I_inh = w_inh * inh_current + J_NMDA * se - si
266+
I_exc = (
267+
w_exc * (exc_current_baseline + exc_current[no, i - 1])
268+
+ w_ee * J_NMDA * se
269+
- J_I * si
270+
+ J_NMDA * ses_input_d[no]
271+
)
272+
I_inh = w_inh * (inh_current_baseline + inh_current[no, i - 1]) + J_NMDA * se - si
262273

263274
r_exc[no, i] = r(I_exc, a_exc, b_exc, d_exc)
264275
r_inh[no, i] = r(I_inh, a_inh, b_inh, d_inh)

0 commit comments

Comments
 (0)