Description of problem
My overall goal is to create a network of multiple neuron groups, each representing different neuron types within different brain regions. Therefore, I am creating custom functions inside which I am creating the neuron groups. However, I am having issues transferring variables through my own function into the NeuronGroup() function, and when I run the group I keep getting errors like '‘The identifier “tau” could not be resolved.’, even though I am sure I am defining the variables correctly.
Sometimes it will throw this error for one variable, and after re-starting everything it might throw the error for a different variable (it doesn’t seem to be consistent).
Is this something that can be done (or maybe should not be done and hence why it doesn’t work)?
Apologies if this has already been answered somewhere, I am fairly new to this!
Minimal code to reproduce problem
Simplified example
from brian2 import *
variables={'N':1, 'tau':10*ms, 'tau_2':10*ms}
def create_neuron_population(variables):
# Parameters
start_scope()
N = variables['N']
tau = variables['tau']
tau_2 = variables['tau_2']
eqs = '''
dv/dt = (1.1-v)/tau : 1
du/dt = (1.1 - u)/tau_2 : 1
'''
# Create a neuron group
G = NeuronGroup(N, eqs, threshold='v>1', reset='v=0', method='exact')
# Initial condition
G.v = 'rand()'
G.u = 0
return G
G = create_neuron_population(variables)
spike_monitor = SpikeMonitor(G)
state_monitor = StateMonitor(G, 'v', record=True)
run(100*ms)
What you have aready tried
Taking all the same functionality outside the custom function removes any errors.