spiketools.utils.extract.threshold_spikes_by_times

spiketools.utils.extract.threshold_spikes_by_times(spikes, timestamps, time_threshold)[source]

Threshold spikes by sub-selecting those that are temporally close to a set of time values.

Parameters:
spikes1d array

Spike times, in seconds.

timestamps1d array

Timestamps, in seconds.

time_thresholdfloat, optional

The threshold that the closest time value must be to a spike for it to be returned. If the temporal distance is greater than the threshold, spike is dropped.

Returns:
spikes1d array

Sub-selected spike times, in seconds.

Examples

Extract spikes based on their proximity to timestamps:

>>> spikes = np.array([0.76, 1.12, 1.72, 2.05, 2.32, 2.92, 3.11, 3.63, 3.91])
>>> timestamps = np.array([1.0, 1.25, 1.5, 1.75, 2.0, 3.5, 3.75, 4.0])
>>> threshold_spikes_by_times(spikes, timestamps, time_threshold=0.25)
array([0.76, 1.12, 1.72, 2.05, 3.63, 3.91])