spiketools.measures.conversions.convert_times_to_counts¶
- spiketools.measures.conversions.convert_times_to_counts(spikes, bins, time_range=None)[source]¶
Convert spikes times to counts of spikes per time bin.
- 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 spike counts across. Only used if bins is a float.
- Returns:
- spike_bin_counts1d array
Vector of counts of the number of spikes per time bin.
Examples
Convert spike times (in seconds) to counts of spikes per time bin:
>>> spikes = np.array([0.100, 0.350, 0.450, 0.775, 0.975]) >>> convert_times_to_counts(spikes, bins=0.250) array([1, 2, 0, 2])