spiketools.utils.extract.get_values_by_time_range¶
- spiketools.utils.extract.get_values_by_time_range(timestamps, values, t_min, t_max, axis=None)[source]¶
Extract data for a requested time range.
- Parameters:
- timestamps1d array
Timestamps, in seconds.
- valuesndarray
Data values, corresponding to the time values in timestamps.
- t_min, t_maxfloat
Time range to extract.
- 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:
- timestamps1d array
Selected timestamp values.
- outndarray
Selected data values.
Examples
Extract data within a specified time range:
>>> timestamps = np.array([1, 2, 3, 4, 5, 6, 7]) >>> values = np.array([0.5, 1, 1.5, 2, 2.5, 3, 3.5]) >>> get_values_by_time_range(timestamps, values, t_min=2, t_max=6) (array([2, 3, 4, 5, 6]), array([1. , 1.5, 2. , 2.5, 3. ]))