I’m relatively new to working with Brian2 and spiking neural networks, so please forgive me if this question is a bit basic.
I am working on a simulation of a spiking neural network using Brian2. Currently, I have defined my synapses with a specific STDP rule, and they are connected using the following code:
STDP = Synapses(PC, PC,
"""
w : 1
dA_presyn/dt = -A_presyn/taup : 1 (event-driven)
dA_postsyn/dt = -A_postsyn/taum : 1 (event-driven)
""",
on_pre="""
A_presyn += Ap
w = clip(w + A_postsyn, 0, wmax)
""",
on_post="""
A_postsyn += Am
w = clip(w + A_presyn, 0, wmax)
""")
STDP.connect(condition="i!=j", p=connection_prob_PC)
STDP.w = w_init
What I would like to do now is apply different STDP parameters to a random subset of these synapses while keeping the overall connectivity the same.
Has anyone done something similar or have any suggestions on how to implement this? Any advice or code snippets would be greatly appreciated!
Hi @Plasc. With STEP parameters, you mean things like the time constants taup and taum or other constants appearing in the equations? The way it is currently written, these constants are the same for all synapses. If instead you declare them as parameters in the equations, they can be different for each synapse, in the same way that w is right now (it won’t change much, but you could add the (constant) flag to make clear that the parameter is not going to change during the simulation, in contrast to w which is). Then, you could give them some default value and set different values for a random subset. You can index a parameter with a string expression or with one-dimensional indices into the flat array storing the values for all synapses. Depending on how you want to define a random subset, you’d then do something like
TDP = Synapses(PC, PC,
"""
w : 1
taup : second (constant) # now a parameter
...""", ...)
STDP.connect(condition="i!=j", p=connection_prob_PC)
STDP.w = w_init
STDP.taup = default_taup
# change value for ~1% of synapses:
STDP.taup["rand()<0.01"] = other_value
# change value for 10 synapses:
STDP.taup[np.random.choice(len(STDP), size=10, replace=False)] = other_value
Hope that helps (and I did not misunderstand what you want to do)!