getting distance without using currently accessed section

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

Moderator: hines

Post Reply
vellamike

getting distance without using currently accessed section

Post by vellamike » Tue Nov 09, 2010 11:53 am

Hi,

I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?

Mike

ted
Site Admin
Posts: 5619
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: getting distance without using currently accessed section

Post by ted » Tue Nov 09, 2010 7:47 pm

vellamike wrote:I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?
Sounds like a contradiction in terms to me, whether in Python or any other language. The section to which a node belongs is part of what distinguishes it from any other node in a model cell. But maybe somebody else will have an answer, in which case I'll learn something new (for the nth time today . . . )

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: getting distance without using currently accessed section

Post by hines » Wed Nov 10, 2010 7:55 am

To use the "distance" function you need to specify the section, either implicitly as in a
for sec in h.allsec():
for seg in sec:
print h.distance(seg.x)
or explicitly as in
print h.distance(dend(.5).x, sec=dend)

However, this is certainly one of those functions that cries out for greater pythonicity as in
print h.distance(dend(.5))
which presents all the informatin needed to compute the distance (from the origin).
This is one of a number of such cases, many of which have already been modified to have a pythonic variant (i.e. take a segment arg instead
of a section, x pair.) I need to look into the possibility of doing this generically.

Post Reply