ezmsg.event.kernel_insert#

Insert kernels at sparse event locations to produce dense signals.

This module provides efficient sparse-to-dense conversion by inserting kernel waveforms at event locations. Overlapping kernels are summed.

Classes

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

Bases: BaseStatefulTransformer[SparseKernelInserterSettings, AxisArray, AxisArray, SparseKernelInserterState]

Insert kernels at sparse event locations, producing dense output.

Input: AxisArray with sparse.COO data where:
  • coords[0]: sample indices (time)

  • coords[1]: channel indices

  • data: event values (used for MultiKernel selection or scaling)

Output: AxisArray with dense data containing inserted kernels.

Features:
  • Handles chunk boundaries seamlessly (kernel tails carry over)

  • Overlapping kernels are summed additively

  • Supports acausal kernels (pre_samples > 0)

  • Efficient O(n_events * kernel_length) instead of dense convolution

class SparseKernelInserterSettings(kernel=None, scale_by_value=False, output_dtype=<class 'numpy.float64'>)[source]#

Bases: Settings

Settings for SparseKernelInserter.

Parameters:
kernel: Kernel | MultiKernel | None = None#

Kernel to insert at event locations. - Kernel: Same kernel for all events. - MultiKernel: Different kernels based on event value. - None: Events are treated as unit impulses (delta functions).

scale_by_value: bool = False#

If True, scale kernel amplitude by event value. If False, event value is used only for MultiKernel selection.

output_dtype#

Data type for output array.

alias of float64

__init__(kernel=None, scale_by_value=False, output_dtype=<class 'numpy.float64'>)#
Parameters:
Return type:

None

class SparseKernelInserterState[source]#

Bases: object

State for SparseKernelInserter.

pending: ndarray[tuple[Any, ...], dtype[floating]] | None = None#
pending_length: int = 0#
class SparseKernelInserterUnit(*args, settings=None, **kwargs)[source]#

Bases: BaseTransformerUnit[SparseKernelInserterSettings, AxisArray, AxisArray, SparseKernelInserter]

Unit for SparseKernelInserter.

Parameters:

settings (Settings | None)

SETTINGS#

alias of SparseKernelInserterSettings