How to enable synapses to access variables of neurons in Brian2

Hello everyone,
I am currently attempting to replicate NALSM from the paper “Increasing Liquid State Machine Performance with Edge-of-Chaos Dynamics Organized by Astrocyte-modulated Plasticity.” The authors have proposed a STDP method with adaptive depression learning rate to train LSM (as shown in formula 7 in the figure) and have implemented the model in the Tensorflow framework.


In simple terms, the global depression learning rate A_ is controlled by the number of input spikes and the number of liquid spikes. Therefore, I attempted to set up a virtual population of neurons (astro) connected to the input and liquid to calculate A_ (as shown in the figure below).

However, how can I make the synapses access/link to A_ within astro? Does Brian2 support such an implementation? I have attached my complete code below. Thank you very much for your suggestions.

from brian2 import (
	NeuronGroup,
	Synapses,
	Network,
	SpikeMonitor,
	StateMonitor,
	PoissonGroup
)
from brian2 import ms, Hz
from brian2 import defaultclock, collect
import matplotlib.pyplot as plt


defaultclock.dt = 1. * ms
tau = 10. * ms

# input and liquid neurons
neuron_inp = PoissonGroup(1, 400 * Hz)
neuron_liq = PoissonGroup(1, 400 * Hz)
# syn with STDP
eqs_synapse = '''
dTpre / dt = -Tpre / tau    : 1 (event-driven)
dTpost / dt = -Tpost / tau  : 1 (event-driven)
w      : 1
Aastro : 1
'''
eqs_synapse_on_pre = '''
Tpre += 0.1
w -= Tpost * Aastro
'''
eqs_synapse_on_post = '''
Tpost += 0.1
w += Tpre * 0.15
'''
syns = Synapses(neuron_inp, neuron_liq, eqs_synapse,
				on_pre=eqs_synapse_on_pre, on_post=eqs_synapse_on_post)
syns.connect()
syns.w = 0.5
st_syns = StateMonitor(syns, ['Tpre', 'Tpost', 'w', 'Aastro'], record=True)


eqs_astro = '''
dAastro / dt = (-Aastro + 0.15) / (100. * ms) : 1
'''
G = NeuronGroup(1, eqs_astro, method ='euler')
G.Aastro = 0.15
# syns.Aastro = linked_var(G, 'Aastro')  # link
syn_inp = Synapses(neuron_inp, G, '', on_pre='Aastro -= 0.01')
syn_inp.connect()
syn_liq = Synapses(neuron_liq, G, '', on_pre='Aastro += 0.01')
syn_liq.connect()
sp_inp = SpikeMonitor(neuron_inp, record=True)
sp_liq = SpikeMonitor(neuron_liq, record=True)
st_asto = StateMonitor(G, ['Aastro'], record=True)

net = Network(collect())
net.run(21 * ms)

fig, axs = plt.subplots(4, 2, figsize=(7, 5), sharex='all')
axs[0, 0].plot(sp_inp.t / ms, sp_inp.i, '.k', label='input spikes')
axs[0, 0].legend()
axs[1, 0].plot(sp_liq.t / ms, sp_liq.i, '.k', label='liquid spikes')
axs[1, 0].legend()
axs[3, 0].plot(st_asto.t / ms, st_asto.Aastro[0], label='A_ from astro')
axs[3, 0].legend()
axs[0, 1].plot(st_syns.t / ms, st_syns.Tpre[0], label='Tpre')
axs[0, 1].legend()
axs[1, 1].plot(st_syns.t / ms, st_syns.Tpost[0], label='Tpost')
axs[1, 1].legend()
axs[2, 1].plot(st_syns.t / ms, st_syns.w[0], label='w')
axs[2, 1].legend()
axs[3, 1].plot(st_syns.t / ms, st_syns.Aastro[0], label='A_ from syn')
axs[3, 1].legend()
axs[3, 1].set(xlim=[-0.5, 20.5])
plt.tight_layout()
plt.show()

Hi @Luka. This is indeed possible in Brian, we enabled this type of synaptic modulation when we wrote our book chapter on astrocyte modeling with Brian: https://doi.org/10.1101/198366 The example codes from this chapter might be useful: Examples — Brian 2 2.8.0.4 documentation

In short, the idea is that you can have a Synapses that target another Synapses – in your example, the astro group can have a Synapses that targets the synapses with STDP. In your code, you’d add:

syn_astro_syn = Synapses(G, syns, "Aastro_post = Aastro_pre : 1 (summed)")
syn_astro_syn.connect()

In your case, this mechanism is a bit more “powerful” than needed – it allows you to have several units in the group G, and connecting subsets of them to each synapse (the summed means that it will sum up the pre-synaptic contributions). For a single, global value, the linked mechanism would indeed be simpler and more efficient. It cannot be used in Synapses right now, but we actually implemented this very feature recently. The next Brian release (towards the end of April, I think) will include it, and then you will be able to mark the Aastro variable in your synapses as (linked) and link it to the Aastro variable in the other group. If you already want to try out this feature, you could install Brian’s development version as described in the documentation.

Hope that helps!

Thank you very much for your advice. It is very helpful to me. :grinning_cat_with_smiling_eyes:

1 Like