Skip to content

Commit 1fe6204

Browse files
authored
Merge pull request #771 from apdavison/multisynapse3
Add "composed" models allowing multiple post-synaptic receptor types
2 parents 2fc6b50 + 6631ce4 commit 1fe6204

32 files changed

+1743
-211
lines changed

doc/reference/neuronmodels.txt

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ backend simulator.
1515
.. note:: the development version has some support for specifying cell types
1616
using the NineML_ and NeuroML_ formats, but this is not yet available
1717
in the current release.
18-
18+
1919
Standard cell types
2020
===================
2121

@@ -25,24 +25,33 @@ Standard cell types
2525
* :class:`IF_curr_alpha`
2626
* :class:`IF_cond_exp`
2727
* :class:`IF_cond_alpha`
28-
28+
2929
* Integrate-and-fire with adaptation:
3030

3131
* :class:`IF_cond_exp_gsfa_grr`
3232
* :class:`EIF_cond_alpha_isfa_ista`
33-
* :class:`EIF_cond_exp_isfa_ista`
33+
* :class:`EIF_cond_exp_isfa_ista`
3434
* :class:`Izhikevich`
35-
35+
3636
* Hodgkin-Huxley model
3737

3838
* :class:`HH_cond_exp`
3939

40-
* Spike sources (input neurons)
40+
* Spike sources (input neurons)
4141

4242
* :class:`SpikeSourcePoisson`
4343
* :class:`SpikeSourceArray`
4444
* :class:`SpikeSourceInhGamma`
4545

46+
* Composed models:
47+
48+
* :class:`AdExp`
49+
* :class:`LIF`
50+
* :class:`~pyNN.standardmodels.receptors.CurrExpPostSynapticResponse`
51+
* :class:`~pyNN.standardmodels.receptors.CondExpPostSynapticResponse`
52+
* :class:`~pyNN.standardmodels.receptors.CondAlphaPostSynapticResponse`
53+
* :class:`~pyNN.standardmodels.receptors.CondBetaPostSynapticResponse`
54+
4655

4756
Base class
4857
----------
@@ -166,6 +175,51 @@ Spike sources
166175
.. autoattribute:: conductance_based
167176

168177

178+
Composed models
179+
---------------
180+
181+
.. autoclass:: PointNeuron
182+
:members:
183+
:undoc-members:
184+
:show-inheritance:
185+
186+
.. autoattribute:: injectable
187+
.. autoattribute:: conductance_based
188+
189+
.. autoclass:: AdExp
190+
:members:
191+
:undoc-members:
192+
:show-inheritance:
193+
194+
.. autoclass:: LIF
195+
:members:
196+
:undoc-members:
197+
:show-inheritance:
198+
199+
200+
.. currentmodule:: pyNN.standardmodels.receptors
201+
202+
.. autoclass:: CurrExpPostSynapticResponse
203+
:members:
204+
:undoc-members:
205+
:show-inheritance:
206+
207+
.. autoclass:: CondExpPostSynapticResponse
208+
:members:
209+
:undoc-members:
210+
:show-inheritance:
211+
212+
.. autoclass:: CondAlphaPostSynapticResponse
213+
:members:
214+
:undoc-members:
215+
:show-inheritance:
216+
217+
.. autoclass:: CondBetaPostSynapticResponse
218+
:members:
219+
:undoc-members:
220+
:show-inheritance:
221+
222+
169223
Native cell types
170224
=================
171225

doc/standardmodels.txt

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Availability: NEST, NEURON, Brian
2929
============== ============= ===== ========================================
3030
Name Default value Units Description
3131
============== ============= ===== ========================================
32-
``v_rest`` -65.0 mV Resting membrane potential
32+
``v_rest`` -65.0 mV Resting membrane potential
3333
``cm`` 1.0 nF Capacity of the membrane
3434
``tau_m`` 20.0 ms Membrane time constant
3535
``tau_refrac`` 0.1 ms Duration of refractory period
@@ -46,9 +46,9 @@ IF_curr_exp
4646

4747
Leaky integrate and fire model with fixed threshold and decaying-exponential post-synaptic current.
4848
(Separate synaptic currents for excitatory and inhibitory synapses.
49-
49+
5050
Availability: NEST, NEURON, Brian
51-
51+
5252
============== ============= ===== =========================================
5353
Name Default value Units Description
5454
============== ============= ===== =========================================
@@ -74,7 +74,7 @@ Availability: NEST, NEURON, Brian
7474
============== ============= ===== ===================================================
7575
Name Default value Units Description
7676
============== ============= ===== ===================================================
77-
``v_rest`` -65.0 mV Resting membrane potential
77+
``v_rest`` -65.0 mV Resting membrane potential
7878
``cm`` 1.0 nF Capacity of the membrane
7979
``tau_m`` 20.0 ms Membrane time constant
8080
``tau_refrac`` 0.1 ms Duration of refractory period
@@ -92,12 +92,12 @@ IF_cond_exp
9292
-----------
9393

9494
Leaky integrate and fire model with fixed threshold and decaying-exponential post-synaptic conductance.
95-
95+
9696
Availability: NEST, NEURON, Brian
97-
97+
9898
============== ============= ===== ===================================================
9999
Name Default value Units Description
100-
============== ============= ===== ===================================================
100+
============== ============= ===== ===================================================
101101
``v_rest`` -65.0 mV Resting membrane potential
102102
``cm`` 1.0 nF Capacity of the membrane
103103
``tau_m`` 20.0 ms Membrane time constant
@@ -109,19 +109,19 @@ Name Default value Units Description
109109
``v_thresh`` -50.0 mV Spike threshold
110110
``v_reset`` -65.0 mV Reset potential after a spike
111111
``i_offset`` 0.0 nA Offset current
112-
============== ============= ===== ===================================================
112+
============== ============= ===== ===================================================
113113

114114

115115
HH_cond_exp
116116
-----------
117117

118118
Single-compartment Hodgkin-Huxley-type neuron with transient sodium and delayed-rectifier potassium currents using the ion channel models from Traub.
119-
119+
120120
Availability: NEST, NEURON, Brian
121121

122122
============== ============= ===== ===================================================
123123
Name Default value Units Description
124-
============== ============= ===== ===================================================
124+
============== ============= ===== ===================================================
125125
``gbar_Na`` 20.0 uS
126126
``gbar_K`` 6.0 uS
127127
``g_leak`` 0.01 uS
@@ -135,21 +135,21 @@ Name Default value Units Description
135135
``tau_syn_E`` 0.2 ms
136136
``tau_syn_I`` 2.0 ms
137137
``i_offset`` 0.0 nA
138-
============== ============= ===== ===================================================
138+
============== ============= ===== ===================================================
139139

140140

141141
EIF_cond_alpha_isfa_ista
142142
------------------------
143143

144-
Adaptive exponential integrate and fire neuron according to
144+
Adaptive exponential integrate and fire neuron according to
145145
Brette R and Gerstner W (2005) Adaptive Exponential Integrate-and-Fire Model as
146146
an Effective Description of Neuronal Activity. J Neurophysiol 94:3637-3642
147147

148148
Availability: NEST, NEURON, Brian
149149

150150
============== ============= ===== ===================================================
151151
Name Default value Units Description
152-
============== ============= ===== ===================================================
152+
============== ============= ===== ===================================================
153153
``cm`` 0.281 nF Capacity of the membrane
154154
``tau_refrac`` 0.1 ms Duration of refractory period
155155
``v_spike`` -40.0 mV Spike detection threshold
@@ -161,12 +161,33 @@ Name Default value Units Description
161161
``b`` 0.0805 nA Spike-triggered adaptation
162162
``delta_T`` 2.0 mV Slope factor
163163
``tau_w`` 144.0 ms Adaptation time constant
164-
``v_thresh`` -50.4 mV Spike initiation threshold
164+
``v_thresh`` -50.4 mV Spike initiation threshold
165165
``e_rev_E`` 0.0 mV Excitatory reversal potential
166166
``tau_syn_E`` 5.0 ms Rise time of excitatory synaptic conductance (alpha function)
167167
``e_rev_I`` -80.0 mV Inhibitory reversal potential
168168
``tau_syn_I`` 5.0 ms Rise time of the inhibitory synaptic conductance (alpha function)
169-
============== ============= ===== ===================================================
169+
============== ============= ===== ===================================================
170+
171+
172+
Composed models
173+
===============
174+
175+
The models listed above all have two fixed post-synaptic mechanism types, "excitatory" and "inhibitory".
176+
If you need more than two mechanisms, e.g. AMPA, NMDA and GABA_A, you can build such models by
177+
combining a "neuron-only" component with one or more "post-synaptic mechanism" components, for example:
178+
179+
::
180+
181+
celltype = sim.PointNeuron(
182+
sim.AdExp(tau_m=10.0, v_rest=-60.0),
183+
AMPA=sim.ExpPSR(tau_syn=1.0, e_syn=0.0),
184+
NMDA=sim.AlphaPSR(tau_syn=20.0, e_syn=0.0),
185+
GABAA=sim.ExpPSR(tau_syn=1.5, e_syn=-70.0),
186+
GABAB=sim.AlphaPSR(tau_syn=15.0, e_syn=-90.0))
187+
188+
Not all simulators can handle all combinations of components, and in general it is not possible to
189+
mix conductance-based and current-based synapses within a single cell type.
190+
PyNN will emit an error message if this is the case.
170191

171192

172193
Spike sources

examples/monolith_vs_composed.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
"""
2+
A demonstration of two different types of neuron model:
3+
- "monolithic" (pre-defined synaptic receptor types)
4+
- "composed" (the user can choose the synaptic receptor types)
5+
6+
This example shows how to build a composed model that matches the
7+
built-in "IF_curr_exp" model, and also demonstrates one of the
8+
additional capabilities of the composed approach, the ability to record
9+
more of the state variables of the synapse model.
10+
11+
Usage: monolith_vs_composed.py [-h] [--plot-figure] [--debug DEBUG] simulator
12+
13+
positional arguments:
14+
simulator neuron, nest, brian2 or another backend simulator
15+
16+
optional arguments:
17+
-h, --help show this help message and exit
18+
--plot-figure Plot the simulation results to a file.
19+
--debug DEBUG Print debugging information
20+
21+
"""
22+
23+
from datetime import datetime
24+
from pyNN.parameters import Sequence
25+
from pyNN.utility import get_simulator, init_logging, normalized_filename
26+
27+
28+
# === Configure the simulator ================================================
29+
30+
sim, options = get_simulator(
31+
(
32+
"--plot-figure",
33+
"Plot the simulation results to a file.",
34+
{"action": "store_true"},
35+
),
36+
("--debug", "Print debugging information"),
37+
)
38+
39+
if options.debug:
40+
init_logging(None, debug=True)
41+
42+
sim.setup(timestep=0.1, min_delay=1.0)
43+
44+
45+
# === Build and instrument the network =======================================
46+
47+
celltype_monolith = sim.IF_curr_exp(
48+
tau_m=10.0, v_rest=-60.0, tau_syn_E=1.0, tau_syn_I=2.0
49+
)
50+
51+
celltype_composed = sim.PointNeuron(
52+
sim.LIF(tau_m=10.0, v_rest=-60.0),
53+
excitatory=sim.CurrExpPostSynapticResponse(tau_syn=1.0),
54+
inhibitory=sim.CurrExpPostSynapticResponse(tau_syn=2.0),
55+
)
56+
57+
neurons_monolith = sim.Population(1, celltype_monolith, initial_values={"v": -60.0})
58+
neurons_composed = sim.Population(1, celltype_composed, initial_values={"v": -60.0})
59+
60+
neurons_monolith.record("v")
61+
neurons_composed.record(["v", "excitatory.isyn", "inhibitory.isyn"])
62+
63+
neurons = neurons_monolith + neurons_composed
64+
65+
inputs = sim.Population(
66+
2,
67+
sim.SpikeSourceArray(
68+
spike_times=[
69+
Sequence([30.0]),
70+
Sequence([120.0]),
71+
]
72+
),
73+
)
74+
75+
connections = {
76+
"excitatory": sim.Projection(
77+
inputs[0:1],
78+
neurons,
79+
sim.AllToAllConnector(),
80+
synapse_type=sim.StaticSynapse(weight=0.5, delay=1.5),
81+
receptor_type="excitatory",
82+
label="exc",
83+
),
84+
"inhibitory": sim.Projection(
85+
inputs[1:2],
86+
neurons,
87+
sim.AllToAllConnector(),
88+
synapse_type=sim.StaticSynapse(weight=-0.2, delay=1.5),
89+
receptor_type="inhibitory",
90+
label="inh",
91+
),
92+
}
93+
# === Run the simulation =====================================================
94+
95+
sim.run(200.0)
96+
97+
98+
# === Save the results, optionally plot a figure =============================
99+
100+
filename = "Results/monolith_vs_composed_{}.pkl".format(options.simulator)
101+
data = neurons.get_data().segments[0]
102+
103+
if options.plot_figure:
104+
from pyNN.utility.plotting import Figure, Panel
105+
106+
figure_filename = filename.replace("pkl", "png")
107+
Figure(
108+
Panel(
109+
data.filter(name="v")[0],
110+
xticks=False,
111+
yticks=True,
112+
ylabel="Membrane potential (mV)",
113+
), # ylim=(-66, -48)),
114+
Panel(
115+
data.filter(name="excitatory.isyn")[0],
116+
xticks=False,
117+
yticks=True,
118+
ylabel="Excitatory synaptic current (nA)",
119+
),
120+
Panel(
121+
data.filter(name="inhibitory.isyn")[0],
122+
xticks=True,
123+
yticks=True,
124+
ylabel="Inhibitory synaptic current (nA)",
125+
xlabel="Time (ms)"
126+
),
127+
title="Comparing 'monolithic' and 'composed' neuron models",
128+
annotations=f"Simulated with {options.simulator.upper()} at {datetime.now().isoformat()}",
129+
).save(figure_filename)
130+
print(figure_filename)
131+
132+
# === Clean up and quit ========================================================
133+
134+
sim.end()

0 commit comments

Comments
 (0)