Problem Constructing Short-Term Potentiation

I am working with a network of PYR and PVN neurons. For the PYR neurons, I have created two spike event-dependent variables: PYR.u is a unitless spike frequency adaptation variable, while PYR.f is a unitless spike-induced synaptic strength variable. When I run simulations over 4 sec with increasing applied current, I see the expected spike-induced increases in PYR.u, but not in PYR.f (image attached). There are no error messages. I must have a logic error in my code. Suggestions? I apologize for amount of code included. Thx

#Some PYR eqs
eqs_pyr = “”"
Iext : amp
Isyn_e_pyr = g_e*(v-Ee)s_sum_e_pyr : amp
s_sum_e_pyr : 1
d_pyr : siemens
k = (int(v<vt) * klow) + (int(v>=vt) * khigh) : siemens/volt
du/dt = a
(-u) : 1
df/dt = b*(-f) : 1
dv/dt = (k*(v-vr)(v-vt)+Iext-Isyn_e_pyr-ud_pyr*(v-va))/C_pyr : volt
“”"
reset = ‘’’
u += 1
f += 0.5
v = vc
‘’’

#PYR neuron group
PYR = NeuronGroup(N1, model=eqs_pyr, reset=reset, threshold=‘v >= vpeak’, method = ‘euler’)
PYR.d_pyr = 0.000000001 * siemens
print(PYR)

#Excitatory synapse model
S_pyr_pyr=Synapses(PYR,PYR,
model=“”"
f_syn=f : 1
ds0/dt=-(s0-s_inf)/(tau_s) :1 (clock-driven)
ds1/dt=-s1Beta :1 (clock-driven)
s_tot=clip(s0,0,s1)
(1 + f_syn) :1
s_sum_e_pyr_post = s_tot : 1 (summed)
“”“,
on_pre=”“”
s0=s1
s1=(s_inf*(1-exp(-0.001second/tau_s))+s1exp(-0.001second/tau_s))exp(0.001Betasecond)
delay=0.001*second
“”",
method = ‘exact’)

#Connectivity
S_pyr_pyr.connect(condition=‘rand() < 0.02’)
print(“Source neuron indices (i):”, S_pyr_pyr.i[:])
print(“Target neuron indices (j):”, S_pyr_pyr.j[:])
print(“Connections (i, j):”)

set initial conditions

PYR.u=0
PYR.f=0

What you have aready tried

Correction: there was a typographical error in the eq. for dv/dt
Should be:

dv/dt = (k*(v-vr)(v-vt)+Iext-Isyn_e_pyr-u d_pyr*(v-va))/C_pyr : volt

My apologies again. When copy/pasting code into this window, some bold-faced text was corrupted. Here is the code again without typographical error:

#Some cell and synaptic parameters
C_pyr = 115 * pF
vr = -52.0 * mV # resting potential
vpeak = 30.0 * mV # spike peak
va = -65 * mV # adaptive current reversal potential
vt = -49.0 * mV # spike threshold
va = -65 * mV # adaptive current reversal potential
vt = -49.0 * mV # spike threshold
vc = -53.0 * mV # postspike reset potential
N1 = 2000 # number of PYR neurons in network
klow = 0.1 * nS/mV
khigh = 3.3  * nS/mV
a = 0.008 /ms # decay rate of adaptive conductance
b = 0.002 /ms # decay rate of STP
g_e = 0.7 * nS # EPSC conductance
Ee=-15 *mV # EPSC reversal potential
alpha = 2000 /second
Beta = 333.33 /second
s_inf =alpha/(alpha+Beta)
tau_s =1/(alpha+Beta)

#Some PYR eqs
eqs_pyr = """
Iext  : amp
Isyn_e_pyr = g_e*(v-Ee)*s_sum_e_pyr : amp
s_sum_e_pyr : 1
d_pyr : siemens
k = (int(v<vt) * klow) + (int(v>=vt) * khigh) : siemens/volt
du/dt = a*(-u) : 1
df/dt = b*(-f) : 1
dv/dt = (k*(v-vr)*(v-vt)+Iext-Isyn_e_pyr-u*d_pyr*(v-va))/C_pyr : volt
"""
reset = '''
u += 1
f += 0.5
v = vc
'''
#PYR neuron group
PYR = NeuronGroup(N1, model=eqs_pyr, reset=reset, threshold='v >= vpeak', method = 'euler')
PYR.d_pyr = 0.000000001 * siemens
print(PYR)

#Excitatory synapse model
S_pyr_pyr=Synapses(PYR,PYR,
       model="""
              f_syn=f : 1
              ds0/dt=-(s0-s_inf)/(tau_s) :1 (clock-driven)
              ds1/dt=-s1*Beta :1 (clock-driven)
              s_tot=clip(s0,0,s1)*(1 + f_syn) :1
              s_sum_e_pyr_post = s_tot : 1 (summed)
       """,
       on_pre="""
              s0=s1 
              s1=(s_inf*(1-exp(-0.001*second/tau_s))+s1*exp(-0.001*second/tau_s))*exp(0.001*Beta*second)
              delay=0.001*second
       """, 
          method = 'exact')

#Connectivity
S_pyr_pyr.connect(condition='rand() < 0.02')
print("Source neuron indices (i):", S_pyr_pyr.i[:])
print("Target neuron indices (j):", S_pyr_pyr.j[:])
print("Connections (i, j):")

# set initial conditions
PYR.u=0
PYR.f=0

Following up on my earlier query, my code is errant in two ways. First, as stated before, a spike is inducing a step increase in adaptation factor u, but is failing to induce a step in the STP factor f. Secondly, my synapse code is flawed because, as written, the synaptic factor f would correspond to prior spiking of the postsynaptic target neuron, not the source neuron.

Hi @MitchG_HunterCollege. To avoid copy&pasting/formatting issues, please make sure to include your code in triple backticks or use the “Preformatted text” option from the toolbar (I edited your post accordingly):

```
# Python code
print("Hello!")
```

Regarding the variable f, it seems to update fine – could you please share the code you used to record and plot it? If I add the following to your code from above:

mon = StateMonitor(PYR, ["f", "u"], record=True)
run(4*second, report='text')

fig, axs = plt.subplots(1, 2)
axs[0].plot(mon.t/ms, mon.u[:5].T)
axs[1].plot(mon.t/ms, mon.f[:5].T)
plt.show()

I get this plot, showing that f gets updated as expected (I think):

In the synaptic equations, you can to refer to either f_pre or f_post, for the respective pre-/post-synaptic variable. As a shorthand, you are also allowed to write f instead of f_post. Note that you do not need to use f_syn = f_pre – the other equations can directly refer to f_pre.

Oh, one more thing: I saw that you used delay = ... as part of your on_pre statement. Note that changes to the delay variable are not taken into account while a simulation is running, they only affect subsequent runs. See Delay Plasticity Only Working in One Direction - #4 by mstimberg for a related discussion.

Hello, Marcel. Thank you for your input. I have tried using the term f_pre in the excitatory synapse model. While the simulations run without error abort, I am still not seeing the factor f increase in neurons as they spike. I don’t think we can resolve this issue by our posting minimal codes on this discussion thread. Would you allow me to provide you my entire code sent to your email? If you can then find my essential syntax errors, you could share these on the discussion thread. Thanks, Mitch

Hi Mitch, I replied to your email!