Hi everyone,
I am building a network using Dendrify and I have a question about how to update the weight of the synapse after adding it to a specific compartment.
Description of problem
My problem (or rather, observation) is that setting the weight parameter using the ‘parameters’ dictionary of the compartment does not seem to change the weight itself when I later print the parameter. See an example below.
Minimal code to reproduce problem
import brian2 as b
import dendrify as d
from brian2.units import *
from dendrify import Soma, Dendrite, PointNeuronModel
b.prefs.codegen.target = 'numpy'
soma = Soma('soma', length=20*um, diameter=20*um,
cm=1*uF/(cm**2), gl=40*uS/(cm**2),
r_axial=150*ohm*cm, v_rest=-70*mV)
dend = Dendrite('dend', length=20*um, diameter=20*um,
cm=1*uF/(cm**2), gl=40*uS/(cm**2),
r_axial=150*ohm*cm, v_rest=-70*mV)
dend.synapse('AMPA', tag='L23E', g=1*nS, t_decay=2*ms)
print('Before modification:', dend)
# Trying to update the value of the synaptic weight parameter: w_AMPA_L23E_dend
dend.parameters['w_AMPA_L23E_dend'] = 20
print('After modification:', dend)
The print statements will show that the value of the parameter ‘w_AMPA_L23E_dend’ is still 1.0 after the attempt to change it.
What you have already tried
What I tried to do is to change the model itself after defining it with the two compartments (soma, send). Then the parameter seems to change in the dictionary. So, I added this code after the snippet above:
graph = [(soma, dend, 12*nS)]
model = NeuronModel(graph, scale_factor=5, spine_factor=1)
model.add_params({'w_AMPA_L23E_dend': 20})
print('After changing the model itself:', model)
Actual output (if relevant)
The last snippet will print this information:
After changing the model itself:
OBJECT
------
<class 'dendrify.neuronmodel.NeuronModel'>
EQUATIONS
---------
dV_soma/dt = (gL_soma * (EL_soma-V_soma) + I_soma) / C_soma :volt
I_soma = I_ext_soma + I_dend_soma :amp
I_ext_soma :amp
I_dend_soma = (V_dend-V_soma) * g_dend_soma :amp
dV_dend/dt = (gL_dend * (EL_dend-V_dend) + I_dend) / C_dend :volt
I_dend = I_ext_dend + I_soma_dend + I_AMPA_L23E_dend :amp
I_ext_dend :amp
I_AMPA_L23E_dend = g_AMPA_L23E_dend * (E_AMPA-V_dend) * s_AMPA_L23E_dend * w_AMPA_L23E_dend :amp
ds_AMPA_L23E_dend/dt = -s_AMPA_L23E_dend / t_AMPA_decay_L23E_dend :1
I_soma_dend = (V_soma-V_dend) * g_soma_dend :amp
PARAMETERS
----------
{'Alpha_NMDA': 0.062,
'Beta_NMDA': 3.57,
'C_dend': 62.83185307 * pfarad,
'C_soma': 62.83185307 * pfarad,
'EL_dend': -70. * mvolt,
'EL_soma': -70. * mvolt,
'E_AMPA': 0. * volt,
'E_Ca': 136. * mvolt,
'E_GABA': -80. * mvolt,
'E_K': -89. * mvolt,
'E_NMDA': 0. * volt,
'E_Na': 70. * mvolt,
'Gamma_NMDA': 0,
'Mg_con': 1.0,
'gL_dend': 2.51327412 * nsiemens,
'gL_soma': 2.51327412 * nsiemens,
'g_AMPA_L23E_dend': 1. * nsiemens,
'g_dend_soma': 12. * nsiemens,
'g_soma_dend': 12. * nsiemens,
't_AMPA_decay_L23E_dend': 2. * msecond,
'w_AMPA_L23E_dend': 20}
EVENTS
------
[]
EVENT CONDITIONS
----------------
{}
This seems to have changed the parameter, but I was wondering if this is the way that Dendrify is intended to be used when changing synaptic weights? Will this way of changing the weights work as expected in a more complex script, keeping the value that I set myself during the simulations? Would this mean that every time I need to change the synaptic weight parameter, I would need to update the model and recreate the neuron group using it? Or upon updating the model, will the neuron group using that model automatically update that value in the simulation?
Or perhaps there is a different way to do it at the moment when the synapse is defined for a compartment (i.e. on the line ‘dend.synapse’). I am asking this question because I am working on a model with many different populations which connect to each other, hence it would be very useful to understand the optimal method to update the synaptic weights.
Thank you in advance.
Best,
Rares