ezmsg.simbiophys.dnss#

DNSS (Digital Neural Signal Simulator) signal generation.

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

Bases: BaseClockDrivenProducer[DNSSLFPSettings, DNSSLFPState]

Produces DNSS LFP signal synchronized to clock ticks.

Each clock tick produces a block of LFP data based on the sample rate (fs) and chunk size (n_time) settings. All channels receive identical LFP values.

class DNSSLFPSettings(fs=30000, n_time=None, n_ch=256, pattern='spike', mode='hdmi')[source]#

Bases: ClockDrivenSettings

Settings for DNSS LFP producer.

Parameters:
__init__(fs=30000, n_time=None, n_ch=256, pattern='spike', mode='hdmi')#
Parameters:
Return type:

None

fs: float = 30000#

Sample rate in Hz. DNSS is fixed at 30kHz.

mode: str = 'hdmi'#

“hdmi” for digital output, “pedestal_norm” or “pedestal_wide” for analog.

Type:

Mode

n_ch: int = 256#

Number of channels.

pattern: str = 'spike'#

“spike” for normal neural signal mode, “other” for other mode.

Type:

LFP pattern

class DNSSLFPState[source]#

Bases: ClockDrivenState

State for DNSS LFP producer.

lfp_gen: Optional[Generator] = None#
template: AxisArray | None = None#
class DNSSLFPUnit(*args, settings=None, **kwargs)[source]#

Bases: BaseClockDrivenUnit[DNSSLFPSettings, DNSSLFPProducer]

Unit for generating DNSS LFP from clock input.

Parameters:

settings (Settings | None)

SETTINGS#

alias of DNSSLFPSettings

lfp_generator(pattern='spike', mode='hdmi', fs=30000)[source]#

Generator yielding LFP samples for the DNSS pattern.

This is a send-able generator. After priming with next(), use send(n_samples) to get LFP values for the next n_samples window. The generator maintains internal state tracking the current sample position.

Parameters:
  • pattern (str) – “spike” for normal neural signal mode, “other” for other mode.

  • mode (str) – “hdmi” for digital output, “pedestal_norm” or “pedestal_wide” for analog.

  • fs (float) – Sample rate in Hz.

Yields:

1D array of LFP values (same for all channels).

Return type:

Generator[ndarray[tuple[Any, ...], dtype[float64]], int, None]

Example

gen = lfp_generator(fs=30000) next(gen) # Prime the generator lfp = gen.send(30000) # Get 1 second of LFP lfp = gen.send(15000) # Get next 0.5 seconds

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

Bases: BaseClockDrivenProducer[DNSSSpikeSettings, DNSSSpikeState]

Produces DNSS spike signal synchronized to clock ticks.

Each clock tick produces a block of spike data as sparse COO arrays based on the sample rate (fs) and chunk size (n_time) settings.

class DNSSSpikeSettings(fs=30000, n_time=None, n_ch=256, mode='hdmi')[source]#

Bases: ClockDrivenSettings

Settings for DNSS spike producer.

Parameters:
__init__(fs=30000, n_time=None, n_ch=256, mode='hdmi')#
Parameters:
Return type:

None

fs: float = 30000#

Sample rate in Hz. DNSS is fixed at 30kHz.

mode: str = 'hdmi'#

“hdmi” reproduces HDMI bugs, “ideal” for ideal pattern.

Type:

Mode

n_ch: int = 256#

Number of channels.

class DNSSSpikeState[source]#

Bases: ClockDrivenState

State for DNSS spike producer.

spike_gen: Optional[Generator] = None#
template: AxisArray | None = None#
class DNSSSpikeUnit(*args, settings=None, **kwargs)[source]#

Bases: BaseClockDrivenUnit[DNSSSpikeSettings, DNSSSpikeProducer]

Unit for generating DNSS spikes from clock input.

Parameters:

settings (Settings | None)

SETTINGS#

alias of DNSSSpikeSettings

spike_event_generator(mode='hdmi', n_chans=4)[source]#

Generator yielding spike event indices for the DNSS pattern.

This is a send-able generator. After priming with next(), use send(n_samples) to get spikes for the next n_samples window. The generator maintains internal state tracking the current sample position.

Parameters:
  • mode (str) – “hdmi” to reproduce HDMI bugs, “ideal” for ideal pattern.

  • n_chans (int) – Number of channels in the slow-phase rotation (default 4).

Yields:

Tuple of (coords, waveform_ids)

  • coords: Shape (2, n_spikes) array of [sample_indices, channel_indices]

  • waveform_ids: Waveform shape identifiers (1, 2, or 3)

Return type:

Generator[tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]], int, None]

Example

gen = spike_event_generator() next(gen) # Prime the generator coords, waveforms = gen.send(30000) # Get spikes in first 30000 samples coords, waveforms = gen.send(15000) # Get spikes in next 15000 samples

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

Bases: Collection

DNSS Signal Synthesizer.

A Collection that generates combined DNSS spike and LFP signals. Uses a common Clock to synchronize: - Spike generation (sparse events with waveform insertion) - LFP generation (sum of sinusoids)

The final output is the sum of spike waveforms and LFP signal.

Network flow:

Clock -> {SpikeGenerator, LFPGenerator} SpikeGenerator -> KernelInserter -> Add.A LFPGenerator -> Add.B Add -> OUTPUT

Parameters:

settings (Settings | None)

ADD = <ezmsg.sigproc.math.add.Add object>#
CLOCK = <ezmsg.baseproc.clock.Clock object>#
KERNEL_INSERT = <ezmsg.event.kernel_insert.SparseKernelInserterUnit object>#
LFP = <ezmsg.simbiophys.dnss.lfp.DNSSLFPUnit object>#
OUTPUT_SIGNAL = OutputStream:unlocated[<class 'ezmsg.util.messages.axisarray.AxisArray'>](self.num_buffers=32, self.force_tcp=False)#
SETTINGS#

alias of DNSSSynthSettings

SPIKE = <ezmsg.simbiophys.dnss.spike.DNSSSpikeUnit object>#
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.

Return type:

None

network()[source]#

Override this method and have the definition return a NetworkDefinition which defines how InputStream and OutputStream from member Unit s will be connected.

Return type:

Iterable[Tuple[Union[Stream, str], Union[Stream, str]]]

class DNSSSynthSettings(n_time=600, n_ch=256, lfp_pattern='spike', mode='hdmi')[source]#

Bases: Settings

Settings for DNSS Synthesizer.

Parameters:
__init__(n_time=600, n_ch=256, lfp_pattern='spike', mode='hdmi')#
Parameters:
Return type:

None

lfp_pattern: str = 'spike'#

“spike” or “other”.

Type:

LFP pattern

mode: str = 'hdmi'#

“hdmi” reproduces HDMI bugs, “pedestal_norm” or “pedestal_wide” for analog.

Type:

Mode

n_ch: int = 256#

Number of channels.

n_time: int = 600#

600 = 20ms at 30kHz).

Type:

Number of samples per block (default

Modules

lfp

# LFP

pattern_match

spike

Produce data mimicking Blackrock Neurotech's Digital Neural Signal Simulator

synth

DNSS Synthesizer - Combined spike and LFP signal generation.

wfs

Spike waveforms matching Blackrock Neurotech's DNSS