Skip to content

Commit 16ce828

Browse files
author
Daniel Incicau
committed
Refactoring
1 parent 8a70d9a commit 16ce828

10 files changed

+315
-505
lines changed

equations.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
I = g_e*(E_e - v) + g_i*(E_i - v) : amp
1919
'''
2020

21-
# Equations for PYR (excitatory) neurons
22-
eqs_exc = '''
21+
# Equations for PYR (excitatory) neurons WITH dendrites
22+
eqs_exc_with_dendrite = '''
2323
dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)
2424
2525
dg_es/dt = -g_es/tau_E : siemens
@@ -34,4 +34,14 @@
3434
3535
I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp
3636
K : 1
37+
'''
38+
39+
# Equations for PYR (excitatory) neurons WITHOUT dendrites
40+
eqs_exc_without_dendrite = '''
41+
dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)
42+
43+
dg_es/dt = -g_es/tau_E : siemens
44+
dg_is/dt = -g_is/tau_I : siemens
45+
46+
I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp
3747
'''

input_amplitude_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ def run_input_amplitude_simulation(params, input_amplitudes, seed_val=12345):
4949
params_with_input["pSST_CS_soma"] = [0] # all probability goes to CS dendrite
5050
params_with_input["pSST_CC_soma"] = [0] # all probability goes to CC dendrite
5151

52-
result_without_sst_soma, _ = run_simulation_for_input(params_with_input, seed_val=seed_val, use_synaptic_probabilities=True)
52+
results = run_simulation_for_input(params_with_input, seed_val=seed_val, use_synaptic_probabilities=True, use_dendrite_model=True)
53+
54+
assert len(results) == 1
55+
result_without_sst_soma = results[0]
5356
results_without_sst_soma.append(result_without_sst_soma)
5457

5558

layer5_CC_CS.py

Lines changed: 208 additions & 477 deletions
Large diffs are not rendered by default.

notebooks/layer5_CC_CS_connection.ipynb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"PLOT_ONLY_FROM_EQUILIBRIUM=True\n",
2828
"BIN_SIZE_FIRING_RATE = 10\n",
2929
"USE_SYNAPSE_PROBS = True\n",
30+
"USE_DENDRITE_MODEL = True\n",
3031
"\n",
3132
"\n",
3233
"index_to_ntype_dict = {\n",
@@ -150,6 +151,7 @@
150151
"metadata": {},
151152
"outputs": [],
152153
"source": [
154+
"# Equations for SST (inhibitory) neurons\n",
153155
"eqs_sst_inh = '''\n",
154156
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
155157
"\n",
@@ -159,6 +161,7 @@
159161
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
160162
"'''\n",
161163
"\n",
164+
"# Equations for PV (inhibitory) neurons\n",
162165
"eqs_pv_inh = '''\n",
163166
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
164167
"\n",
@@ -168,7 +171,8 @@
168171
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
169172
"'''\n",
170173
"\n",
171-
"eqs_exc = '''\n",
174+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
175+
"eqs_exc_with_dendrite = '''\n",
172176
" dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)\n",
173177
"\n",
174178
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -183,6 +187,16 @@
183187
"\n",
184188
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
185189
" K : 1\n",
190+
"'''\n",
191+
"\n",
192+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
193+
"eqs_exc_without_dendrite = '''\n",
194+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
195+
"\n",
196+
" dg_es/dt = -g_es/tau_E : siemens\n",
197+
" dg_is/dt = -g_is/tau_I : siemens\n",
198+
"\n",
199+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
186200
"'''"
187201
]
188202
},
@@ -263,7 +277,7 @@
263277
" pv_input_i = PoissonInput(pv_neurons, 'g_e', N=1, rate=lambda_pv, weight=f'I_ext_pv(t, {n_idx})')\n",
264278
"\n",
265279
" # CS Neurons\n",
266-
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc, threshold='v_s > V_t',\n",
280+
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
267281
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
268282
" cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
269283
" cs_neurons.v_d = -70 * mV\n",
@@ -273,7 +287,7 @@
273287
" cs_input_i = PoissonInput(cs_neurons, 'g_es', N=1, rate=lambda_cs, weight=f'I_ext_cs(t, {n_idx})')\n",
274288
"\n",
275289
" # CC Neurons\n",
276-
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
290+
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
277291
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
278292
" cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
279293
" cc_neurons.v_d = -70 * mV\n",

notebooks/layer5_SST_Soma_selectivity.ipynb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"PLOT_ONLY_FROM_EQUILIBRIUM=True\n",
2828
"BIN_SIZE_FIRING_RATE = 10\n",
2929
"USE_SYNAPSE_PROBS = True\n",
30+
"USE_DENDRITE_MODEL = True\n",
3031
"\n",
3132
"\n",
3233
"index_to_ntype_dict = {\n",
@@ -47,7 +48,6 @@
4748
"metadata": {},
4849
"outputs": [],
4950
"source": [
50-
"\n",
5151
"################################################################################\n",
5252
"# Model parameters\n",
5353
"################################################################################\n",
@@ -151,6 +151,7 @@
151151
"metadata": {},
152152
"outputs": [],
153153
"source": [
154+
"# Equations for SST (inhibitory) neurons\n",
154155
"eqs_sst_inh = '''\n",
155156
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
156157
"\n",
@@ -160,6 +161,7 @@
160161
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
161162
"'''\n",
162163
"\n",
164+
"# Equations for PV (inhibitory) neurons\n",
163165
"eqs_pv_inh = '''\n",
164166
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
165167
"\n",
@@ -169,7 +171,8 @@
169171
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
170172
"'''\n",
171173
"\n",
172-
"eqs_exc = '''\n",
174+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
175+
"eqs_exc_with_dendrite = '''\n",
173176
" dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)\n",
174177
"\n",
175178
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -184,6 +187,16 @@
184187
"\n",
185188
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
186189
" K : 1\n",
190+
"'''\n",
191+
"\n",
192+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
193+
"eqs_exc_without_dendrite = '''\n",
194+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
195+
"\n",
196+
" dg_es/dt = -g_es/tau_E : siemens\n",
197+
" dg_is/dt = -g_is/tau_I : siemens\n",
198+
"\n",
199+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
187200
"'''"
188201
]
189202
},
@@ -264,7 +277,7 @@
264277
" pv_input_i = PoissonInput(pv_neurons, 'g_e', N=1, rate=lambda_pv, weight=f'I_ext_pv(t, {n_idx})')\n",
265278
"\n",
266279
" # CS Neurons\n",
267-
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc, threshold='v_s > V_t',\n",
280+
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
268281
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
269282
" cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
270283
" cs_neurons.v_d = -70 * mV\n",
@@ -274,7 +287,7 @@
274287
" cs_input_i = PoissonInput(cs_neurons, 'g_es', N=1, rate=lambda_cs, weight=f'I_ext_cs(t, {n_idx})')\n",
275288
"\n",
276289
" # CC Neurons\n",
277-
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
290+
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
278291
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
279292
" cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
280293
" cc_neurons.v_d = -70 * mV\n",

notebooks/layer5_sandbox.ipynb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"metadata": {},
115115
"outputs": [],
116116
"source": [
117+
"# Equations for SST (inhibitory) neurons\n",
117118
"eqs_sst_inh = '''\n",
118119
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
119120
"\n",
@@ -123,6 +124,7 @@
123124
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
124125
"'''\n",
125126
"\n",
127+
"# Equations for PV (inhibitory) neurons\n",
126128
"eqs_pv_inh = '''\n",
127129
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
128130
"\n",
@@ -132,7 +134,8 @@
132134
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
133135
"'''\n",
134136
"\n",
135-
"eqs_exc = '''\n",
137+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
138+
"eqs_exc_with_dendrite = '''\n",
136139
" dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)\n",
137140
"\n",
138141
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -147,6 +150,16 @@
147150
"\n",
148151
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
149152
" K : 1\n",
153+
"'''\n",
154+
"\n",
155+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
156+
"eqs_exc_without_dendrite = '''\n",
157+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
158+
"\n",
159+
" dg_es/dt = -g_es/tau_E : siemens\n",
160+
" dg_is/dt = -g_is/tau_I : siemens\n",
161+
"\n",
162+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
150163
"'''"
151164
]
152165
},
@@ -176,7 +189,7 @@
176189
" pv_input_i = PoissonInput(pv_neurons, 'g_e', N=1, rate=lambda_pv, weight=I_ext_pv[n_idx]*nS)\n",
177190
"\n",
178191
"# CS Neurons\n",
179-
"cs_neurons = NeuronGroup(N_cs, model=eqs_exc, threshold='v_s > V_t',\n",
192+
"cs_neurons = NeuronGroup(N_cs, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
180193
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
181194
"cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
182195
"cs_neurons.v_d = -70 * mV\n",
@@ -186,7 +199,7 @@
186199
" cs_input_i = PoissonInput(cs_neurons, 'g_es', N=1, rate=lambda_cs, weight=I_ext_cs[n_idx]*nS)\n",
187200
"\n",
188201
"# CC Neurons\n",
189-
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
202+
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
190203
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
191204
"cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
192205
"cc_neurons.v_d = -70 * mV\n",
@@ -953,7 +966,7 @@
953966
"name": "python",
954967
"nbconvert_exporter": "python",
955968
"pygments_lexer": "ipython3",
956-
"version": "3.9.14"
969+
"version": "3.10.6"
957970
}
958971
},
959972
"nbformat": 4,

notebooks/test_different_inputs.ipynb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"metadata": {},
119119
"outputs": [],
120120
"source": [
121+
"# Equations for SST (inhibitory) neurons\n",
121122
"eqs_sst_inh = '''\n",
122123
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
123124
"\n",
@@ -127,6 +128,7 @@
127128
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
128129
"'''\n",
129130
"\n",
131+
"# Equations for PV (inhibitory) neurons\n",
130132
"eqs_pv_inh = '''\n",
131133
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
132134
"\n",
@@ -136,7 +138,8 @@
136138
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
137139
"'''\n",
138140
"\n",
139-
"eqs_exc = '''\n",
141+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
142+
"eqs_exc_with_dendrite = '''\n",
140143
" dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)\n",
141144
"\n",
142145
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -151,6 +154,16 @@
151154
"\n",
152155
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
153156
" K : 1\n",
157+
"'''\n",
158+
"\n",
159+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
160+
"eqs_exc_without_dendrite = '''\n",
161+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
162+
"\n",
163+
" dg_es/dt = -g_es/tau_E : siemens\n",
164+
" dg_is/dt = -g_is/tau_I : siemens\n",
165+
"\n",
166+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
154167
"'''"
155168
]
156169
},
@@ -176,15 +189,15 @@
176189
"pv_neurons.g_i = 'rand()*w_i'\n",
177190
"\n",
178191
"# CS Neurons\n",
179-
"cs_neurons = NeuronGroup(N_cs, model=eqs_exc, threshold='v_s > V_t',\n",
192+
"cs_neurons = NeuronGroup(N_cs, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
180193
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
181194
"cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
182195
"cs_neurons.v_d = -70 * mV\n",
183196
"cs_neurons.g_es = cs_neurons.g_ed = 'rand()*w_e'\n",
184197
"cs_neurons.g_is = cs_neurons.g_id = 'rand()*w_i'\n",
185198
"\n",
186199
"# CC Neurons\n",
187-
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
200+
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
188201
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
189202
"cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
190203
"cc_neurons.v_d = -70 * mV\n",
@@ -509,7 +522,7 @@
509522
"name": "python",
510523
"nbconvert_exporter": "python",
511524
"pygments_lexer": "ipython3",
512-
"version": "3.9.14"
525+
"version": "3.10.6"
513526
}
514527
},
515528
"nbformat": 4,

notebooks/test_single_neurons.ipynb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,17 @@
100100
"metadata": {},
101101
"outputs": [],
102102
"source": [
103+
"# Equations for SST (inhibitory) neurons\n",
103104
"eqs_sst_inh = '''\n",
104105
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
105106
"\n",
106107
" dg_e/dt = -g_e/tau_E : siemens\n",
107108
" dg_i/dt = -g_i/tau_I : siemens\n",
108-
"\n",
109+
" \n",
109110
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
110111
"'''\n",
111112
"\n",
113+
"# Equations for PV (inhibitory) neurons\n",
112114
"eqs_pv_inh = '''\n",
113115
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
114116
"\n",
@@ -118,7 +120,8 @@
118120
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
119121
"'''\n",
120122
"\n",
121-
"eqs_exc = '''\n",
123+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
124+
"eqs_exc_with_dendrite = '''\n",
122125
" dv_s/dt = ((E_l-v_s)/tau_S + (g_s*(1/(1+exp(-(v_d-E_d)/D_d))) + I_s)/C_S) : volt (unless refractory)\n",
123126
"\n",
124127
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -133,6 +136,16 @@
133136
"\n",
134137
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
135138
" K : 1\n",
139+
"'''\n",
140+
"\n",
141+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
142+
"eqs_exc_without_dendrite = '''\n",
143+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
144+
"\n",
145+
" dg_es/dt = -g_es/tau_E : siemens\n",
146+
" dg_is/dt = -g_is/tau_I : siemens\n",
147+
"\n",
148+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
136149
"'''"
137150
]
138151
},
@@ -144,7 +157,7 @@
144157
"outputs": [],
145158
"source": [
146159
"# CC Neurons\n",
147-
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
160+
"cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
148161
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
149162
"cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
150163
"cc_neurons.v_d = -70 * mV\n",
@@ -369,7 +382,7 @@
369382
"name": "python",
370383
"nbconvert_exporter": "python",
371384
"pygments_lexer": "ipython3",
372-
"version": "3.9.14"
385+
"version": "3.10.6"
373386
}
374387
},
375388
"nbformat": 4,

0 commit comments

Comments
 (0)