Dear Forum,
I would like to ask whether or not is possible to obtain the sum of the
synaptic current carried out by a certain receptor type.
For example, may I measure the total current carried out by several
GABAa, or NMDA receptors at the cell body?
Thanks in advance
Eleftheria
measuring total synaptic current
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
with code, all things are possible
Of course. Depending on what you need, the implementation is "extremely easy" ormay I measure the total current carried out by several
GABAa, or NMDA receptors at the cell body?
merely "straightforward."
The following assumes that "receptors" means "synaptic mechanisms."
If your synaptic mechanisms use the event delivery system (i.e. contain a
NET_RECEIVE block), all synapses that have the same equilibrium potential and
time course that are attached to the same node of a model cell can be represented
by a single point process. Somas are almost invariably "isopotential" so your somatic
synapses can all be attached to the same node and can thus be represented with only
one instance each of a gabaergic and an ampaergic mechanism (easily done with
Exp2Syn and ExpSyn, using appropriate e and taus).
If synapses are scattered over multiple nodes, you'll just have to keep track of them
when you set them up, and compute a "sum on the fly" as the simulation advances.
If you need more details about either of these strategies, just ask.
Re: measuring total synaptic current
Hi,
I want to measure the current from all the synapses I inserted into a neuron. How can I do that?
I tried to record from all synapses in Python by:
But when I run a simulation the program dies without giving an error.
Is there another way to do it. Maybe using a mod file which simplifys this?
I think you mentioned this already in your comment:
I want to measure the current from all the synapses I inserted into a neuron. How can I do that?
I tried to record from all synapses in Python by:
Code: Select all
vec_i = [0]*5
for i in np.arange(0,n_syn):
vec_i[i] = h.Vector()
vec_i[i].record(h.AMPAsyn[i]._ref_i)
Is there another way to do it. Maybe using a mod file which simplifys this?
I think you mentioned this already in your comment:
Can you elaborate on that or send some code?If synapses are scattered over multiple nodes, you'll just have to keep track of them
when you set them up, and compute a "sum on the fly" as the simulation advances.
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: measuring total synaptic current
Wow, everything old is new again. Or at least some old things are new. Thank you, Python!
If not, then maybe you can embed print statements at key points in your program, then execute it to see where the failure occurs, and use that information to refine your bug search.
"How do I keep track of the synapses as I set them up?"
Append each synaptic mechanism to a list when you create it. Then you can iterate over the contents of that list without having to keep track of "magic numbers" such as the number of synaptic mechanisms you created. Example:Now you can set up Vector record by doing thisNotice that I'm iterating over the elements of one list in order to populate another list. Also notice the absence of magic numbers--not a 3 nor its symbolic representation NSYN in sight. No need to remember either the number or what you called it.
"OK, how do I add them up after the simulation ends?"
There are many ways that would work.Is there another way to do it.
There is no mod file that would simplify this.Maybe using a mod file which simplifys this?
Not very helpful. In such cases, it is up to the programmer to locate the cause of the problem. Did you happen to develop your program in an incremental manner, starting with something simple that works, then proceeding iteratively, that is,when I run a simulation the program dies without giving an error.
Code: Select all
REPEAT
make a small change
test to make sure that the latest change works
UNTIL the whole program exists and works correctly
First, my opinion now is that I wouldn't bother adding up the currents during a run. I'd capture their time courses to hoc Vectors, and add those up after the simulation ends.I think you mentioned this already in your comment:Can you elaborate on that or send some code?If synapses are scattered over multiple nodes, you'll just have to keep track of them when you set them up, and compute a "sum on the fly" as the simulation advances.
"How do I keep track of the synapses as I set them up?"
Append each synaptic mechanism to a list when you create it. Then you can iterate over the contents of that list without having to keep track of "magic numbers" such as the number of synaptic mechanisms you created. Example:
Code: Select all
# create the instances of the synaptic mechanism
syns = [] # syns is a Python list
NSYN = 3
for ii in range(0,NSYN):
tmp = h.AlphaSynapse(0.5, sec = soma)
tmp.onset = 1.0+ii*0.4
tmp.gmax = 1e-3
tmp.e = 0
syns.append(tmp)
Code: Select all
ivecs = [] # for the individual synaptic currents
for abc in syns:
tmp = h.Vector()
tmp.record(abc._ref_i)
ivecs.append(tmp)
"OK, how do I add them up after the simulation ends?"
Code: Select all
def myrun():
h.run() # initializes and runs a simulation, and also updates NEURON's InterViews graphs
# you may prefer to call finitialize and continuerun directly
itotal = np.array(ivecs[0]) # get the first Vector into a numpy array
for ii in range(1,len(ivecs)):
itotal += ivecs[ii].as_numpy()
#
pyplot.plot(tvec.as_numpy(), itotal)
pyplot.show()
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: measuring total synaptic current
After a bit of reflection, I think this version of myrun() is preferable. Uses no indices, and treats all members of the list in exactly the same way.
Code: Select all
def myrun():
h.run()
itotal = np.zeros(len(tvec))
for abc in ivecs:
itotal += abc.as_numpy()
#
pyplot.plot(tvec.as_numpy(), itotal)
pyplot.show()
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: measuring total synaptic current
Here are the hoc equivalents for the Python code in my previous posts.
There's no way to avoid using an index variable to access individual items in a hoc List. Even so, it's better to use Lists rather than "arrays" of objrefs.
"How do I keep track of the synapses as I set them up?"
Append each synaptic mechanism to a list when you create it.
Code: Select all
objref syns, tmp
syns = new List()
for ii=0,NSYN-1 {
soma tmp = new AlphaSynapse(0.5)
tmp.onset = 1.0+ii*0.4
tmp.gmax = 1e-3
tmp.e = 0
syns.append(tmp)
}
objref tmp // so tmp can't be (mis)used to break anything
Now you can set up Vector record by doing this
Code: Select all
objref tvec, ivecs
tvec = new Vector()
tvec.record(&t)objref itotal, g
proc myrun() { local ii
run()
itotal = new Vector(tvec.size(),0)
for ii = 0,ivecs.count()-1 itotal.add(ivecs.o(ii))
g = new Graph()
itotal.plot(g, tvec)
g.exec_menu("View = plot")
}
ivecs = new List()
for ii = 0,syns.count()-1 {
tmp = new Vector()
tmp.record(&syns.o(ii).i)
ivecs.append(tmp)
}
objref tmp
"OK, how do I add them up after the simulation ends?"
Code: Select all
objref itotal, g
proc myrun() { local ii
run()
itotal = new Vector(tvec.size(),0)
for ii = 0,ivecs.count()-1 itotal.add(ivecs.o(ii))
g = new Graph()
itotal.plot(g, tvec)
g.exec_menu("View = plot")
}