spiketools.utils.epoch.epoch_spikes_by_range¶
- spiketools.utils.epoch.epoch_spikes_by_range(spikes, start_times, stop_times, reset=False)[source]¶
Epoch spiking data into trials, based on time ranges of interest.
- Parameters:
- spikes1d array
Spike times, in seconds.
- start_times, stop_timeslist of float
The start and stop times, in seconds, of each epoch.
- resetbool, optional, default: False
Whether to reset each set of trial timestamps to start at zero.
- Returns:
- trialslist of 1d array
Spike times per trial.
Examples
Epoch an array of spiking data into trials, resetting each trial to start at time 0:
>>> spikes = np.array([0.1, 0.2, 0.3, 0.5, 0.6, 0.7, 1, 1.4]) >>> start_times = [0.0, 0.45, 0.9] >>> stop_times = [0.4, 0.85, 1.35] >>> epoch_spikes_by_range(spikes, start_times, stop_times, reset=True) [array([0.1, 0.2, 0.3]), array([0.05, 0.15, 0.25]), array([0.1])]