spiketools.utils.extract.threshold_spikes_by_values

spiketools.utils.extract.threshold_spikes_by_values(spikes, timestamps, values, min_value=None, max_value=None, time_threshold=None)[source]

Threshold spikes by sub-selecting based on thresholding values on another data stream.

Parameters:
spikes1d array

Spike times, in seconds.

timestamps1d array

Timestamps, in seconds.

values1d array

Data values, corresponding to the timestamps.

min_value, max_valuefloat, optional

Minimum and/or maximum threshold value to select spikes based on. The minimum value is inclusive, but the maximum value is exclusive.

time_thresholdfloat, optional

The threshold value for the time between the spike and a timestamp for the spike to be kept. Any spikes further in time from a timestamp value are dropped.

Returns:
spikes1d array

Sub-selected spike times, in seconds.

Examples

Threshold spikes based on a minimum data threshold:

>>> spikes = np.array([0.1, 0.4, 1.2, 1.6, 1.8, 2.5, 2.9])
>>> timestamps = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0])
>>> values = np.array([1.0, 2.0, 3.0, 2.0, 3.0, 2.0])
>>> threshold_spikes_by_values(spikes, timestamps, values, min_value=2.5)
array([1.6, 2.5])