Monitor
core.Monitor.Monitor(self,
obj,=[],
variables=None,
period=None,
period_offset=True,
start=0,
net_id )
Monitoring class allowing to record easily parameters or variables from Population, PopulationView, Dendrite or Projection objects.
Example:
= Monitor(pop, ['g_exc', 'v', 'spike'], period=10.0) m
It is also possible to record the sum of inputs to each neuron in a rate-coded population:
= Monitor(pop, ['sum(exc)', 'r']) m
Parameters
Name | Type | Description | Default |
---|---|---|---|
obj | Any | object to monitor. Must be a Population , PopulationView , Dendrite or Projection object. |
required |
variables | list | single variable name or list of variable names to record (default: []). | [] |
period | float | delay in ms between two recording (default: dt). Not valid for the spike variable of a Population(View). |
None |
period_offset | float | determine the moment in ms of recording within the period (default 0). Must be smaller than period. | None |
start | bool | defines if the recording should start immediately (default: True). If not, you should later start the recordings with the start() method. |
True |
Attributes
Name | Description |
---|---|
period | Period of recording in ms |
period_offset | Shift of moment of time of recording in ms within a period |
variables | Returns a copy of the current variable list. |
Methods
Name | Description |
---|---|
coefficient_of_variation | Computes the coefficient of variation for the recorded spikes in the population. |
get | Returns the recorded variables as a Numpy array (first dimension is time, second is neuron index). |
histogram | Returns a histogram for the recorded spikes in the population. |
inter_spike_interval | Computes the inter-spike interval for the recorded spikes in the population. |
mean_fr | Computes the mean firing rate in the population during the recordings. |
pause | Pauses the recordings. |
population_rate | Takes the recorded spikes of a population and returns a smoothed firing rate for the population of recorded neurons. |
raster_plot | Returns two numpy arrays representing for each recorded spike 1) the spike times and 2) the ranks of the neurons. |
reset | Reset the monitor to its initial state. |
resume | Resumes the recordings. |
save | Saves the recorded variables as a Numpy array (first dimension is time, second is neuron index). |
size_in_bytes | Get the size of allocated memory on C++ side. Please note, this is only valid if compile() was invoked. |
smoothed_rate | Computes the smoothed firing rate of the recorded spiking neurons. |
start | Starts recording the variables. |
stop | Stops the recording. |
times | Returns the start and stop times (in ms) of the recorded variables. |
coefficient_of_variation
=None, ranks=None) core.Monitor.Monitor.coefficient_of_variation(spikes
Computes the coefficient of variation for the recorded spikes in the population.
:ranks: a list of neurons that should be evaluated. By default (None), all neurons are evaluated.
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
get
core.Monitor.Monitor.get(=None,
variables=False,
keep=False,
reshape=False,
force_dict )
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
Name | Type | Description | Default |
---|---|---|---|
variables | str | list[str] | (list of) variables. By default, a dictionary with all variables is returned. | None |
keep | bool | defines if the content in memory for each variable should be kept (default: False). | False |
reshape | bool | transforms the second axis of the array to match the population’s geometry (default: False). | False |
Returns
Name | Type | Description |
---|---|---|
dict | Recorded variables |
histogram
core.Monitor.Monitor.histogram(=None,
spikes=None,
bins=False,
per_neuron=None,
recording_window )
Returns a histogram for the recorded spikes in the population.
Example:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.histogram()
histo plt.plot(histo)
or:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.get('spike')
spikes = m.histogram(spikes)
histo plt.plot(histo)
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
|
bins | the bin size in ms (default: dt). | None |
inter_spike_interval
core.Monitor.Monitor.inter_spike_interval(=None,
spikes=None,
ranks=False,
per_neuron )
Computes the inter-spike interval for the recorded spikes in the population.
:ranks: a list of neurons that should be evaluated. By default (None), all neurons are evaluated. :per_neuron: if set to True, the computed inter-spike intervals are stored per neuron (analog to spikes), otherwise all values are stored in one huge vector (default: False).
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
mean_fr
=None) core.Monitor.Monitor.mean_fr(spikes
Computes the mean firing rate in the population during the recordings.
Example:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.mean_fr() fr
or:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.get('spike')
spikes = m.mean_fr(spikes) fr
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
pause
core.Monitor.Monitor.pause()
Pauses the recordings.
population_rate
=None, smooth=0.0) core.Monitor.Monitor.population_rate(spikes
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.
If spikes
is left empty, get('spike')
will be called. Beware: this erases the data from memory.
Example:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.population_rate(smooth=100.) r
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . |
None |
|
smooth | smoothing time constant. Default: 0.0 (no smoothing). | 0.0 |
raster_plot
=None) core.Monitor.Monitor.raster_plot(spikes
Returns two numpy arrays representing for each recorded spike 1) the spike times and 2) the ranks of the neurons.
Example:
= Monitor(P[:1000], 'spike')
m 1000.0)
simulate(= m.raster_plot()
t, n '.') plt.plot(t, n,
or:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.get('spike')
spikes = m.raster_plot(spikes)
t, n '.') plt.plot(t, n,
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | dict | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
Returns
Name | Type | Description |
---|---|---|
tuple | spike times and neuron indices as numpy arrays.. |
reset
core.Monitor.Monitor.reset()
Reset the monitor to its initial state.
resume
core.Monitor.Monitor.resume()
Resumes the recordings.
save
core.Monitor.Monitor.save(
filename,=None,
variables=False,
keep=False,
reshape=False,
force_dict )
Saves 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 saved. If a list is provided or the argument left empty, a dictionary with all recorded variables is saved.
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 saved.
Parameters
Name | Type | Description | Default |
---|---|---|---|
filename | str | name of the save file. | required |
variables | str | list[str] | (list of) variables. By default, a dictionary with all variables is returned. | None |
keep | bool | defines if the content in memory for each variable should be kept (default: False). | False |
reshape | bool | transforms the second axis of the array to match the population’s geometry (default: False). | False |
Returns
Name | Type | Description |
---|---|---|
None | Recorded variables |
size_in_bytes
core.Monitor.Monitor.size_in_bytes()
Get the size of allocated memory on C++ side. Please note, this is only valid if compile() was invoked.
Returns
Name | Type | Description |
---|---|---|
int | size in bytes of all allocated C++ data. |
smoothed_rate
=None, smooth=0.0) core.Monitor.Monitor.smoothed_rate(spikes
Computes the smoothed firing rate of the recorded spiking neurons.
The first axis is the neuron index, the second is time.
Example:
= ann.Monitor(P[:1000], 'spike')
m 1000.0)
ann.simulate(= m.smoothed_rate(smooth=100.) r
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | the dictionary of spikes returned by get('spike') . If left empty, get('spike') will be called. Beware: this erases the data from memory. |
None |
|
smooth | smoothing time constant. Default: 0.0 (no smoothing). | 0.0 |
start
=None, period=None) core.Monitor.Monitor.start(variables
Starts recording the variables.
It is called automatically after compile()
if the flag start
was not passed to the constructor.
Parameters
Name | Type | Description | Default |
---|---|---|---|
variables | list | single variable name or list of variable names to start recording (default: the variables argument passed to the constructor). |
None |
period | float | delay in ms between two recording (default: dt). Not valid for the spike variable of a Population(View). |
None |
stop
core.Monitor.Monitor.stop()
Stops the recording.
Warning: This will delete the content of the C++ object and all data not previously retrieved is lost.
times
=None) core.Monitor.Monitor.times(variables
Returns the start and stop times (in ms) of the recorded variables.
It should only be called after a call to get()
, so that it describes when the variables have been recorded.
Parameters
Name | Type | Description | Default |
---|---|---|---|
variables | list[str] | (list of) variables. By default, the times for all variables is returned. | None |
Returns
Name | Type | Description |
---|---|---|
dict | dictionary of start and stop times. |