forsec ... stack empty

The basics of how to develop, test, and use models.
Post Reply
oren
Posts: 54
Joined: Fri Mar 22, 2013 1:03 am

forsec ... stack empty

Post by oren » Mon Aug 12, 2013 9:50 am

Hello,
I have a neuron model and I am trying to get the route from each leaf ( terminal ) to the routh.
First I use this code to get a list of all terminals

Code: Select all

 objref tree
tree = new SectionList()
soma[0] distance()
soma[0] tree.wholetree()

objref terminals, thisone
 terminals = new SectionList()
forsec tree {
    thisone = new SectionRef()	

    if (thisone.nchild == 0 ) terminals.append
}
objref thisone
After running this code, sectionlist terminal contain all the terminals of the neuron.
Then I want to trace the route back to the root, I try to run this code:

Code: Select all

objref Leaff
Dist = new Vector()
forsec terminals {
	Leaff = new SectionRef()
         while (Leaff.has_parent){
		Leaff.parent
                .....
}
}
But when I try to run the second part of the code I get this error:

Code: Select all

/usr/local/nrn/x86_64/bin/nrniv: stack empty

I found out that the error is in

Code: Select all

Leaff.parent
Because also if I try to run this code

Code: Select all

objref Leaff
Dist = new Vector()
forsec terminals {
	 Leaff = new SectionRef()
         Leaff.parent
}
I get the same error.

What exactly is the problem?

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

Re: forsec ... stack empty

Post by ted » Tue Aug 13, 2013 1:20 am

How to debug this for yourself.

1. Does your code work properly with this model cell?

Code: Select all

// cell 1
create soma, dend[2]
access soma
connect dend[0](0), soma(1)
connect dend[1](0), dend[0](1)
If it does, then see if it fails on this model cell:

Code: Select all

// cell 2
create soma, dend[3]
access soma
connect dend[0](0), soma(1)
connect dend[1](0), dend[0](1)
connect dend[3](0), soma(0)
2. Change your

Code: Select all

forsec terminals {
  . . . statements . . .
}
loop to

Code: Select all

forsec terminals {
  Leaf.sec print secname()
  . . . statements . . .
}
and see what happens when you try your code on the two simple cell models.

oren
Posts: 54
Joined: Fri Mar 22, 2013 1:03 am

Re: forsec ... stack empty

Post by oren » Tue Aug 13, 2013 2:58 am

Thank You Ted, Now I understand.

This is my new code and it work.

Code: Select all

objref Leaff
Dist = new Vector()
forsec terminals {
   Leaff = new SectionRef()
         while (Leaff.has_parent){
      Leaff.sec { ...CODE... }
      Leaff.parent {
                Leaff = new SectionRef
}
                
}
}


Post Reply