Page 1 of 1

Finding upstream and downstream sections and segments

Posted: Sun Feb 12, 2012 10:19 pm
by Corinne
Hello,

I was wondering if there was an elegant way to find all of the upstream and downstream sections and segments from a node. For example, say I wanted to find the average voltage of all sections upstream from an current injection point. To do this I would need to know the voltage at all the nodes upstream from the cite of my injection. Is there a way to find out what the upsteam sections and segments are, or do I need to make a list by hand?

Thanks!!

Re: Finding upstream and downstream sections and segments

Posted: Mon Feb 13, 2012 10:14 am
by ted

Code: Select all

objref sl
sl = new SectionList()
foo sl.children() // appends all children of foo to sl
SectionRef class has useful methods--parent, child, parent etc.

Re: Finding upstream and downstream sections and segments

Posted: Fri Feb 17, 2012 1:07 am
by Corinne
I knew there would be a fabulous way to do it!

Is there an equally fabulous way to make a list of all the distal most sections of an arbor? I couldn't quite figure it out using the recommended statements.

Thanks!

Re: Finding upstream and downstream sections and segments

Posted: Fri Feb 17, 2012 10:02 am
by ted
First make a SectionList that contains all children of the arbor's root section. Assuming the root section's name is foo

Code: Select all

objref tree
tree = new SectionList()
foo tree.wholetree()
Then iterate over all the sections in that SectionList to identify those that have no children

Code: Select all

objref terminals, thisone
terminals = new SectionList()
forsec tree {
  thisone = new SectionRef()
  if (thisone.nchild == 0) terminals.append()
}
objref thisone // destroy link between thisone and the last referenced section
  // for the sake of safety