elephant.statistics.mean_firing_rate

elephant.statistics.mean_firing_rate(spiketrain, t_start=None, t_stop=None, axis=None)[source]

Return the firing rate of the spike train.

Accepts a neo.SpikeTrain, a pq.Quantity array, or a plain np.ndarray. If either a neo.SpikeTrain or pq.Quantity array is provided, the return value will be a pq.Quantity array, otherwise a plain np.ndarray. The units of the pq.Quantity array will be the inverse of the spiketrain.

The interval over which the firing rate is calculated can be optionally controlled with t_start and t_stop.

Parameters:
spiketrainneo.SpikeTrain or pq.Quantity or np.ndarray

The spike times.

t_startfloat or pq.Quantity, optional

The start time to use for the interval. If None, retrieved from the t_start attribute of spiketrain. If that is not present, default to 0. Any value from spiketrain below this value is ignored. Default: None.

t_stopfloat or pq.Quantity, optional

The stop time to use for the time points. If not specified, retrieved from the t_stop attribute of spiketrain. If that is not present, default to the maximum value of spiketrain. Any value from spiketrain above this value is ignored. Default: None.

axisint, optional

The axis over which to do the calculation. If None, do the calculation over the flattened array. Default: None.

Returns:
float or pq.Quantity or np.ndarray

The firing rate of the spiketrain

Raises:
TypeError

If spiketrain is a np.ndarray and t_start or t_stop is pq.Quantity.

Notes

If spiketrain is a pq.Quantity or neo.SpikeTrain, and t_start or t_stop are not pq.Quantity, t_start and t_stop are assumed to have the same units as spiketrain.