New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible indexing error when using SpikeMonitor with a subgroup on numpy #824

mstimberg opened this Issue Mar 14, 2017 · 0 comments


None yet
1 participant

mstimberg commented Mar 14, 2017

As reported on the mailing list, using SpikeMonitor on subgroups can lead to an indexing error as in this example:

from brian2 import * = 'numpy'
duration = 100*ms
G = NeuronGroup(10, '''dv/dt = -v/tau : volt
                       tau : second''',
                threshold='v > -50*mV',
                reset='v = -70*mV',
G.v = -65*mV
# Create subgroups
G1 = G[:5]
G2 = G[5:]
G1.tau = 10*ms
G2.tau = 10*ms

The reason is a stupid check in the SpikeMonitor template, meant to avoid unnecessary filtering if a SpikeMonitor records from the full group (which is the common case):

if _source_start != 0 or _source_stop != {{N}}:

The check is meant to check whether _source_stop is equal to the size of the full group, but {{N}} here refers to the number of recorded spikes in this SpikeMonitor... So if a SpikeMonitor records from a subgroup starting at the beginning of a group (like G1 in the example above) and if it has previously recorded as many spikes as the length of the subgroup and if during the current time step there are spikes that should not be recorded because they are not in that subgroup, then no filtering takes place even though it should and we'll get an index error.

The other codegen targets do the filtering quite differently, so they are not affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment