spiketools.utils.epoch.epoch_data_by_time

spiketools.utils.epoch.epoch_data_by_time(timestamps, values, timepoints, time_threshold=None)[source]

Epoch data into trials, based on individual timepoints of interest.

Parameters:
timestamps1d array

Timestamps, in seconds.

values1d or 2d array

Data values.

timepointslist of float

The time value(s), in seconds, to extract per trial.

time_thresholdfloat, optional

The threshold that the closest time value must be within to be returned. If the temporal distance is greater than the threshold, output is NaN.

Returns:
trialslist of float

Selected data points across trial.

Examples

Epoch data values based on individual timepoints:

>>> timestamps = np.array([0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5])
>>> values = np.array([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5])
>>> timepoints = [0.3, 0.7, 1.3]
>>> epoch_data_by_time(timestamps, values, timepoints)
[1.5, 2.5, 4.0]