superneuromat.SNN.ispikes#
- property SNN.ispikes: ndarray[(<class 'int'>, <class 'int'>), None][source]#
Convert the output spike train to a dense binary
numpy.ndarray
.This is useful for slicing and analyzing the spike train.
Index with
snn.ispikes[time, neuron]
.Note that this is converted from the output spike train, which may be cleared with
clear_spike_train()
orreset()
.- Returns:
The
dtype
of the array will bedefault_bool_dtype
.- Return type:
numpy.ndarray[(int, int), bool]
Examples
>>> # Here's an example spike train: >>> snn.ispikes array([[False, False, False, False, True], [False, True, False, True, True], [ True, True, True, True, True], [ True, True, False, False, False]]) >>> snn.print_spike_train() t|id0 1 2 3 4 0: [│ │ │ │ ├─] 1: [│ ├─│ ├─├─] 2: [├─├─├─├─├─] 3: [├─├─│ │ │ ]
>>> # single neuron >>> snn.ispikes[0, 0] # True if neuron 0 spiked at time 0 np.False_
>>> # multiple neurons >>> snn.ispikes[0, :] # Whether a neuron spiked at time step 0 array([False, False, False, False, True]) >>> snn.ispikes[:, 0] # Whether neuron 0 spiked for a particular time step array([False, False, True, True]) >>> snn.ispikes[-1] # Whether a neuron spiked at the last time step array([ True, True, False, False, False]) >>> snn.ispikes[-3:].sum() # Number of spikes emitted in the last 3 time steps np.int64(10) >>> snn.ispikes[-3:].sum(0) # Number of spikes emitted for each neuron in the last 3 time steps array([2, 3, 1, 2, 2]) >>> snn.ispikes[:, 2:].sum(0) # Number of spikes emitted by the first 2 neurons over all time array([2, 3]) >>> snn.ispikes.sum(1) # number of spikes emitted per neuron over all time array([1, 3, 5, 2])