spiketools.utils.checks.check_time_bins¶
- spiketools.utils.checks.check_time_bins(bins, time_range=None, values=None, check_range=False)[source]¶
Check a given time bin definition, and define if only given a time resolution.
- Parameters:
- binsfloat or 1d array
The binning to apply to the spiking data. If float, the length of each bin. If array, precomputed bin definitions.
- time_rangelist of [float, float], optional
Time range, in seconds, to create the binned firing rate across. Only used if bins is a float. If given, the end value is inclusive.
- values1d array, optional
The time values that are to be binned. Optional if time_range is provided instead.
- check_rangebool, optional, default: False
Whether to check the range of the data values against the time bins.
- Returns:
- bins1d array
Time bins.
Examples
Check a time bin definition, where bins are defined as a bin length:
>>> bins = 0.5 >>> values = np.array([0.2, 0.4, 0.6, 0.9, 1.4, 1.5, 1.6, 1.9]) >>> time_range = [0., 2.] >>> check_time_bins(bins, time_range, values) array([0. , 0.5, 1. , 1.5, 2. ])
Check a time bin definition, where bins are already defined:
>>> bins = np.array([0. , 0.5, 1. , 1.5, 2. ]) >>> check_time_bins(bins, time_range, values) array([0. , 0.5, 1. , 1.5, 2. ])