bin_spikes#
- torch_brain.utils.bin_spikes(spikes, num_units, bin_size, max_spikes=None, right=True, eps=0.001, dtype=<class 'numpy.int32'>)[source]#
Bins spikes into time bins of size bin_size. If the total time spanned by the spikes is not a multiple of bin_size, the spikes are truncated to the nearest multiple of bin_size. If right is True, the spikes are truncated from the left end of the time series, otherwise they are truncated from the right end.
Notes
The number of units cannot be inferred from a subset of spikes, so
num_unitsmust be provided explicitly.Floating-point roundoff can cause
(end - start) / bin_sizeto be very close to an integer without being exact (e.g. 9.99999999). Theepsparameter is added before flooring to make the bin-count computation numerically robust.
- Parameters:
spikes (
IrregularTimeSeries) – IrregularTimeSeries object containing the spikes.num_units (
int) – Number of units in the population.bin_size (
float) – Size of the time bins in seconds.max_spikes (
Optional[int]) – Maximum number of spikes to include per unit per bin. IfNone, no clipping is applied.right (
bool) – Decide which side gets truncated when duration is not a multiple ofbin_size. IfTrue, excess spikes are truncated from the left edge.eps (
float) – Small numerical margin used during bin assignment.dtype (
dtype) – Data type of the output binned array. (defaultnp.int32)
- Return type:
- Returns:
Binned spike counts with shape
(T, N), whereTis the number of time bins andNisnum_units.