3.10. Monitoring

Recording of neural or synaptic variables during the simulation is possible through a Monitor object.

class ANNarchy.Monitor(obj, variables=[], period=None, start=True, net_id=0)[source]

Monitoring class allowing to record easily parameters or variables from Population, PopulationView and Dendrite objects.

It is not possible to record complete projections.

Parameters:

  • obj: object to monitor. Must be a Population, PopulationView or Dendrite object.
  • variables: single variable name or list of variable names to record (default: []).
  • period: delay in ms between two recording (default: dt). Not valid for the spike variable of a Population(View).
  • start: defines if the recording should start immediately (default: True). If not, you should later start the recordings with the start() method.

Example:

m = Monitor(pop, ['g_exc', 'v', 'spike'], period=10.0)

It is also possible to record the sum of inputs to each neuron in a rate-coded population:

m = Monitor(pop, ['sum(exc)', 'r'])
get(variables=None, keep=False, reshape=False, force_dict=False)[source]

Returns the recorded variables as a Numpy array (first dimension is time, second is neuron index).

If a single variable name is provided, the recorded values for this variable are directly returned. If a list is provided or the argument left empty, a dictionary with all recorded variables is returned.

The spike variable of a population will be returned as a dictionary of lists, where the spike times (in steps) for each recorded neurons are returned.

Parameters:

  • variables: (list of) variables. By default, a dictionary with all variables is returned.
  • keep: defines if the content in memory for each variable should be kept (default: False).
  • reshape: transforms the second axis of the array to match the population’s geometry (default: False).
histogram(spikes=None, bins=None)[source]

Returns a histogram for the recorded spikes in the population.

Parameters:

  • spikes: the dictionary of spikes returned by get('spike'). If left empty, get('spike') will be called. Beware: this erases the data from memory.
  • bins: the bin size in ms (default: dt).

Example:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
histo = m.histogram()
plot(histo)

or:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
spikes = m.get('spike')
histo = m.histogram(spikes)
plot(histo)
mean_fr(spikes=None)[source]

Computes the mean firing rate in the population during the recordings.

Parameters:

  • spikes: the dictionary of spikes returned by get('spike'). If left empty, get('spike') will be called. Beware: this erases the data from memory.

Example:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
fr = m.mean_fr()

or:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
spikes = m.get('spike')
fr = m.mean_fr(spikes)
pause()[source]

Resumes the recordings.

population_rate(spikes=None, smooth=0.0)[source]

Takes the recorded spikes of a population and returns a smoothed firing rate for the population of recorded neurons.

This method is faster than calling smoothed_rate and then averaging.

The first axis is the neuron index, the second is time.

Parameters:

  • spikes: the dictionary of spikes returned by get('spike').

If left empty, get('spike') will be called. Beware: this erases the data from memory.

Example:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
r = m.population_rate(smooth=100.)
raster_plot(spikes=None)[source]

Returns two vectors representing for each recorded spike 1) the spike times and 2) the ranks of the neurons.

Parameters:

  • spikes: the dictionary of spikes returned by get('spike'). If left empty, get('spike') will be called. Beware: this erases the data from memory.

Example:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
spike_times, spike_ranks = m.raster_plot()
plot(spike_times, spike_ranks, '.')

or:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
spikes = m.get('spike')
spike_times, spike_ranks = m.raster_plot(spikes)
plot(spike_times, spike_ranks, '.')
resume()[source]

Resumes the recordings.

smoothed_rate(spikes=None, smooth=0.0)[source]

Computes the smoothed firing rate of the recorded spiking neurons.

The first axis is the neuron index, the second is time.

Parameters:

  • spikes: the dictionary of spikes returned by get('spike'). If left empty, get('spike') will be called. Beware: this erases the data from memory.

Example:

m = Monitor(P[:1000], 'spike')
simulate(1000.0)
r = m.smoothed_rate(smooth=100.)
start(variables=None, period=None)[source]

Starts recording the variables. It is called automatically after compile() if the flag start was not passed to the constructor.

Parameters:

  • variables: single variable name or list of variable names to start recording (default: the variables argument passed to the constructor).
  • period: delay in ms between two recording (default: dt). Not valid for the spike variable of a Population(View).
stop()[source]

Stops the recordings.

times(variables=None)[source]

Returns the start and stop times of the recorded variables.

Parameters:

  • variables: (list of) variables. By default, the times for all variables is returned.
period

Period of recording in ms