Skip to content

Commit 48e85e0

Browse files
authored
Merge pull request #22 from DanInci/feature/configurable_exh_neurons_with_dendrites
Refactoring
2 parents 8a70d9a + f235807 commit 48e85e0

11 files changed

+634
-722
lines changed

equations.py

Lines changed: 13 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,15 @@
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
47+
K : 1
3748
'''

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: 309 additions & 504 deletions
Large diffs are not rendered by default.

notebooks/layer5_CC_CS_connection.ipynb

Lines changed: 77 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"PLOT_ONLY_FROM_EQUILIBRIUM=True\n",
28-
"BIN_SIZE_FIRING_RATE = 10\n",
27+
"PLOT_ONLY_FROM_EQUILIBRIUM=True # Plot graphs only from equilibrium time\n",
28+
"BIN_SIZE_FIRING_RATE = 10 # Number of bins for firing rates historgram\n",
2929
"USE_SYNAPSE_PROBS = True\n",
30+
"USE_DENDRITE_MODEL = False\n",
3031
"\n",
3132
"\n",
3233
"index_to_ntype_dict = {\n",
@@ -36,8 +37,8 @@
3637
" 3: 'PV'\n",
3738
"}\n",
3839
"\n",
39-
"equilibrium_t = 0.2*second\n",
40-
"no_simulations = 20"
40+
"equilibrium_t = 0.2*second # Default equilibirium time. Should be set based on previous simulation results\n",
41+
"no_simulations = 20 # Number of simulations to be conducted & their results are averaged"
4142
]
4243
},
4344
{
@@ -50,28 +51,29 @@
5051
"################################################################################\n",
5152
"# Model parameters\n",
5253
"################################################################################\n",
54+
"\n",
5355
"### General parameters\n",
5456
"duration = 3*second # Total simulation time\n",
55-
"sim_dt = 0.1*ms # Integrator/sampling step\n",
57+
"sim_dt = 0.1*ms # Integrator/sampling step\n",
5658
"\n",
57-
"N_sst = 34 # Number of SST neurons (inhibitory)\n",
58-
"N_pv = 46 # Number of PV neurons (inhibitory)\n",
59-
"N_cc = 275 # Number of CC neurons (excitatory)\n",
60-
"N_cs = 45 # Number of CS neurons (excitatory)\n",
59+
"N_sst = 34 # Number of SST neurons (inhibitory)\n",
60+
"N_pv = 46 # Number of PV neurons (inhibitory)\n",
61+
"N_cc = 275 # Number of CC (PYR) neurons (excitatory)\n",
62+
"N_cs = 45 # Number of CS (PYR) neurons (excitatory)\n",
6163
"N = [N_cs, N_cc, N_sst, N_pv]\n",
6264
"\n",
6365
"### Neuron parameters\n",
64-
"tau_S = 16*ms # \n",
65-
"tau_D = 7*ms #\n",
66-
"tau_SST = 20*ms #\n",
67-
"tau_PV = 10*ms #\n",
66+
"tau_S = 16*ms # PYR neuron - soma membrane time constant \n",
67+
"tau_D = 7*ms # PYR neuron - dendritic membrane time constant\n",
68+
"tau_SST = 20*ms # SST neuron membrane time constant\n",
69+
"tau_PV = 10*ms # PV neuron membrane time constant\n",
6870
"tau_E = 5*ms # Excitatory synaptic time constant\n",
6971
"tau_I = 10*ms # Inhibitory synaptic time constant\n",
7072
"\n",
71-
"C_S = 370*pF\n",
72-
"C_D = 170*pF\n",
73-
"C_SST = 100*pF\n",
74-
"C_PV = 100*pF\n",
73+
"C_S = 370*pF # PYR neuron - soma membrane capacitance\n",
74+
"C_D = 170*pF # PYR neuron - dendritic membrane capacitance\n",
75+
"C_SST = 100*pF # SST neuron membrane capacitance\n",
76+
"C_PV = 100*pF # PV neuron membrane capacitance\n",
7577
"\n",
7678
"E_l = -70*mV # leak reversal potential\n",
7779
"E_e = 0*mV # Excitatory synaptic reversal potential\n",
@@ -87,26 +89,21 @@
8789
"### Connectivity weight & probabilities\n",
8890
"# CS_CS 0, CS_SST 1, CS_PV 2, SST_CS 3, PV_CS 4, CC_CC 5, CC_SST 6, CC_PV 7, SST_CC 8, PV_CC 9, CC_CS 10, SST_PV 11, SST_SST 12, PV_PV 13, PV_SST 14, \n",
8991
"conn_weights = [0.27, 0.05, 1.01, 0.19, 0.32, 0.24, 0.09, 0.48, 0.19, 0.52, 0.19, 0.18, 0.19, 0.47, 0.44] # in nS\n",
90-
"# If not `USE_SYNAPSE_PROBS`, the topology is maintained as specified with a probability p=1\n",
9192
"if USE_SYNAPSE_PROBS: \n",
9293
" # CS_CS 0, CS_SST 1, CS_PV 2, SST_CS 3, PV_CS 4, CC_CC 5, CC_SST 6, CC_PV 7, SST_CC 8, PV_CC 9, CC_CS 10, SST_PV 11, SST_SST 12, PV_PV 13, PV_SST 14, \n",
9394
" conn_probs = [0.16, 0.23, 0.18, 0.52, 0.43, 0.06, 0.26, 0.22, 0.13, 0.38, 0.09, 0.29, 0.1, 0.5, 0.14]\n",
95+
"# If not `USE_SYNAPSE_PROBS`, the topology is maintained as specified with a probability p=1\n",
9496
"else: \n",
9597
" conn_probs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
9698
"\n",
97-
"### External Input\n",
99+
"### External input amplitude & steady state\n",
98100
"I_sst_amp = 50\n",
99101
"I_pv_amp = 50\n",
100102
"I_cc_amp = 200\n",
101103
"I_cs_amp = 100\n",
102104
"\n",
103-
"I_sst_steady = 0\n",
104-
"I_pv_steady = 0\n",
105-
"I_cc_steady = 0\n",
106-
"I_cs_steady = 0\n",
107-
"\n",
108-
"\n",
109-
"lambda_cs = lambda_cc = lambda_sst = lambda_pv = 10*Hz\n",
105+
"I_sst_steady = I_pv_steady = I_cc_steady = I_cs_steady = 0\n",
106+
"ambda_sst = lambda_pv = lambda_cc = lambda_cs = 10*Hz\n",
110107
"\n",
111108
"input_steady = [I_cs_steady, I_cc_steady, I_sst_steady, I_pv_steady]\n",
112109
"input_amplitudes = [I_cs_amp, I_cc_amp, I_sst_amp, I_pv_amp]\n",
@@ -120,7 +117,10 @@
120117
"spatial_phase = 1\n",
121118
"tsteps = int(duration / sim_dt)\n",
122119
"\n",
120+
"### Simulation weights for CC->CS connection probabilities\n",
123121
"cc_cs_weights = [0, 0.125, 0.25, 0.5, 1, 2, 4, 8]\n",
122+
"\n",
123+
"### Degrees for simulated orientation input\n",
124124
"degrees = [0, 90, 180, 270]\n",
125125
"\n",
126126
"################################################################################"
@@ -150,6 +150,7 @@
150150
"metadata": {},
151151
"outputs": [],
152152
"source": [
153+
"# Equations for SST (inhibitory) neurons\n",
153154
"eqs_sst_inh = '''\n",
154155
" dv/dt = ((E_l-v)/tau_SST + I/C_SST) : volt (unless refractory)\n",
155156
"\n",
@@ -159,6 +160,7 @@
159160
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
160161
"'''\n",
161162
"\n",
163+
"# Equations for PV (inhibitory) neurons\n",
162164
"eqs_pv_inh = '''\n",
163165
" dv/dt = ((E_l-v)/tau_PV + I/C_PV) : volt (unless refractory)\n",
164166
"\n",
@@ -168,7 +170,8 @@
168170
" I = g_e*(E_e - v) + g_i*(E_i - v) : amp\n",
169171
"'''\n",
170172
"\n",
171-
"eqs_exc = '''\n",
173+
"# Equations for PYR (excitatory) neurons WITH dendrites\n",
174+
"eqs_exc_with_dendrite = '''\n",
172175
" 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",
173176
"\n",
174177
" dg_es/dt = -g_es/tau_E : siemens\n",
@@ -183,6 +186,17 @@
183186
"\n",
184187
" I_d = g_ed*(E_e - v_d) + g_id*(E_i - v_d) : amp\n",
185188
" K : 1\n",
189+
"'''\n",
190+
"\n",
191+
"# Equations for PYR (excitatory) neurons WITHOUT dendrites\n",
192+
"eqs_exc_without_dendrite = '''\n",
193+
" dv_s/dt = ((E_l-v_s)/tau_S + I_s/C_S) : volt (unless refractory)\n",
194+
"\n",
195+
" dg_es/dt = -g_es/tau_E : siemens\n",
196+
" dg_is/dt = -g_is/tau_I : siemens\n",
197+
"\n",
198+
" I_s = g_es*(E_e - v_s) + g_is*(E_i - v_s) : amp\n",
199+
" K : 1\n",
186200
"'''"
187201
]
188202
},
@@ -263,20 +277,30 @@
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",
267-
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
268-
" cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
269-
" cs_neurons.v_d = -70 * mV\n",
280+
" if USE_DENDRITE_MODEL:\n",
281+
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
282+
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
283+
" cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
284+
" cs_neurons.v_d = -70 * mV\n",
285+
" else:\n",
286+
" cs_neurons = NeuronGroup(N_cs, model=eqs_exc_without_dendrite, threshold='v_s > V_t',\n",
287+
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
288+
" cs_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
270289
"\n",
271290
" ## Poisson input to CS neurons\n",
272291
" for n_idx in range(N_cs):\n",
273292
" cs_input_i = PoissonInput(cs_neurons, 'g_es', N=1, rate=lambda_cs, weight=f'I_ext_cs(t, {n_idx})')\n",
274293
"\n",
275294
" # CC Neurons\n",
276-
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc, threshold='v_s > V_t',\n",
277-
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
278-
" cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
279-
" cc_neurons.v_d = -70 * mV\n",
295+
" if USE_DENDRITE_MODEL:\n",
296+
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc_with_dendrite, threshold='v_s > V_t',\n",
297+
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
298+
" cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
299+
" cc_neurons.v_d = -70 * mV\n",
300+
" else:\n",
301+
" cc_neurons = NeuronGroup(N_cc, model=eqs_exc_without_dendrite, threshold='v_s > V_t',\n",
302+
" reset='v_s = E_l', refractory=8.3 * ms, method='euler')\n",
303+
" cc_neurons.v_s = 'E_l + rand()*(V_t-E_l)'\n",
280304
"\n",
281305
" ## Poisson input to CC neurons\n",
282306
" for n_idx in range(N_cc):\n",
@@ -322,26 +346,27 @@
322346
" conn_CCsoma_PV.w = conn_weights[CCsoma_PV]\n",
323347
" \n",
324348
" # SST => PYR dendrite\n",
325-
" ## target CS dendrite\n",
326-
" SST_CSdendrite = 3\n",
327-
" conn_SST_CSdendrite = Synapses(sst_neurons, cs_neurons, model='w: 1', on_pre='g_id+=w*nS', name='SST_CSdendrite') # inhibitory\n",
328-
" conn_SST_CSdendrite_prob = conn_probs[SST_CSdendrite] * sst_dendrite_conn_weight\n",
329-
" conn_SST_CSdendrite.connect(p=conn_SST_CSdendrite_prob) # prob divided between soma & dendrite\n",
330-
" conn_SST_CSdendrite.w = conn_weights[SST_CSdendrite]\n",
331-
"\n",
332-
" ## target CC dendrite\n",
333-
" SST_CCdendrite = 8\n",
334-
" conn_SST_CCdendrite = Synapses(sst_neurons, cc_neurons, model='w: 1', on_pre='g_id+=w*nS', name='SST_CCdendrite') # inhibitory\n",
335-
" conn_SST_CCdendrite_prob = conn_probs[SST_CCdendrite] * sst_dendrite_conn_weight\n",
336-
" conn_SST_CCdendrite.connect(p=conn_SST_CCdendrite_prob) # prob divided between soma & dendrite\n",
337-
" conn_SST_CCdendrite.w = conn_weights[SST_CCdendrite]\n",
349+
" if USE_DENDRITE_MODEL:\n",
350+
" ## target CS dendrite\n",
351+
" SST_CSdendrite = 3\n",
352+
" conn_SST_CSdendrite = Synapses(sst_neurons, cs_neurons, model='w: 1', on_pre='g_id+=w*nS', name='SST_CSdendrite') # inhibitory\n",
353+
" conn_SST_CSdendrite_prob = conn_probs[SST_CSdendrite] * sst_dendrite_conn_weight # prob divided between soma & dendrite\n",
354+
" conn_SST_CSdendrite.connect(p=conn_SST_CSdendrite_prob) \n",
355+
" conn_SST_CSdendrite.w = conn_weights[SST_CSdendrite]\n",
356+
"\n",
357+
" ## target CC dendrite\n",
358+
" SST_CCdendrite = 8\n",
359+
" conn_SST_CCdendrite = Synapses(sst_neurons, cc_neurons, model='w: 1', on_pre='g_id+=w*nS', name='SST_CCdendrite') # inhibitory\n",
360+
" conn_SST_CCdendrite_prob = conn_probs[SST_CCdendrite] * sst_dendrite_conn_weight # prob divided between soma & dendrite\n",
361+
" conn_SST_CCdendrite.connect(p=conn_SST_CCdendrite_prob) \n",
362+
" conn_SST_CCdendrite.w = conn_weights[SST_CCdendrite]\n",
338363
"\n",
339364
" # SST <=> PYR soma\n",
340365
" ## target CS soma\n",
341366
" SST_CSsoma = 3\n",
342367
" conn_SST_CSsoma = Synapses(sst_neurons, cs_neurons, model='w: 1', on_pre='g_is+=w*nS', name='SST_CSsoma') # inhibitory (optional connection)\n",
343-
" conn_SST_CSsoma_prob = conn_probs[SST_CSsoma] * sst_soma_conn_weight\n",
344-
" conn_SST_CSsoma.connect(p=conn_SST_CSsoma_prob) # prob divided between soma & dendrite\n",
368+
" conn_SST_CSsoma_prob = conn_probs[SST_CSsoma] * sst_soma_conn_weight if USE_DENDRITE_MODEL else conn_probs[SST_CSsoma] # prob divided between soma & dendrite only if `USE_DENDRITE_MODEL` \n",
369+
" conn_SST_CSsoma.connect(p=conn_SST_CSsoma_prob) \n",
345370
" conn_SST_CSsoma.w = conn_weights[SST_CSsoma]\n",
346371
"\n",
347372
" CSsoma_SST = 1\n",
@@ -352,8 +377,8 @@
352377
" ## taget CC soma\n",
353378
" SST_CCsoma = 8\n",
354379
" conn_SST_CCsoma = Synapses(sst_neurons, cc_neurons, model='w: 1', on_pre='g_is+=w*nS', name='SST_CCsoma') # inhibitory (optional connection)\n",
355-
" conn_SST_CCsoma_prob = conn_probs[SST_CCsoma] * sst_soma_conn_weight\n",
356-
" conn_SST_CCsoma.connect(p=conn_SST_CCsoma_prob) # prob divided between soma & dendrite\n",
380+
" conn_SST_CCsoma_prob = conn_probs[SST_CCsoma] * sst_soma_conn_weight if USE_DENDRITE_MODEL else conn_probs[SST_CCsoma] # prob divided between soma & dendrite only if `USE_DENDRITE_MODEL` \n",
381+
" conn_SST_CCsoma.connect(p=conn_SST_CCsoma_prob)\n",
357382
" conn_SST_CCsoma.w = conn_weights[SST_CCsoma]\n",
358383
"\n",
359384
" CCsoma_SST = 6\n",

0 commit comments

Comments
 (0)