spiketools.utils.extract.get_value_range¶
- spiketools.utils.extract.get_value_range(timestamps, data, min_value=None, max_value=None, reset=None)[source]¶
Extract data and associated timestamps for a desired value range.
- Parameters:
- timestamps1d array
Timestamps, in seconds.
- data1d array
Data values, corresponding to the timestamps.
- min_value, max_valuefloat, optional
Minimum and/or maximum value to extract from the input array. The minimum value is inclusive, but the maximum value is exclusive.
- resetfloat, optional
If provided, resets the time values by the given reset value.
- Returns:
- timestamps1d array
Timestamps, in seconds, selected by value.
- data1d array
Array of data, selected by value.
Examples
Extract data and corresponding timestamps based on value range:
>>> data = np.array([1, 2, 3, 4, 5, 6, 7, 8]) >>> timestamps = np.array([0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.2, 1.5]) >>> get_value_range(timestamps, data, min_value=2.5, max_value=6.5) (array([0.4, 0.5, 0.7, 0.9]), array([3, 4, 5, 6]))