Accessing segment area

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Accessing segment area

Post by sgratiy »

How can I access the segment area form Python?

For example, I have a hoc objet L2_PC[0] and the the following does not work

Code: Select all

>>> h.L2_PC[0].dend[14](0.1).area
Traceback (most recent call last):
  File "stdin", line 1, in <module>
AttributeError: 'nrn.Segment' object has no attribute 'area'
I thought this is how the range variable should be accessed in Python

Code: Select all

sec(x).rangevar


What do I do wrong here?
Thanks
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Accessing segment area

Post by ted »

area is not a range variable--it is a function. hoc usage is
area(x)
returns area of the segment in the currently accessed section that contains location x.

Try this example (assumes dend is a section with nseg == 5):

Code: Select all

for seg in dend:
  seg.diam = 10*seg.x
Then

Code: Select all

for seg in dend:
  print seg.x, seg.diam, h.area(seg.x)
returns

Code: Select all

0.1 1.0 62.8318530718
0.3 3.0 188.495559215
0.5 5.0 314.159265359
0.7 7.0 439.822971503
0.9 9.0 565.486677646
sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Re: Accessing segment area

Post by sgratiy »

it works, thanks.
Post Reply