ezmsg.simbiophys.system.velocity2ecephys#

Convert 2D cursor velocity to simulated extracellular electrophysiology.

This module provides a complete system that encodes cursor velocity into realistic ecephys signals containing both spike waveforms and LFP-like background activity.

Pipeline:

velocity (x,y) -> CART2POL --+--> Velocity2Spike --> spikes --|
                             |                                +--> Add --> ecephys
                             +--> Velocity2LFP ----> lfp -----|

The coordinate transformation from Cartesian to polar is done once at the input, then shared by both spike and LFP encoding branches.

This is the top-level system for velocity-encoded neural simulation. Use this when you need full ecephys-like output suitable for testing BCI decoders.

See also

ezmsg.simbiophys.system.velocity2spike: Spike-only encoding. ezmsg.simbiophys.system.velocity2lfp: LFP-only encoding.

Classes

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

Bases: Collection

Encode cursor velocity into simulated extracellular electrophysiology.

This system combines spike and LFP encoding to produce realistic ecephys signals. It runs two parallel pipelines:

  1. Spike branch (Velocity2Spike): Generates cosine-tuned spike waveforms based on velocity direction and magnitude.

  2. LFP branch (Velocity2LFP): Generates velocity-modulated colored noise representing local field potentials.

The outputs are summed to produce the final ecephys signal.

Input:

AxisArray with shape (N, 2) containing cursor velocity in pixels/second. Dimension 0 is time, dimension 1 is [vx, vy].

Output:

AxisArray with shape (M, output_ch) containing combined spike and LFP signals at output_fs sampling rate.

Example

>>> encoder = VelocityEncoder(VelocityEncoderSettings(
...     output_fs=30_000.0,
...     output_ch=256,
...     seed=42,
... ))
Parameters:

settings (Settings | None)

SETTINGS#

alias of VelocityEncoderSettings

INPUT_SIGNAL = InputStream:unlocated[AxisArray]()#
COORDS = <ezmsg.sigproc.coordinatespaces.CoordinateSpaces object>#
SPIKES = <ezmsg.simbiophys.system.velocity2spike.Velocity2Spike object>#
LFP = <ezmsg.simbiophys.system.velocity2lfp.Velocity2LFP object>#
ADD = <ezmsg.sigproc.math.add.Add object>#
OUTPUT_SIGNAL = OutputStream:unlocated[AxisArray](self.num_buffers=32, self.force_tcp=False)#
configure()[source]#

A lifecycle hook that runs when the Collection is instantiated.

This is the best place to call Unit.apply_settings() on each member Unit of the Collection. Override this method to perform collection-specific configuration of child components.

Return type:

None

network()[source]#

Override this method and have the definition return a NetworkDefinition which defines how InputStreams and OutputStreams from member Units will be connected.

The NetworkDefinition specifies the message routing between components by connecting output streams to input streams.

Returns:

Network definition specifying stream connections

Return type:

NetworkDefinition

class VelocityEncoderSettings(output_fs=30000.0, output_ch=256, seed=6767)[source]#

Bases: Settings

Settings for VelocityEncoder.

Parameters:
output_fs: float = 30000.0#

Output sampling rate in Hz.

output_ch: int = 256#

Number of output channels (simulated electrodes).

seed: int = 6767#

Random seed for reproducible spike and LFP generation.

__init__(output_fs=30000.0, output_ch=256, seed=6767)#
Parameters:
Return type:

None