spiketools.measures.conversions.convert_times_to_rates¶
- spiketools.measures.conversions.convert_times_to_rates(spikes, bins, time_range=None, smooth=None)[source]¶
Convert spike times to continuous firing rates.
- Parameters:
- spikes1d array
Spike times, in seconds.
- binsfloat or 1d array
The binning to apply to the spiking data. If float, the time length of each bin. If array, precomputed bin definitions.
- time_rangelist of [float, float], optional
Time range, in seconds, to calculate the binned firing rate across. Only used if bins is a float.
- smoothfloat, optional
If provided, the kernel to use to smooth the continuous firing rate.
- Returns:
- cfr1d array
Continuous firing rate, compute across time bins.
Examples
Convert spike times (in seconds) to continuous firing rate across bins:
>>> spikes = np.array([0.002, 0.250, 0.450, 0.500, 0.750, 1.000, 1.250, 1.300, 1.400, 1.500]) >>> convert_times_to_rates(spikes, bins=0.2) array([ 5., 5., 10., 5., 0., 5., 15., 5.])