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))
, whereindices
are the array indices which were recorded. When indexing theStateMonitor
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 insource
, 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, whereasmon.v[[0, 2]]
will return the values for the first and third recorded neurons, i.e. for neurons 0 and 4.Attributes
The array of recorded indices
The variables to record
Methods
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 itswhen
attribute defaults to'start'
, i.e. the last recording is at the beginning of the last time step.