Recording synaptic currents

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Recording synaptic currents

Post by alexandrapierri »

Dear NEURON/Python community

I have a population model and I want to record somatic synaptic currents and somatic voltage from a given excitatory cell.
I have my GABAa mod file and GABA synapses are inserted in my excitatory cell model.
Using the code below I can successfully record the somatic voltage but not synaptic currents.
The vector recording the currents (i_vecs) is empty as it doesn't point to anything in my excitatory cell model.
Error: "_ref_i was not made to point to anything at the pyramidacell.hoc"

What is the correct syntax to record synaptic currents (particularly GABAa)? Any documentation I've read shows that "i_vec.record(target.soma(0.5)._ref_i)" should be the right syntax, but I probably need to change the pointer "..._ref_i" into something more specific. Do I need to set a pointer for this? Any help with debugging this would be greatly appreciated.

thank you,
Alex

Code: Select all

import time

h.load_file("stdrun.hoc")

def record_population_voltages(c,pop_id):
    v_vecs = []
    for i in range(len(c.neurons[pop_id])):
        v_vec = h.Vector()
        try:
            v_vec.record(c.neurons[pop_id][i].axon(0.5)._ref_v)
        except:
            v_vec.record(c.neurons[pop_id][i].soma(0.5)._ref_v)
        v_vecs.append(v_vec)
    return v_vecs

exc_v_vecs     = record_population_voltages(circuit, 0)
pvbc_v_vecs    = record_population_voltages(circuit, 1)

def get_population_currents(c,pop_id):
    i_vecs = []
    
    #for target in range(len(c.neurons[pop_id])):
    for i in range(len(c.neurons[pop_id])):    
        i_vec = h.Vector()
        try: 
            target = c.neurons[pop_id][i]
            i_vec.record(target.soma(0.5)._ref_i)
        except:
            target = c.neurons[pop_id][i]
            i_vec.record(target.soma(0.5)._ref_i)
        i_vecs.append(i_vec)
    return i_vecs

exc_i_vecs = record_population_currents(circuit, 0)
pvbc_i_vecs = record_population_currents(circuit, 1)


print('starting simulation..')
    
t_vec = h.Vector()  # Time stamp vector
t_vec.record(h._ref_t)

tic = time.time()

h.dt = 0.5
h.tstop =  time_for_single
h.finitialize(-65.0)
h.fadvance()
h.continuerun(h.tstop)

elapsed = time.time() - tic
print('that took %0.3f seconds' % elapsed)
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Recording synaptic currents

Post by ted »

The key to measuring something is to know what it is called.

Actually you've got it half right. Your syntax is correct. The problem is, there's no such variable as
target.soma(0.5)._ref_i
that is, for any given segment seg, seg.i does not exist.

I know nothing about your synaptic mechanisms, so I don't know the name of the variable(s) that they use for the current(s) they generate. Examine their NMODL source code to see what the NEURON block says the currents' names are. They'll be declared in USEION statements or NONSPECIFIC_CURRENT statements. FWIW, most of the time I'd probably use plain old ExpSyn and Exp2Syn to represent AMPAergic and GABA-A synaptic transmission.

All this is beside the point. You really don't want to record the transmembrane current of any segment, because it would combine both ionic and capacitive currents, AND you'd have no way to tell how much of that was current generated by synapses attached to a given segment or how much resulted from axial current spreading from adjacent segments. Nor do you want to record the currents generated by individual instances of any synaptic mechanism, because that would make your code needlessly complex (how would you handle a situation in which each segment could have any number of instances of any particular synaptic mechanism?).

There's a much smarter way to do this. Assuming that your AMPAergic (or GABAergic) mechanism is linear (so superposition holds), you will only need to attach a single instance of it to whatever segment is supposed to have any number of AMPAergic (or GABAergic) synapses attached. Then you just capture the time course of the current generated by that single instance.

If you're dealing with some mechanism Foo that isn't linear, and some segment is supposed to have two or more instances of type Foo attached, then revise the NMODL code for Foo so that, instead of generating a nonspecific current or a current attributed to one of the usual ionic species, it WRITEs a current that is carried by fictional ionic species with a distinctive name, e.g.
USEION xampa READ exampa WRITE ixampa VALENCE 1
and make its BREAKPOINT blocks calculate the appropriate current e.g.

BREAKPOINT {
SOLVE . . .
ixampa = g*(v - exampa)
}

Then any section bar to which at least one instance of Foo is attached will automatically have a membrane current component called ixampa that is visible to hoc and Python. The value of ixampa in any segment seg of bar will be in units of mA/cm2 and will equal

(100)*(SUMMA ixampa)/(area of seg in um2)

where SUMMA ixampa is the sum of the currents generated by all instances of Foo that are attached to seg, and the scale factor (100) converts nA/um2 to mA/cm2. So just record seg's ixampa to some vector vec, then after a simulation divide each element in vec by 100, and vec will then contain the time course of the total synaptic current in nA generated by all instances of Foo that are attached to bar.
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: Recording synaptic currents

Post by alexandrapierri »

thank you Ted

I am working on this now. I had a question for you. My GABAa mod file has this nonspecific "i" current which is defined at the BREAKPOINT as "i = g*(v - Erev)". Why can I not record this "i" current using the pointer ...._ref_i?

Code: Select all

NEURON {
	POINT_PROCESS GABAa
	POINTER pre
	RANGE C, R, R0, R1, g, gmax, lastrelease
	NONSPECIFIC_CURRENT i
	GLOBAL Cmax, Cdur, Alpha, Beta, Erev, Prethresh, Deadtime, Rinf, Rtau
}

BREAKPOINT {
	SOLVE release
	g = gmax * R
	i = g*(v - Erev)
}
thank you
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Recording synaptic currents

Post by ted »

Suppose foo is an instance of the GABAa class that was created by the statement

foo = h.GABAa(dend3(0.5)) # attaches an instance of GABAa to the segment of dend3 that contains location 0.5

Then foo.i is the Python name for the current generated by foo. If you want to record the time course of foo.i to a vector, just do something like this

ivec = h.Vector()
ivec.record(foo._ref_i)

Next example: suppose you have created an instance of a cell class like this

cell = MyPyr()

Also suppose that the MyPyr class has a section called dend that has the pas mechanism. Here's how to record the time course of pas.i in the segment of dend that contains location 0.5 (the midpoint of dend):

ivec.record(cell.dend(0.5)._ref_i_pas)

I believe there's a syntax that allows one to refer to the current as pas.i, but I can't think of it at the moment.
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: Recording synaptic currents

Post by alexandrapierri »

thank you Ted

Suppose the MyPyr class contains GABA synapses already (as part of the class definitions).
I would like to record from those existing GABA synapses (somatic area).

Naive question: Is foo = h.GABAa(dend3(0.5)) attaching a new GABA synapse on my MyPyr, aside from the ones attached already within the MyPyr class, or is it only creating an instance of the existing synapses?

Also what if the CABAa is defined in a mod file that is read by the MyPyr class, and not in a Python class.
Would in that case the syntax be the same? I would think that if the GABAa is defined in a mod file I would then need to do something like:
ivec.record(cell.dend(0.5)._ref_i_ixgaba), where ixgaba is defined within the GABAa mod file, as discussed in earlier threads?

Thank you,
Alexandra
Post Reply