spiketools.utils.epoch.epoch_spikes_by_event

spiketools.utils.epoch.epoch_spikes_by_event(spikes, events, window)[source]

Epoch spiking data into trials, based on events of interest.

Parameters:
spikes1d array

Spike times, in seconds.

events1d array

The set of event times, in seconds, to extract from the data.

windowlist of [float, float]

The time window, in seconds, to extract around each event.

Returns:
trialslist of 1d array

Spike times, in seconds, per trial.

Notes

For each trial, the returned spike times will be relative to each event time, set as zero.

Examples

Epoch spike times based on an event window:

>>> spikes = np.array([0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 1.3])
>>> events = np.array([0.2, 0.8, 1.2])
>>> window = [0.0, 0.25]
>>> epoch_spikes_by_event(spikes, events, window)
[array([0.1, 0.2]), array([0.1]), array([0.1])]