StateMonitor class

(Shortest import: from brian2 import StateMonitor)

class brian2.monitors.statemonitor.StateMonitor(*args, **kw)[source]

Bases: Group, CodeRunner

Record values of state variables during a run

To extract recorded values after a run, use the t attribute for the array of times at which values were recorded, and variable name attribute for the values. The values will have shape (len(indices), len(t)), where indices are the array indices which were recorded. When indexing the StateMonitor directly, the returned object can be used to get the recorded values for the specified indices, i.e. the indexing semantic refers to the indices in source, not to the relative indices of the recorded values. For example, when recording only neurons with even numbers, mon[[0, 2]].v will return the values for neurons 0 and 2, whereas mon.v[[0, 2]] will return the values for the first and third recorded neurons, i.e. for neurons 0 and 4.

Attributes

record

The array of recorded indices

record_variables

The variables to record

Methods

record_single_timestep()

Records a single time step.

reinit()

resize(new_size)

Details

record

The array of recorded indices

record_variables

The variables to record

record_single_timestep()[source]

Records a single time step. Useful for recording the values at the end of the simulation – otherwise a StateMonitor will not record the last simulated values since its when attribute defaults to 'start', i.e. the last recording is at the beginning of the last time step.

reinit()[source]
resize(new_size)[source]