spiketools.measures.spikes.compute_presence_ratio

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

Compute the presence ratio for a set of spike times.

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

Returns:
presence_ratiofloat

The computed presence ratio.

Notes

The presence ratio reflects the proportion of time bins in which at least 1 spike occurred.

Examples

Compute the presence ratio from spike times:

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