PopulationRateMonitor class¶
(Shortest import: from brian2 import PopulationRateMonitor)
- class brian2.monitors.ratemonitor.PopulationRateMonitor(*args, **kw)[source]¶
Bases:
RateMonitorRecord instantaneous firing rates, averaged across neurons from a
NeuronGroupor other spike source.- Parameters:
source : (
NeuronGroup,SpikeSource)The source of spikes to record.
name : str, optional
A unique name for the object, otherwise will use
source.name+'_ratemonitor_0', etc.codeobj_class : class, optional
The
CodeObjectclass to run code with.dtype : dtype, optional
The dtype to use to store the
ratevariable. Defaults tofloat64, i.e. double precision.
Notes
Currently, this monitor can only monitor the instantaneous firing rates at each time step of the source clock. Any binning/smoothing of the firing rates has to be done afterwards using the
binned_rateorsmooth_ratemethods.Attributes
The group we are recording from
Methods
binned_rate(bin_size)Return the population rate binned with the given bin size.
reinit()Clears all recorded rates
resize(new_size)Details
- source¶
The group we are recording from
- binned_rate(bin_size)[source]¶
Return the population rate binned with the given bin size.
- Parameters:
bin_size :
QuantityThe size of the bins in seconds. Should be a multiple of dt.
- Returns:
bins :
QuantityThe start time of the bins.
binned_values :
QuantityThe binned population rates as a 1D array in Hz.
Warning
This method will give incorrect results if the monitor has recorded values with varying
dtvalues.Notes
The returned bin times represent the start of each bin interval, not the center. This is consistent with how Brian2 records spike times and other temporal data. For example, a spike recorded at time
toccurred during the interval[t, t+dt).For plotting purposes, especially with larger bin sizes, you may want to use bin centers instead of bin starts for a more intuitive visualization. You can easily calculate the bin centers by adding half the bin size:
>> bins, rates = monitor.binned_rate(10*ms) >> bin_centers = bins + 10*ms / 2 >> plt.plot(bin_centers, rates)
This adjustment is particularly helpful when the bins are large relative to the time scale of interest, as it better represents where the rate measurement applies within each time window.
Tutorials and examples using this¶
Example frompapers/Brunel_2000
Example frompapers/Brunel_Hakim_1999
Example frompapers/Brunel_Wang_2001
Example frompapers/Wang_2002
Example synapses/spike_based_homeostasis