### Accessing segment diameter

Posted:

**Wed Mar 12, 2014 8:51 pm**Hi,

What is the correct way of accessing segment diameter from python? In a python version of 'cone.hoc' (see 'cone.py' below) seg.diam did not return the same values compared to a hoc call (see output below).

What is the correct way of accessing segment diameter from python? In a python version of 'cone.hoc' (see 'cone.py' below) seg.diam did not return the same values compared to a hoc call (see output below).

**cone.py**Code: Select all

```
import neuron
import math
h = neuron.h
a = h.Section()
a.Ra = 100
a.nseg = 10
a.push()
h.pt3dclear()
for i in range(0,31):
x = math.pi*i/30.0
h.pt3dadd(200*math.sin(x), 200*math.cos(x), 0, 100*math.sin(4*x))
for seg in a.allseg():
print seg.x, seg.diam
h.psection()
h("for (x) print x, diam(x)")
```

**output**Code: Select all

```
0.0 500.0
0.05 500.0
0.15 500.0
0.25 500.0
0.35 500.0
0.45 500.0
0.55 500.0
0.65 500.0
0.75 500.0
0.85 500.0
0.95 500.0
1.0 500.0
PySec_b72bc938 { nseg=10 L=628.031 Ra=100
/*location 0 attached to cell 0*/
/* First segment only */
insert capacitance { cm=1}
insert morphology { diam=500}
}
0 54.180325
0.05 54.180325
0.15 87.665604
0.25 33.45362
0.35 87.665604
0.45 54.180325
0.55 54.180325
0.65 87.665604
0.75 33.45362
0.85 87.665604
0.95 54.180325
1 54.180325
```