spiketools.utils.extract.get_inds_by_values¶
- spiketools.utils.extract.get_inds_by_values(values, select, threshold=None, drop_null=True)[source]¶
Get indices for a set of specified time points.
- Parameters:
- values1d array
Values to select from.
- select1d array
The values to extract indices for.
- thresholdfloat, optional
The threshold that the closest value must be within to be returned. If the distance is greater than the threshold, output is -1.
- drop_nullbool, optional, default: True
Whether to drop any null indices from the outputs (outside threshold range). If False, indices for any null values are -1.
- Returns:
- inds1d array
Indices for all requested values.
Examples
Get the corresponding indices for specified values:
>>> values = np.array([10, 15, 20, 25, 30]) >>> select = np.array([11, 21]) >>> get_inds_by_values(values, select) array([0, 2])