Finding parent section name and location

The basics of how to develop, test, and use models.
Post Reply
was2be
Posts: 5
Joined: Wed Sep 26, 2018 3:34 pm

Finding parent section name and location

Post by was2be »

I want to be able to return the parent section name and location (e.g., "dend[4](0.3)") for any child section. I see the SectionRef documentation (https://www.neuron.yale.edu/neuron/stat ... ecref.html), but don't know how to implement it in hoc. Would like to see a few lines of sample code which would return the parent name and location for any identified child section. Thanks.
ted
Site Admin
Posts: 5786
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Finding parent section name and location

Post by ted »

This will report the name of the root section, the name of each child section, and the name of the parent and location on the parent to which the child is attached. I assume you will read about any unfamiliar keywords in the Programmer's Reference.

Code: Select all

// usage: reportparents()
strdef str
proc reportparents() { local x  localobj tobj
  forall {
    str = secname()
    tobj = new SectionRef()
    if (tobj.has_parent()) {
//      tobj.parent {print secname(), " is parent of ", str}
      x = parent_connection()
      tobj.parent {print str, " is attached to ", secname(), "(", x, ")"}
    } else {
      print str, " doesn't have a parent"
    }
  }
}
Post Reply