There is a slight inconsistency regarding how mechanisms in terminal nodes are handled from hoc and Python. Consider the following hoc code:
Code: Select all
create s
s {
nseg = 1
insert pas
for (x) print x, g_pas(x)
}
This will print:
Obviously, calling g_pas(0) or g_pas(1) will return its value at the adjacent internal node. Trying to do the same from python:
Code: Select all
import neuron
if __name__ == "__main__":
h = neuron.hoc.HocObject()
s = h.Section()
s.nseg = 1
s.insert("pas")
for seg in s:
print seg.x, seg.pas.g
results in:
Code: Select all
Traceback (most recent call last):
File "test_term.py", line 8, in <module>
print seg.x, seg.pas.g
NameError: pas, the mechanism does not exist at PySec_b7d3c050(0)
I would have to explicitly do:
Code: Select all
for seg in s:
if not(seg.x == 0 or seg.x == 1): print seg.x, seg.pas.g
to avoid this. I understand that it doesn't make any sense to
assign a value to a range variable at a terminal node, since no mechanisms are attached to it, but it would be nice if one could
print range variables using the "for seg in section" syntax without checking for terminal nodes. For instance, would it be possible to print out the value of the range variable at the adjacent internal node when seg.x == 0 or seg.x == 1, as it is done from hoc? One could still emit an error message when trying to assign to range vars at terminal nodes.
Best
Christoph