| 1 |
{# USES_VARIABLES { _spikespace, neuron_index, _timebins, _period_bins, _lastindex, t_in_timesteps } #} |
| 2 |
{% extends 'common_group.py_' %} |
| 3 |
|
| 4 |
{% block maincode %} |
| 5 |
_the_period = {{_period_bins}} |
| 6 |
_timebin = {{t_in_timesteps}} |
| 7 |
_n_spikes = 0 |
| 8 |
|
| 9 |
_lastindex_before = {{_lastindex}} |
| 10 |
|
| 11 |
if _the_period > 0: |
| 12 |
_timebin %= _the_period |
| 13 |
# If there is a periodicity in the SpikeGenerator, we need to reset the |
| 14 |
# lastindex when the period has passed |
| 15 |
if _lastindex_before > 0 and {{_timebins}}[_lastindex_before - 1] >= _timebin: |
| 16 |
_lastindex_before = 0 |
| 17 |
|
| 18 |
_n_spikes = _numpy.searchsorted({{_timebins}}[_lastindex_before:], |
| 19 |
_timebin, side='right') |
| 20 |
|
| 21 |
{{_lastindex}} = _lastindex_before + _n_spikes |
| 22 |
|
| 23 |
_indices = {{neuron_index}}[_lastindex_before:_lastindex_before+_n_spikes] |
| 24 |
|
| 25 |
{{_spikespace}}[:_n_spikes] = _indices |
| 26 |
{{_spikespace}}[-1] = _n_spikes |
| 27 |
{% endblock %} |