spiketools.measures.spikes.compute_spike_presence

spiketools.measures.spikes.compute_spike_presence(spikes, bins, time_range=None)[source]

Compute the spike presence across time bins.

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 presence across. Only used if bins is a float.

Returns:
spike_presence1d array

Boolean array indicating spike presence across time bins.

Examples

Compute the spike presence from spike times:

>>> spikes = np.array([0.25, 1.15, 1.75, 2.25, 2.75, 4.5])
>>> compute_spike_presence(spikes, bins=1, time_range=[0, 5])
array([ True,  True,  True, False,  True])