File: spikegenerator.py_

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (27 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{# USES_VARIABLES { _spikespace, neuron_index, _timebins, _period_bins, _lastindex, t_in_timesteps } #}
{% extends 'common_group.py_' %}

{% block maincode %}
_the_period    = {{_period_bins}}
_timebin       = {{t_in_timesteps}}
_n_spikes      = 0

_lastindex_before = {{_lastindex}}

if _the_period > 0:
    _timebin %= _the_period
    # If there is a periodicity in the SpikeGenerator, we need to reset the
    # lastindex when the period has passed
    if _lastindex_before > 0 and {{_timebins}}[_lastindex_before - 1] >= _timebin:
        _lastindex_before = 0

_n_spikes = _numpy.searchsorted({{_timebins}}[_lastindex_before:],
                                _timebin, side='right')

{{_lastindex}} = _lastindex_before + _n_spikes

_indices = {{neuron_index}}[_lastindex_before:_lastindex_before+_n_spikes]

{{_spikespace}}[:_n_spikes] = _indices
{{_spikespace}}[-1] = _n_spikes
{% endblock %}