Recording spikes and state variables¶

It is possible to record the times of action potentials, and the values of state variables, of any neuron in the network. Recording state variables of dynamic synapse models is not yet supported.

The classes Population, PopulationView and Assembly all have a record() method, which takes either a single variable name or a list/tuple of such names, and which sets up recording of the requested variables for all neurons in the population:

>>> population.record(['v', 'spikes']) # record membrane potential and spikes from all neurons in the population
>>> assembly.record('spikes')          # record spikes from all neurons in multiple populations

To record from only a subset of the neurons in a Population, we create a temporary PopulationView using indexing or the sample() method and call record() on this view:

>>> population.sample(10).record('v')                         # record membrane potential from 10 neurons chosen at random
>>> population[[0,1,2]].record(['v', 'gsyn_exc', 'gsyn_inh']) # record several variables from specific neurons

To find out what variable names are available for a given neuron model, inspect the recordable attribute of the population’s celltype attribute:

>>> population.celltype
>>> population.celltype.recordable
['spikes', 'v', 'w', 'gsyn_exc', 'gsyn_inh']

By default, variables are recorded at every time step. It is possible to record at a lower frequency using the sampling_interval argument, e.g.:

>>> population.record(None)   # reset recording for this population
>>> population.record('v', sampling_interval=1.0)

You should ensure that the sampling interval is an integer multiple of the simulation time step. Other values may work, but have not been tested.

An alternative syntax is available, using the top-level record() function:

>>> record(['v', 'spikes'], population, filename="output_data.pkl", sampling_interval=1.0)

This avoids having to call population.write_data() at the end of the simulation; the data will be automatically written to the specified filename.