send_steps_from_pre

send_steps_from_pre#

class brainpy.state.network.send_steps_from_pre(pre_spikes, pre_of_edge=None, *, lag=0)[source]#

Step indices where each edge’s presynaptic neuron fired (the send mask).

Parameters:
  • pre_spikes (array_like) – (T,) single-pre spike train, or (T, n_pre) population matrix (1/0 or boolean). A send is a step where the edge’s presynaptic neuron fired.

  • pre_of_edge (array_like of int, optional) – (E,) population-local presynaptic index per edge in CSR (sorted-by-pre) order, i.e. proj.pre_local_idx[proj._pre_idx]. None uses a (T,) train (or the lone column of a (T, 1) matrix) for every edge.

  • lag (int, optional) – Offset added to each fire step to align with the weight trajectory. The full Simulator reads the per-population spike holder one step late, so a presynaptic spike at step s shows up in weight_trace[s + lag] (lag=1); the direct-feed parity drives feed the projection in-step (lag=0, the default). Shifted steps outside [0, T) are clipped.

Returns:

(n_send,) integer array for a single presynaptic train (pre_of_edge is None), otherwise a length-E list of per-edge integer arrays (CSR order).

Return type:

numpy.ndarray or list of numpy.ndarray

Raises:

ValueError – If pre_spikes is a multi-column (T, n_pre) matrix and pre_of_edge is not supplied.

See also

weight_recorder_events

Sample a weight trajectory at the send steps.

Examples

>>> import numpy as np
>>> from brainpy_state._nest_network import send_steps_from_pre
>>> pre = np.zeros(8); pre[[2, 5]] = 1
>>> send_steps_from_pre(pre).tolist()
[2, 5]