ezmsg.event.binned#

Bin an event stream into a lower-rate count (or rate) signal.

The binning is delegated to ezmsg.sigproc.binned_aggregate.BinnedAggregate so this shares one bin-boundary implementation with every other consumer of that binner. With fractional=True (the default) bins span a fractional bin_duration * fs samples with a carry accumulator and are labelled with the nominal bin_duration gain; with fractional=False they span a fixed int(bin_duration * fs) samples (sample-locked, matching ezmsg.sigproc.window.Window). Because the grid comes from the shared binner, two streams binned this way at the same bin_duration land on the same grid for any input rate and can be aligned downstream (e.g. with ezmsg.sigproc.merge.Merge).

Sparse sparse.COO inputs (e.g. the default ezmsg.event.peak.ThresholdCrossing output) are densified to per-sample contributions before binning; dense inputs are used as is. Set scale_by_value=True to weight each event by its stored value instead of counting occurrences, and scale_output=True to divide the per-bin count by bin_duration (events/second).

Classes

class BinnedEventAggregator(*args, **kwargs)[source]#

Bases: BaseTransformer[BinnedEventAggregatorSettings, AxisArray, AxisArray]

Count events per fixed-duration bin, delegating binning to sigproc.

The per-bin reduction, carry across message boundaries, and output time axis all come from BinnedAggregateTransformer; this wrapper only converts events to per-sample contributions and optionally rate-normalizes.

__init__(*args, **kwargs)[source]#
Return type:

None

class BinnedEventAggregatorSettings(bin_duration: float = 0.05, scale_output: bool = True, axis: str = 'time', fractional: bool = True, scale_by_value: bool = False)[source]#

Bases: Settings

Parameters:
bin_duration: float = 0.05#

Duration of each output bin in seconds.

scale_output: bool = True#

If True, divide each bin’s count by bin_duration (events/second).

axis: str = 'time'#

Name of the axis to bin along.

fractional: bool = True#

If True (default), bins span a fractional bin_duration * fs samples via BinnedAggregate and are labelled with the nominal bin_duration gain. If False, bins span a fixed int(bin_duration * fs) samples (sample-locked). See BinnedAggregate.

scale_by_value: bool = False#

If True, weight each event by its stored value; if False (default), every nonzero entry contributes a count of 1.

__init__(bin_duration=0.05, scale_output=True, axis='time', fractional=True, scale_by_value=False)#
Parameters:
Return type:

None

class BinnedEventAggregatorUnit(*args, settings=None, **kwargs)[source]#

Bases: BaseTransformerUnit[BinnedEventAggregatorSettings, AxisArray, AxisArray, BinnedEventAggregator]

Parameters:

settings (Settings | None)

SETTINGS#

alias of BinnedEventAggregatorSettings