Interesting. I'd use
Code: Select all
for seg in a:
print seg.x, seg.diam
just because it's easier to type--but it produces the same result you got.
The problem is not in how you are trying to access segment diameter. it's that the pt3d data have not yet been used to compute the segment diameters. However, if you simply execute
Code: Select all
for seg in a:
print seg.x, seg.diam
AFTER the
h("for (x) print x, diam(x)")
statement, you'll see that Python reports diameters that are based on the pt3d data.
What's happening: the pt3dadd statements really are setting up the pt3d data structures, but translation of those structures into segment geometry is deferred until it is "absolutely necessary," that is, until a statement is executed that requires segment properties to be consistent with the pt3d data. This makes sense because models with detailed 3D anatomy may have geometry specifications that require hundreds or thousands of pt3dadd statements, and it would waste time if every pt3dadd statement forced updating of everything that depends on cell geometry.
Examples of statements that force updating of segment geometry include things that are absolutely essential for simulations to generate correct results, e.g. h.finitialize() which is used to initialize a model, and h.area(x) which calculates the area of the segment that contains location x where x lies in the interval 0..1 (sometimes used in model setup code when specifying biophysical properties). And in hoc, even diam(x) has the power to trigger segment geometry updates, as you discovered. But accessing segment diameter directly from Python doesn't--yet.
If this is fixable, the fix will probably soon appear in the latest development code. Whether or not it is fixable, a practical workaround is just to execute h.area(x) or h.finitialize() after the last pt3dadd statement has been executed.
Two final comments:
1. You really don't want pt3d data to include extremely small diam3d values, because those will result in extremely high series resistance between adjacent compartments. Examine your diam3d values and you'll find three.
2. It's a good idea for nseg to be odd. Read about this, and about effective strategies for choosing nseg, in the FAQ list
https://www.neuron.yale.edu/neuron/faq/ ... -questions