Vector play issue

Moderator: wwlytton

Post Reply
aliaped
Posts: 13
Joined: Sun Aug 09, 2020 12:10 pm

Vector play issue

Post by aliaped »

Hi there,

Many thanks for the work you put into this forum.

I am attempting to change synaptic conductance over the course of a train at specific time steps, and am using the vector play method as described in the two links in the comments below. Unfortunately, the vector is clearly not playing into the conductance value, and conductance remains at 0 over the course of the train. I have checked that when a single conductance value replaces the vector, the code works as expected, namely, a train of synaptic events of that single conductance is delivered at the onset time.

I suspect I am incorrectly using either the NetCon, NetStim, and/or Vector.play(). Would you be able to look at the code and identify my technical error? I have not provided model specification at this time for confidentiality reasons, but would be happy to do so privately if necessary.

Thank you again.

Code: Select all


## uses Vector.play() method from https://www.neuron.yale.edu/phpBB/viewtopic.php?t=163
## and https://nrn.readthedocs.io/en/latest/python/programming/math/vector.html#Vector.play

tchange = np.array([111, 116, 133, 151, 201])
e_sschange = np.array([0.0065, 0.00325, 0.0015, 0.00075, 0.00015])

tvec_chg = h.Vector().from_python(tchange)
evec_chg = h.Vector().from_python(e_sschange)




expSyn = h.Exp2Syn(0.5, h.soma)
expSyn.e = 0
expSyn.tau2 = .8
expSyn.tau1 = .2

ns = h.NetStim()
ns.number = 8
ns.interval = 1 * ms
ns.noise = 0
ns.start = 50 * ms

netCon = h.NetCon(ns, expSyn)
netCon.delay = 112


evec_chg.play(expSyn, netCon.weight[0], tvec_chg, 1)
v = h.Vector().record(h.soma(0.5)._ref_v)# Membrane potential vector
t = h.Vector().record(h._ref_t)# Time stamp vector
h.finitialize(-70 * mV)
h.continuerun(500 * ms)
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Vector play issue

Post by ted »

Interesting problem. You're very close to getting it right. No need to disclose your model cell; it's easy enough to make an isolated soma and use that for interactive software development.

Code: Select all

from neuron import h, gui
# the built-in GUI is very convenient for development and debugging
soma = h.Section(name='soma')
soma.diam = 10
soma.L = 10/h.PI # surface area 100 um2
soma.insert('pas') # resting potential will be -70 mV
syn = h.ExpSyn(soma(0.5))
syn.tau = 3 # a fast NMDAergic synapse
To drive the synapse I'll use a NetStim, just like you did, but with parameters that are convenient for short runs and quick viewing of simulation results

Code: Select all

pre = h.NetStim() # presynaptic spike source
nc = h.NetCon(pre, syn)
# nc.weight[0] = 1e-4 # uS
nc.weight[0] = 0 # uS
### network architecture is complete
### now specify activity of spontaneously active cells
pre.start = 5
pre.interval = 5
pre.number = 1e9
Now I load the session file that recreates a RunControl and graphs that show soma.v(0.5) and synaptic conductance vs. time. Also a statement that specifies the membrane potential to which all sections will be initialized when I click on the RunControl's Init & Run button (-70 mV so the cell starts at its resting potential).

Code: Select all

### instrumentation and simulation flow control
h.load_file('rig.ses') # RunControl, soma.v vs. t, ExpSyn.g vs. t
h.v_init = -70 # potential to which all sections are initialized
Finally the Vector.play stuff

Code: Select all

# use Vector.play to force nc.weight[0] to change at specific times
tvec = h.Vector([0, 10, 35, 60]) # so every run starts with weight[0]==0 
wvec = h.Vector([0, 1e-4, 0.5e-4, 0.2e-4])
wvec.play(nc._ref_weight[0], tvec)
where I'm taking advantage of pythonic syntax to specify the values stored in the time and weight vectors. Be sure to read the Programmer's Reference python documentation of NEURON's Vector class, and think about the interoperability between NEURON's Vectors and numpy's arrays.

Save this to a file called changeweight.py, then execute it
python3 -i changeweight.py
and finally click on Init & Run (which is equivalent to executing h.run()). Looks like the code works. BTW, note that, for each value of nc.weight[0], there are enough repetitions for soma.v(0.5) and ExpSyn.g to settle down.

I haven't bothered to set up Vector.record to capture the course of soma.v(0.5) and t during a simulation.
aliaped
Posts: 13
Joined: Sun Aug 09, 2020 12:10 pm

Re: Vector play issue

Post by aliaped »

Ted, this was so excellent. Thank you.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Vector play issue

Post by ted »

You're welcome.

A few things I forgot to say--

To see the effects of changing synaptic weight at the times specified in tvec require that h.tstop be set to at least 80 ms (100 would be fine).

When running simulations of a model that is not spontaneously active, i.e. has a stable resting potential, it is generally a good idea to initialize the model to its steady state, and delay the onset of perturbations such as stimuli (current clamps, synaptic activations etc.) until h.t is at least 5 or 10 ms. This allows verification that state variables are indeed properly initialized. If the model _is_ spontaneously active, it is best to defer perturbations until the simulation has run long enough for activity to stabilize. Likewise, figures should genearlly include a bit of "baseline activity" before the start of any perturbation. These recommendations will seem like standard practice to modelers who have a background in experimental biology, but experience has shown them to be new ideas to many who come from mathematics or the physical sciences.
Post Reply