weight_recorder_events

weight_recorder_events#

class brainpy.state.network.weight_recorder_events(weight_trace, send_steps)[source]#

Per-send weight events over a weight trajectory (the thin send-view).

NEST’s weight_recorder logs one event per plastic send, value = the weight at send-time (our post-send weight_trace value). This masks the dense per-step trajectory to the send steps.

Parameters:
  • weight_trace (array_like) – (T,) or (T, E) per-step weight (or delivered amplitude) trajectory, sampled post-update (the order NEST logs: after this send’s pairing update).

  • send_steps (numpy.ndarray or list of numpy.ndarray) – (n_send,) integer send-step indices (e.g. from send_steps_from_pre()), or a length-E list of per-edge step arrays masking each column of a (T, E) trace independently (multapses recording in CSR order).

Returns:

(steps, weights) with steps == send_steps and weights == weight_trace[steps] ((n_send,) for a 1-D trace, or (n_send, E) for shared steps over a 2-D trace); a list of (steps_e, weights_e) per edge when send_steps is a per-edge list.

Return type:

tuple or list

Raises:

ValueError – If send_steps is a per-edge list but weight_trace is not 2-D, or the list length does not match the number of trace columns.

See also

send_steps_from_pre

Build the send mask from a presynaptic spike train.

Notes

A weight change strictly between the last send and the run end is absent from the events (NEST’s recorder logs only at sends, so it misses it too); read it from weight_trace[-1] / the final connection weight instead.

Examples

>>> import numpy as np
>>> from brainpy_state._nest_network import weight_recorder_events
>>> trace = np.array([5.0, 4.0, 4.0, 3.0])
>>> steps, w = weight_recorder_events(trace, np.array([1, 3]))
>>> steps.tolist(), w.tolist()
([1, 3], [4.0, 3.0])