spiketools.utils.extract.get_value_by_time

spiketools.utils.extract.get_value_by_time(timestamps, values, timepoint, time_threshold=None, axis=None)[source]

Get the value from a data array at a specific time point.

Parameters:
timestamps1d array

Timestamps, in seconds.

values1d or 2d array

Data values, corresponding to the time values in timestamps.

timepointfloat

Time value to extract.

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 -1.

axis{0, 1}, optional

The axis argument for the values data, if it’s a 2d array, as {0: column, 1: row}. If not provided, is inferred from the values array.

Returns:
outfloat or 1d array

The value(s) at the requested time point.

Examples

Get the data values for a specified timepoint:

>>> timestamps = np.array([0.5, 1, 1.5, 2, 2.5, 3 ])
>>> values = np.array([[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]])
>>> get_value_by_time(timestamps, values, 1.5)
array([3, 9])