dspk.synapse.extraction
Snippets: the waveform around each spike, on its nearest channels.
snippets |
The waveform around each spike, on its nearest channels. |
Functions
Section titled “Functions”snippets
Section titled “snippets”snippets( data, spikes: dict, probe: Probe, sample_rate: float, *, k: int = DEFAULT_K_NEIGHBORS, pre_ms: float = DEFAULT_PRE_MS, post_ms: float = DEFAULT_POST_MS, sinc_shift: bool = False,) -> dictThe waveform around each spike, on its nearest channels.
Parameters
data:array_like
Signal(channels, samples)in µV, converted to float32 on the host.spikes:dict of numpy.ndarray
samplesandchannels, as the detectors return.probe:Probe
The probe, for each spike’s nearest channels.sample_rate:float
Sample rate in Hz.k:int, defaultDEFAULT_K_NEIGHBORS(4)
Channels per snippet.pre_ms:float, defaultDEFAULT_PRE_MS(1.0)
The span[t - pre_ms, t + post_ms)around each spike.post_ms:float, defaultDEFAULT_POST_MS(2.0)
The span[t - pre_ms, t + post_ms)around each spike.sinc_shift:bool, defaultFalse
Realign each snippet to its sub-sample trough.
Returns
dict of np.ndarray—waveforms(spikes, k, samples),channels(spikes, k),centers,offsets, andkept: the input index of each snippet (spikes too near an edge are skipped).
Examples
>>> import numpy as np>>> import dspk>>> x = np.random.default_rng(0).standard_normal((4, 30_000)).astype(np.float32) * 10>>> x[1, 15_000:15_010] -= 120 # one spike>>> spikes = dspk.synapse.detection.threshold(x, 30_000.0)>>> probe = dspk.synapse.io.Probe.preset("tetrode")>>> snips = dspk.synapse.extraction.snippets(x, spikes, probe, 30_000.0, k=4)>>> snips["waveforms"].shape[1:](4, 90)