Page 1 of 1

### How does a section recognize a mechanism's current?

Posted: Fri Jul 12, 2019 5:00 pm
Hello. I am quite new to NEURON. I am trying to implement a custom mechanism (mod file) that outputs a synaptic current. I noticed that when trying to record the current at the section that contains the custom mechanism, the current from the mechanism is not present. To illustrate, here is some Python code that successfully captures a section's current with an inserted Exp2Syn mechanism.

Code: Select all

``````from neuron import h
import matplotlib.pyplot as plt

h.load_file("stdrun.hoc")

s0 = h.Section()
s0.insert('pas')

syn = h.Exp2Syn(s0(0.5)) # define as exponential synapse

h.tstop = 10000
h.dt = .1
h.steps_per_ms = 1.0/h.dt

evec = h.Vector()

# time of events
evec.append(200)
evec.append(1200)
evec.append(7000)

input_vector = h.VecStim()
input_vector.play(evec)

nc = h.NetCon(input_vector,syn)
nc.weight = 1

i = h.Vector()
i.record(syn._ref_i) # record the current through the synapse

secI = h.Vector()
secI.record(s0(0.5)._ref_i_pas) # record the current at the section

h.run()

# plot currents
plt.figure(1)
plt.plot(i)

plt.figure(2)
plt.plot(secI)
plt.show()
``````

When using Exp2Syn, you can directly see the effects of the synaptic current on the recording of the current of the section. When looking at the mod file for Exp2Syn, I thought the only significant part that would have the section "recognize" the current is to declare it as a NONSPECIFIC_CURRENT. So I tried making a very simple mod file to see if the current would be "seen" by the section:

Code: Select all

``````NEURON {
POINT_PROCESS netcontest
RANGE i
NONSPECIFIC_CURRENT i
}

UNITS {
(nA) = (nanoamp)
}

ASSIGNED {
i (nA)
}

INITIAL {
i = -70
}

NET_RECEIVE(weight (uS)) {
i = i + 10
}
``````
The mod file simply initiates the current to -70nA and steps it up by 10nA every time an event is received. If you rerun the python code I copied but replace it to use my simple mod file ( syn = h.netcontest(s0(0.5) ) the plotted section current does not reflect the activity of the custom mechanism.

My main question is how do I get the section to "see" the current of my custom mechanism? Am I missing something crucial in the mod file? Thank you for any assistance!

### Re: How does a section recognize a mechanism's current?

Posted: Mon Jul 15, 2019 12:16 pm
I am quite new to NEURON. I am trying to implement a custom mechanism (mod file) that outputs a synaptic current.
Are you quite sure that is necessary? There isn't something that already exists which, except for parameter values, would do exactly what you want? If there isn't, then have you tried looking for something that exists and is close to what you want to implement?
When looking at the mod file for Exp2Syn, I thought the only significant part that would have the section "recognize" the current is to declare it as a NONSPECIFIC_CURRENT.
"Programming by example" is a useful strategy, but as you found out, there are still many pitfalls. NMODL is very different from C, hoc, or Python. Have you taken a look at the enhanced preprint of
Hines, M.L. and Carnevale, N.T. Expanding NEURON's Repertoire of Mechanisms with NMODL. Neural Computation 12:995-1007, 2000
which is available as
https://neuron.yale.edu/neuron/static/p ... odl400.pdf
(also note the errata https://neuron.yale.edu/neuron/static/p ... rrata.html)
?
how do I get the section to "see" the current of my custom mechanism?
Use a custom mechanism that actually generates a current. Your NMODL code needs a BREAKPOINT block that assigns a value to the current variable.

What is to be done to your NMODL file to fix that and some other problems you haven't bumped into yet?

If you have a mechanism that is supposed to generate a current, the mechanism must have a BREAKPOINT block which contains a statement that assigns a value to that current. Absent such a statement, your mechanism won't affect the model's charge balance equations.

Code: Select all

``````BREAKPOINT {
i = amp
}``````
where amp is the name of an intermediate variable whose value will be set to some initial value upon model initialization, and incremented by some amount every time the mechanism receives an event.
Of course, amp must be declared in the ASSIGNED block

Code: Select all

``````ASSIGNED {
amp (nA)
i (nA)
}``````
Instead of hard wiring magic numbers like -70 and 10 (which happen to be very poor choices, by the way) into your code, you'll want to parameterize your model. amp0 and delta are nice and mnemonic.

Code: Select all

``````PARAMETER {
amp0 = 0 (nA)
delta = -0.01 (nA) : < 0 depolarizes. after all, this is a synaptic mechanism, not an electrode
}``````
A synaptic mechanism is likely to be used more than once in a model, and you might want each instance to have its own parameters, so declare them to be RANGE in the NEURON block.

Code: Select all

``````NEURON {
POINT_PROCESS netcontest
RANGE amp0, delta, i
NONSPECIFIC_CURRENT i
}
``````
To ensure that amp is reset to its initial value when the model is initialized, the NMODL file's INITIAL block should be changed to

Code: Select all

``````INITIAL {
amp = amp0
}``````
and to use delta to increment amp when an event arrives, the NET_RECEIVE block should become

Code: Select all

``````NET_RECEIVE(weight (uS)) {
amp = amp + delta
}``````
What remains to be done? If you use modlunit to check the NMODL file for consistency of units, modlunit will complain that it doesn't know about uS, so the UNITS block should be

Code: Select all

``````UNITS {
(nA) = (nanoamp)
(uS) = (microsiemens)
}``````

### Re: How does a section recognize a mechanism's current?

Posted: Wed Jul 17, 2019 2:51 pm
Thank you for the reply Ted, appreciate it! Will keep all the tips you suggested in mind moving forward and will have a look at the NEURON guide as well. The use of the BREAKPOINT block to affect charge balance is exactly what I needed.