Last modified by adavison on 2022/10/04 13:55

From version 15.1
edited by adavison
on 2021/09/30 15:30
Change comment: There is no comment for this version
To version 20.1
edited by adavison
on 2021/12/01 15:21
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -9,11 +9,11 @@
9 9  
10 10  == Audience ==
11 11  
12 -This tutorial is intended for people with at least a basic knowledge of neuroscience (high school level or above) and basic familiarity with the Python programming language. It should also be helpful for people who already have advanced knowledge of neuroscience and neural simulation, who simply wish to learn how to use PyNN, and how it differs from other simulation tools they know.
12 +This tutorial is intended for people with at least a basic knowledge of neuroscience (high-school level or above) and basic familiarity with the Python programming language. It should also be helpful for people who already have advanced knowledge of neuroscience and neural simulation, who simply wish to learn how to use PyNN and how it differs from other simulation tools they know.
13 13  
14 14  == Prerequisites ==
15 15  
16 -To follow this tutorial, you need a basic knowledge of neuroscience (high-school level or greater), basic familiarity with the Python programming language, and either a computer with PyNN, NEST, NEURON and Brian 2 installed, or an EBRAINS account and basic familiarity with Jupyter notebooks. If you don't have these tools installed, see one of our previous tutorials which guide you through the installation.
16 +To follow this tutorial, you need a basic knowledge of neuroscience (high-school level or greater), basic familiarity with the Python programming language, and either a computer with PyNN, NEST, NEURON, and Brian 2 installed or an EBRAINS account and basic familiarity with Jupyter notebooks. If you don't have these tools installed, see one of our previous tutorials which guide you through the installation.
17 17  
18 18  == Format ==
19 19  
... ... @@ -66,13 +66,13 @@
66 66  **Screencast** - blank document in editor
67 67  )))
68 68  
69 -In this video, you'll see my editor on the left, and on the right my terminal and my file browser. I'll be writing code in the editor, and then running my scripts in the terminal. You're welcome to follow along~-~--you can pause the video at any time if I'm going too fast~-~--or you can just watch.
69 +In this video, you'll see my editor on the left and my terminal and my file browser on the right. I'll be writing code in the editor and then running my scripts in the terminal. You're welcome to follow along~-~--you can pause the video at any time if I'm going too fast~-~--or you can just watch.
70 70  
71 -Let's start by writing a docstring, "Simple network model using PyNN".
71 +Let's start by writing a docstring "Simple network model using PyNN".
72 72  
73 -For now, we're going to use the NEST simulator to simulate this model, so we import the PyNN-for-NEST module.
73 +For now, we're going to use the NEST simulator to simulate this model; so, we import the PyNN-for-NEST module.
74 74  
75 -Like with any numerical model, we need to break time down into small steps, so let's set that up with steps of 0.1 milliseconds.
75 +Like with any numerical model, we need to break time down into small steps; so let's set that up with steps of 0.1 milliseconds.
76 76  
77 77  (% class="box infomessage" %)
78 78  (((
... ... @@ -92,10 +92,10 @@
92 92  \\(% style="color:#000000" %)"""Simple network model using PyNN"""
93 93  \\import pyNN.nest as sim
94 94  sim.setup(timestep=0.1)(%%)
95 -(% style="color:#e74c3c" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, t_refrac=1, tau_m=10, cm=1, i_offset=0.1)
95 +(% style="color:#e74c3c" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, tau_refrac=1, tau_m=10, cm=1, i_offset=0.1)
96 96  )))
97 97  
98 -Let's create 100 of these neurons, then we're going to record the membrane voltage, and run a simulation for 100 milliseconds.
98 +Let's create 100 of these neurons; then, we're going to record the membrane voltage and run a simulation for 100 milliseconds.
99 99  
100 100  (% class="box infomessage" %)
101 101  (((
... ... @@ -103,7 +103,7 @@
103 103  \\(% style="color:#000000" %)"""Simple network model using PyNN"""
104 104  \\import pyNN.nest as sim
105 105  sim.setup(timestep=0.1)(%%)
106 -(% style="color:#000000" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
106 +(% style="color:#000000" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, tau_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
107 107  (% style="color:#e74c3c" %)population1 = sim.Population(100, cell_type, label="Population 1")
108 108  population1.record("v")
109 109  sim.run(100.0)(%%)
... ... @@ -119,7 +119,7 @@
119 119  \\import pyNN.nest as sim(%%)
120 120  (% style="color:#e74c3c" %)from pyNN.utility.plotting import Figure, Panel(%%)
121 121  (% style="color:#000000" %)sim.setup(timestep=0.1)(%%)
122 -(% style="color:#000000" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
122 +(% style="color:#000000" %)cell_type  = sim.IF_curr_exp(v_rest=-65, v_thresh=-55, v_reset=-65, tau_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
123 123  (% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1")
124 124  population1.record("v")
125 125  sim.run(100.0)(%%)
... ... @@ -136,9 +136,9 @@
136 136  \\**Run script in terminal, show figure**
137 137  )))
138 138  
139 -As you'd expect, the bias current causes the membrane voltage to increase until it reaches threshold~-~--it doesn't increase in a straight line because it's a //leaky// integrate-and-fire neuron~-~--then once it hits the threshold the voltage is reset, and then stays at the same level for a short time~-~--this is the refractory period~-~--before it starts to increase again.
139 +As you'd expect, the bias current causes the membrane voltage to increase until it reaches threshold~-~--it doesn't increase in a straight line because it's a //leaky// integrate-and-fire neuron~-~--then, once it hits the threshold, the voltage is reset and then stays at the same level for a short time~-~--this is the refractory period~-~--before it starts to increase again.
140 140  
141 -Now, all 100 neurons in our population are identical, so if we plotted the first neuron, the second neuron, ..., we'd get the same trace.
141 +Now, all 100 neurons in our population are identical; so, if we plotted the first neuron, the second neuron, ..., we'd get the same trace.
142 142  
143 143  (% class="box infomessage" %)
144 144  (((
... ... @@ -158,7 +158,7 @@
158 158  \\**Run script in terminal, show figure**
159 159  )))
160 160  
161 -Let's change that. In nature every neuron is a little bit different, so let's set the resting membrane potential and the spike threshold randomly from a Gaussian distribution.
161 +Let's change that. In nature, every neuron is a little bit different; so, let's set the resting membrane potential and the spike threshold randomly from a Gaussian distribution.
162 162  
163 163  (% class="box infomessage" %)
164 164  (((
... ... @@ -169,10 +169,10 @@
169 169  (% style="color:#e74c3c" %)from pyNN.random import RandomDistribution(%%)
170 170  (% style="color:#000000" %)sim.setup(timestep=0.1)(%%)
171 171  (% style="color:#000000" %)cell_type  = sim.IF_curr_exp(
172 - (% style="color:#e74c3c" %) v_rest=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}),
173 - v_thresh=RandomDistribution('normal', {'mu': -55.0, 'sigma': 1.0}),
174 - v_reset=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), (%%)
175 -(% style="color:#000000" %) t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
172 + (% style="color:#e74c3c" %) v_rest=RandomDistribution('normal', mu=-65.0, sigma=1.0),
173 + v_thresh=RandomDistribution('normal', mu=-55.0, sigma=1.0),
174 + v_reset=RandomDistribution('normal', mu=-65.0, sigma=1.0), (%%)
175 +(% style="color:#000000" %) tau_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
176 176  
177 177  
178 178  **...**
... ... @@ -190,15 +190,15 @@
190 190  \\**Run script in terminal, show figure**
191 191  )))
192 192  
193 -Now if we run our simulation again, we can see the effect of this heterogeneity in the neuron population.
193 +Now, if we run our simulation again, we can see the effect of this heterogeneity in the neuron population.
194 194  
195 195  (% class="box successmessage" %)
196 196  (((
197 -**Slide** showing addition of second population, and of connections between them
197 +**Slide** showing addition of second population and of connections between them
198 198  )))
199 199  
200 200  (% class="wikigeneratedid" %)
201 -So far we have a population of neurons, but there are no connections between them, we don't have a network. Let's add a second population of the same size as the first, but we'll set the offset current to zero, so they don't fire action potentials spontaneously.
201 +So far, we have a population of neurons, but there are no connections between them, we don't have a network. Let's add a second population of the same size as the first, but we'll set the offset current to zero, so they don't fire action potentials spontaneously.
202 202  
203 203  (% class="box infomessage" %)
204 204  (((
... ... @@ -213,7 +213,7 @@
213 213  **...**
214 214  )))
215 215  
216 -Now we want to create synaptic connections between the neurons in Population 1 and those in Population 2. There are lots of different ways these could be connected.
216 +Now, we want to create synaptic connections between the neurons in Population 1 and those in Population 2. There are lots of different ways these could be connected.
217 217  
218 218  (% class="box successmessage" %)
219 219  (((
... ... @@ -254,7 +254,7 @@
254 254  )))
255 255  
256 256  (% class="wikigeneratedid" %)
257 -In PyNN, we call a group of connections between two populations a _Projection_. To create a Projection, we need to specify the presynaptic population, the postsynaptic population, the connection algorithm, and the synapse model. Here we're using the simplest synapse model available in PyNN, for which the synaptic weight is constant over time, there is no plasticity.
257 +In PyNN, we call a group of connections between two populations a _Projection_. To create a Projection, we need to specify the presynaptic population, the postsynaptic population, the connection algorithm, and the synapse model. Here, we're using the simplest synapse model available in PyNN, for which the synaptic weight is constant over time; there is no plasticity.
258 258  
259 259  (% class="box infomessage" %)
260 260  (((
... ... @@ -263,7 +263,7 @@
263 263  
264 264  **...**
265 265  (% style="color:#000000" %)population2.record("v")(%%)
266 -(% style="color:#e74c3c" %)connection_algorithm = sim.FixedProbabilityConnector(p=0.5)
266 +(% style="color:#e74c3c" %)connection_algorithm = sim.FixedProbabilityConnector(p_connect=0.5)
267 267  synapse_type = sim.StaticSynapse(weight=0.5, delay=0.5)
268 268  connections = sim.Projection(population1, population2, connection_algorithm, synapse_type)(%%)
269 269  (% style="color:#000000" %)sim.run(100.0)(%%)
... ... @@ -289,7 +289,7 @@
289 289   (% style="color:#e74c3c" %)Panel(
290 290   data2_v[:, 0:5],
291 291   xticks=True, xlabel="Time (ms)",
292 - yticks=True"
292 + yticks=True
293 293   ),(%%)
294 294  (% style="color:#000000" %) title="Response of (% style="color:#e74c3c" %)simple network(% style="color:#000000" %)",
295 295   annotations="Simulated with NEST"
... ... @@ -299,7 +299,7 @@
299 299  )))
300 300  
301 301  (% class="wikigeneratedid" %)
302 -and there we have it, our simple neuronal network of integrate-and-fire neurons, written in PyNN, simulated with NEST. If you prefer to use the NEURON simulator, PyNN makes this very simple, we import the PyNN-for-NEURON module instead.
302 +and there we have it, our simple neuronal network of integrate-and-fire neurons, written in PyNN, simulated with NEST. If you prefer to use the NEURON simulator, PyNN makes this very simple: we import the PyNN-for-NEURON module instead.
303 303  
304 304  (% class="box infomessage" %)
305 305  (((
... ... @@ -310,16 +310,16 @@
310 310  (% style="color:#000000" %)from pyNN.random import RandomDistribution(%%)
311 311  (% style="color:#000000" %)sim.setup(timestep=0.1)(%%)
312 312  (% style="color:#000000" %)cell_type  = sim.IF_curr_exp(
313 - (% style="color:#e74c3c" %) (% style="color:#000000" %)v_rest=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}),
314 - v_thresh=RandomDistribution('normal', {'mu': -55.0, 'sigma': 1.0}),
315 - v_reset=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), (%%)
316 -(% style="color:#000000" %) t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
313 + (% style="color:#e74c3c" %) (% style="color:#000000" %)v_rest=RandomDistribution('normal', mu=-65.0, sigma=1.0),
314 + v_thresh=RandomDistribution('normal', mu=-55.0, sigma=1.0),
315 + v_reset=RandomDistribution('normal', mu=-65.0, sigma=1.0), (%%)
316 +(% style="color:#000000" %) tau_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%)
317 317  (% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1")(%%)
318 318  (% style="color:#000000" %)population2 = sim.Population(100, cell_type, label="Population 2")
319 319  population2.set(i_offset=0)
320 320  population1.record("v")
321 321  population2.record("v")(%%)
322 -(% style="color:#000000" %)connection_algorithm = sim.FixedProbabilityConnector(p=0.5)
322 +(% style="color:#000000" %)connection_algorithm = sim.FixedProbabilityConnector(p_connect=0.5)
323 323  synapse_type = sim.StaticSynapse(weight=0.5, delay=0.5)
324 324  connections = sim.Projection(population1, population2, connection_algorithm, synapse_type)(%%)
325 325  (% style="color:#000000" %)sim.run(100.0)(%%)
... ... @@ -334,7 +334,7 @@
334 334   Panel(
335 335   data2_v[:, 0:5],
336 336   xticks=True, xlabel="Time (ms)",
337 - yticks=True"
337 + yticks=True
338 338   ),(%%)
339 339  (% style="color:#000000" %) title="Response of simple network",
340 340   annotations="Simulated with (% style="color:#e74c3c" %)NEURON(% style="color:#000000" %)"
... ... @@ -351,7 +351,7 @@
351 351  **Slide** recap of learning objectives
352 352  )))
353 353  
354 -That is the end of this tutorial, in which I've demonstrated how to build a simple network using PyNN, and to simulate it using two different simulators, NEST and NEURON.
354 +That is the end of this tutorial, in which I've demonstrated how to build a simple network using PyNN and to simulate it using two different simulators, NEST and NEURON.
355 355  
356 356  Of course, PyNN allows you to create much more complex networks than this, with more realistic neuron models, synaptic plasticity, spatial structure, and so on. You can also use other simulators, such as Brian or SpiNNaker, and you can run simulations in parallel on clusters or supercomputers.
357 357  
... ... @@ -363,7 +363,7 @@
363 363  )))
364 364  
365 365  (% class="wikigeneratedid" %)
366 -PyNN has been developed by many different people, with financial support from several different organisations. I'd like to mention in particular the CNRS and the European Commission, through the FACETS, BrainScaleS and Human Brain Project grants.
366 +PyNN has been developed by many different people, with financial support from several organisations. I'd like to mention in particular the CNRS and the European Commission, through the FACETS, BrainScaleS, and Human Brain Project grants.
367 367  
368 368  (% class="wikigeneratedid" %)
369 -For more information visit neuralensemble.org/PyNN. If you have questions you can contact us through the PyNN Github project, the NeuralEnsemble forum, EBRAINS support, or the EBRAINS Community.
369 +For more information, visit neuralensemble.org/PyNN. If you have questions you can contact us through the PyNN Github project, the NeuralEnsemble forum, EBRAINS support, or the EBRAINS Community.