Changes for page 03. Building and simulating a simple model
Last modified by adavison on 2022/10/04 13:55
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -106,21 +106,215 @@ 106 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)(%%) 107 107 (% style="color:#e74c3c" %)population1 = sim.Population(100, cell_type, label="Population 1") 108 108 population1.record("v") 109 -sim.run(100.0) 109 +sim.run(100.0)(%%) 110 +\\**Run script in terminal** 110 110 ))) 111 111 112 112 PyNN has some built-in tools for making simple plots, so let's import those, and plot the membrane voltage of the zeroth neuron in our population (remember Python starts counting at zero). 113 113 115 +(% class="box infomessage" %) 116 +((( 117 +**Screencast** - current state of editor 118 +\\(% style="color:#000000" %)"""Simple network model using PyNN""" 119 +\\import pyNN.nest as sim(%%) 120 +(% style="color:#e74c3c" %)from pyNN.utility.plotting import Figure, Panel(%%) 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)(%%) 123 +(% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1") 124 +population1.record("v") 125 +sim.run(100.0)(%%) 126 +(% style="color:#e74c3c" %)data_v = population1.get_data().segments[0].filter(name='v')[0] 127 +Figure( 128 + Panel( 129 + data_v[:, 0], 130 + xticks=True, xlabel="Time (ms)", 131 + yticks=True, ylabel="Membrane potential (mV)" 132 + ), 133 + title="Response of neuron #0", 134 + annotations="Simulated with NEST" 135 +).show()(%%) 136 +\\**Run script in terminal, show figure** 137 +))) 138 + 114 114 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. 115 115 116 116 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. 117 117 118 -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, and let's plot membrane voltage from _all_ the neurons. 143 +(% class="box infomessage" %) 144 +((( 145 +**Screencast** - current state of editor 146 +\\(% style="color:#000000" %)"""Simple network model using PyNN""" 147 +\\import pyNN.nest as sim(%%) 148 +(% style="color:#000000" %)from pyNN.utility.plotting import Figure, Panel(%%) 149 +(% style="color:#000000" %)sim.setup(timestep=0.1)(%%) 150 +(% 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)(%%) 151 +(% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1") 152 +population1.record("v") 153 +sim.run(100.0)(%%) 154 +(% style="color:#000000" %)data_v = population1.get_data().segments[0].filter(name='v')[0] 155 +Figure( 156 + Panel( 157 + data_v[:, (% style="color:#e74c3c" %)0:5(% style="color:#000000" %)], 158 + xticks=True, xlabel="Time (ms)", 159 + yticks=True, ylabel="Membrane potential (mV)" 160 + ), 161 + title="Response of (% style="color:#e74c3c" %)first five neurons(% style="color:#000000" %)", 162 + annotations="Simulated with NEST" 163 +).show()(%%) 164 +\\**Run script in terminal, show figure** 165 +))) 119 119 167 +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. 168 + 169 +(% class="box infomessage" %) 170 +((( 171 +**Screencast** - current state of editor 172 +\\(% style="color:#000000" %)"""Simple network model using PyNN""" 173 +\\import pyNN.nest as sim(%%) 174 +(% style="color:#000000" %)from pyNN.utility.plotting import Figure, Panel(%%) 175 +(% style="color:#e74c3c" %)from pyNN.random import RandomDistribution(%%) 176 +(% style="color:#000000" %)sim.setup(timestep=0.1)(%%) 177 +(% style="color:#000000" %)cell_type = sim.IF_curr_exp( 178 + (% style="color:#e74c3c" %) v_rest=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), 179 + v_thresh=RandomDistribution('normal', {'mu': -55.0, 'sigma': 1.0}), 180 + v_reset=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), (%%) 181 +(% style="color:#000000" %) t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%) 182 +(% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1") 183 +population1.record("v") 184 +sim.run(100.0)(%%) 185 +(% style="color:#000000" %)data_v = population1.get_data().segments[0].filter(name='v')[0] 186 +Figure( 187 + Panel( 188 + data_v[:, 0:5], 189 + xticks=True, xlabel="Time (ms)", 190 + yticks=True, ylabel="Membrane potential (mV)" 191 + ), 192 + title="Response of first five neurons (% style="color:#e74c3c" %)with heterogeneous parameters(% style="color:#000000" %)", 193 + annotations="Simulated with NEST" 194 +).show()(%%) 195 +\\**Run script in terminal, show figure** 196 +))) 197 + 120 120 Now if we run our simulation again, we can see the effect of this heterogeneity in the neuron population. 121 121 122 -TO BE COMPLETED 200 +(% class="box successmessage" %) 201 +((( 202 +**Slide** showing addition of second population, and of connections between them 203 +))) 123 123 205 +(% class="wikigeneratedid" %) 206 +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. 207 + 208 +(% class="box infomessage" %) 209 +((( 210 +**Screencast** - current state of editor 211 +\\(% style="color:#000000" %)"""Simple network model using PyNN""" 212 +\\import pyNN.nest as sim(%%) 213 +(% style="color:#000000" %)from pyNN.utility.plotting import Figure, Panel(%%) 214 +(% style="color:#000000" %)from pyNN.random import RandomDistribution(%%) 215 +(% style="color:#000000" %)sim.setup(timestep=0.1)(%%) 216 +(% style="color:#000000" %)cell_type = sim.IF_curr_exp( 217 + (% style="color:#e74c3c" %) (% style="color:#000000" %)v_rest=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), 218 + v_thresh=RandomDistribution('normal', {'mu': -55.0, 'sigma': 1.0}), 219 + v_reset=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), (%%) 220 +(% style="color:#000000" %) t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%) 221 +(% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1")(%%) 222 +(% style="color:#e74c3c" %)population2 = sim.Population(100, cell_type, label="Population 2") 223 +population2.set(i_offset=0)(%%) 224 +(% style="color:#000000" %)population1.record("v")(%%) 225 +(% style="color:#e74c3c" %)population2.record("v")(%%) 226 +(% style="color:#000000" %)sim.run(100.0)(%%) 227 +(% style="color:#000000" %)data_v = population1.get_data().segments[0].filter(name='v')[0] 228 +Figure( 229 + Panel( 230 + data_v[:, 0:5], 231 + xticks=True, xlabel="Time (ms)", 232 + yticks=True, ylabel="Membrane potential (mV)" 233 + ), 234 + title="Response of first five neurons with heterogeneous parameters", 235 + annotations="Simulated with NEST" 236 +).show()(%%) 237 +\\**Run script in terminal, show figure** 238 +))) 239 + 240 +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. 241 + 242 +(% class="box successmessage" %) 243 +((( 244 +**Slide** showing all-to-all connections 245 +))) 246 + 247 +We could connect all neurons in Population 1 to all those in Population 2. 248 + 249 +(% class="box successmessage" %) 250 +((( 251 +**Slide** showing random connections 252 +))) 253 + 254 +We could connect the populations randomly, in several different ways. 255 + 256 +(% class="box successmessage" %) 257 +((( 258 +**Slide** showing distance-dependent connections 259 +))) 260 + 261 +(% class="wikigeneratedid" %) 262 +We could connect the populations randomly, but with a probability of connection that depends on the distance between the neurons. 263 + 264 +(% class="box successmessage" %) 265 +((( 266 +**Slide** showing explicit lists of connections 267 +))) 268 + 269 +(% class="wikigeneratedid" %) 270 +Or we could connect the neurons in a very specific manner, based on an explicit list of connections. 271 + 272 +(% class="wikigeneratedid" %) 273 +Just as PyNN provides a variety of neuron models, so it comes with a range of connection algorithms built in. You can also add your own connection methods. 274 + 275 +(% class="box successmessage" %) 276 +((( 277 +**Slide** showing addition of second population, and of connections between them, labelled as a Projection. 278 +))) 279 + 280 +(% class="wikigeneratedid" %) 281 +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. 282 + 283 +(% class="box infomessage" %) 284 +((( 285 +**Screencast** - current state of editor 286 +\\(% style="color:#000000" %)"""Simple network model using PyNN""" 287 +\\import pyNN.nest as sim(%%) 288 +(% style="color:#000000" %)from pyNN.utility.plotting import Figure, Panel(%%) 289 +(% style="color:#000000" %)from pyNN.random import RandomDistribution(%%) 290 +(% style="color:#000000" %)sim.setup(timestep=0.1)(%%) 291 +(% style="color:#000000" %)cell_type = sim.IF_curr_exp( 292 + (% style="color:#e74c3c" %) (% style="color:#000000" %)v_rest=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), 293 + v_thresh=RandomDistribution('normal', {'mu': -55.0, 'sigma': 1.0}), 294 + v_reset=RandomDistribution('normal', {'mu': -65.0, 'sigma': 1.0}), (%%) 295 +(% style="color:#000000" %) t_refrac=1, tau_m=10, cm=1, i_offset=0.1)(%%) 296 +(% style="color:#000000" %)population1 = sim.Population(100, cell_type, label="Population 1")(%%) 297 +(% style="color:#000000" %)population2 = sim.Population(100, cell_type, label="Population 2") 298 +population2.set(i_offset=0) 299 +population1.record("v") 300 +population2.record("v")(%%) 301 +(% style="color:#e74c3c" %)connection_algorithm = sim.FixedProbabilityConnector(p=0.5) 302 +synapse_type = sim.StaticSynapse(weight=0.5, delay=0.5) 303 +connections = sim.Projection(population1, population2, connection_algorithm, synapse_type)(%%) 304 +(% style="color:#000000" %)sim.run(100.0)(%%) 305 +(% style="color:#000000" %)data_v = population1.get_data().segments[0].filter(name='v')[0] 306 +Figure( 307 + Panel( 308 + data_v[:, 0:5], 309 + xticks=True, xlabel="Time (ms)", 310 + yticks=True, ylabel="Membrane potential (mV)" 311 + ), 312 + title="Response of first five neurons with heterogeneous parameters", 313 + annotations="Simulated with NEST" 314 +).show()(%%) 315 +\\**Run script in terminal, show figure** 316 +))) 317 + 124 124 (% class="wikigeneratedid" id="HSummary28Inthistutorial2CyouhavelearnedtodoX202629" %) 125 125 (% class="small" %)**Summary (In this tutorial, you have learned to do X…)** 126 126