Mechanisms at terminal nodes in hoc vs. Python
Posted: Mon Aug 18, 2008 6:55 am
There is a slight inconsistency regarding how mechanisms in terminal nodes are handled from hoc and Python. Consider the following hoc code:
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:
results in:
I would have to explicitly do:
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
Code: Select all
create s
s {
nseg = 1
insert pas
for (x) print x, g_pas(x)
}
Code: Select all
0 0.001
0.5 0.001
1 0.001
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
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)
Code: Select all
for seg in s:
if not(seg.x == 0 or seg.x == 1): print seg.x, seg.pas.g
Best
Christoph