Monitor
Monitor(self,
obj,=[],
variables=None,
period=None,
period_offset=True,
start=None,
name=0,
net_id )
Object allowing to record variables from Population
, PopulationView
, Dendrite
or Projection
instances.
This object should not be created directly, but returned by Network.monitor()
:
= net.monitor(pop, ['g_exc', 'v', 'spike'], period=10.0, start=False) m
Monitors are started by default after compile()
. You can control their recording behavior with the start()
, stop()
, pause()
and resume()
methods.
# Start recording
m.start()
net.simulate(T)# Pause recording
m.pause()
net.simulate(T)# Resume recording
m.resume()
net.simulate(T)
= m.get() # Get the data data
For spiking networks recording 'spike'
, some utilities allow to easily compute raster plots /other statistics or mean firing rates over time/neuron axes:
= m.get('spike')
spikes
= m.raster_plot(spikes)
t, n = m.histogram()
histo = m.inter_spike_interval(spikes)
isi = m.coefficient_of_variation(spikes)
cov = m.mean_fr(spikes)
fr = m.smoothed_rate(spikes, smooth=100.)
r = m.population_rate(spikes, smooth=100.) r_mean
Attributes
Name | Description |
---|---|
period | Period of recording in milliseconds. |
period_offset | Offset of recording within a period, in milliseconds. |
variables | Current list of recorded variables. |
Methods
Name | Description |
---|---|
get | Returns the recorded variables and empties the buffer. |
start | Starts recording the variable. |
pause | Pauses the recording. |
resume | Resumes the recording. |
stop | Stops the recording. |
reset | Reset the monitor to its initial state. |
save | Saves the recorded variables as a Numpy array (first dimension is time, second is neuron index). |
times | Returns the start and stop times (in ms) of the recorded variables as a dictionary. |
raster_plot | Returns two numpy arrays representing for each recorded spike 1) the spike times and 2) the ranks of the neurons. |
histogram | Returns a histogram for the recorded spikes in the population. |
inter_spike_interval | Computes the inter-spike intervals (ISI) for the recorded spikes in the population. |
coefficient_of_variation | Computes the coefficient of variation for the recorded spikes in the population. |
mean_fr | Computes the mean firing rate in the population during the recordings. |
smoothed_rate | Computes the smoothed firing rate of the recorded spiking neurons. |
population_rate | Computes a smoothed firing rate for the population of recorded neurons. |
get
=None, keep=False, reshape=False, force_dict=False) get(variables
Returns the recorded variables and empties the buffer.
The recorded data is returned 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 as an array. 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 key is the neuron index, and the list contains the spike times (in steps; multiply by net.dt
to get spike times in milliseconds) for each recorded neurons.
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 |
start
=None, period=None) start(variables
Starts recording the variable.
It is called automatically after Network.compile()
if the flag start=False
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 |
pause
pause()
Pauses the recording.
resume
resume()
Resumes the recording.
stop
stop()
Stops the recording.
Warning: This will delete the content of the C++ object and all data not previously retrieved is lost.
reset
reset()
Reset the monitor to its initial state.
save
=None, keep=False, reshape=False, force_dict=False) save(filename, variables
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 containing the spike times (in steps; multiply by net.dt
to get spike times in milliseconds) for each recorded neurons.
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 |
times
=None) times(variables
Returns the start and stop times (in ms) of the recorded variables as a dictionary.
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 |
raster_plot
=None) raster_plot(spikes
Returns two numpy arrays representing for each recorded spike 1) the spike times and 2) the ranks of the neurons.
Example:
= net.monitor(pop, 'spike')
m 1000.0)
net.simulate(
= m.raster_plot()
t, n '.') plt.plot(t, n,
or:
= net.monitor(pop, 'spike')
m 1000.0)
net.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 |
histogram
=None, bins=None, per_neuron=False, recording_window=None) histogram(spikes
Returns a histogram for the recorded spikes in the population.
= net.monitor(pop, 'spike')
m 1000.0)
net.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
=None, ranks=None, per_neuron=False) inter_spike_interval(spikes
Computes the inter-spike intervals (ISI) for the recorded spikes in the population.
= net.monitor(pop, 'spike')
m 1000.0)
net.simulate(
= m.get('spike')
spikes = m.inter_spike_interval(spikes)
isi plt.hist(isi)
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 |
ranks | list[int] | a list of neurons that should be evaluated. By default None , all neurons are evaluated. |
None |
per_neuron | bool | 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). | False |
coefficient_of_variation
=None, ranks=None) coefficient_of_variation(spikes
Computes the coefficient of variation for the recorded spikes in the population.
= net.monitor(pop, 'spike')
m 1000.0)
net.simulate(
= m.get('spike')
spikes = m.coefficient_of_variation(spikes)
cov plt.hist(isi)
:ranks: a list of neurons that should be evaluated. By default (None), all neurons are evaluated.
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 |
mean_fr
=None) mean_fr(spikes
Computes the mean firing rate in the population during the recordings.
= net.monitor(pop, 'spike')
m 1000.0)
net.simulate(
= m.get('spike')
spikes = m.mean_fr(spikes) fr
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 |
smoothed_rate
=None, smooth=0.0) smoothed_rate(spikes
Computes the smoothed firing rate of the recorded spiking neurons.
The first axis is the neuron index, the second is time.
= net.monitor(pop, 'spike')
m 1000.0)
net.simulate(
= m.get('spike')
spikes = m.smoothed_rate(spikes, smooth=100.) r
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 |
smooth | float | smoothing time constant. Default: 0.0 (no smoothing). | 0.0 |
population_rate
=None, smooth=0.0) population_rate(spikes
Computes a smoothed firing rate for the population of recorded neurons.
This method is faster than calling smoothed_rate
and then averaging.
If spikes
is left empty, get('spike')
will be called. Beware: this erases the data from memory.
Example:
= net.monitor(P[:1000], 'spike')
m 1000.0)
net.simulate(
= m.get('spike')
spikes = m.population_rate(spikes, smooth=100.) r
Parameters
Name | Type | Description | Default |
---|---|---|---|
spikes | dict | the dictionary of spikes returned by get('spike') . |
None |
smooth | float | smoothing time constant. Default: 0.0 (no smoothing). | 0.0 |