Re: Getting the full topology (segments level) from hoc
Posted: Wed Nov 20, 2013 9:47 am
The problem is that you are interating over the child sections when the number of children are changing within the body of the iterator.
(although it may not matter here and I can't tell if it does without thinking too hard about the code, it also does not seem to be a good idea to include
the Ext section within the forall processing). So I changed forall to 'forsec most' where most is the original sections. Anyway, here is the diff for the
changes I made.
(although it may not matter here and I can't tell if it does without thinking too hard about the code, it also does not seem to be a good idea to include
the Ext section within the forall processing). So I changed forall to 'forsec most' where most is the original sections. Anyway, here is the diff for the
changes I made.
Code: Select all
diff -r b66e93677626 test.hoc
--- a/test.hoc Wed Nov 20 09:30:31 2013 -0500
+++ b/test.hoc Wed Nov 20 09:40:31 2013 -0500
@@ -1,11 +1,20 @@
+ load_file("./sp.hoc")
+objref most
+most = new SectionList()
+forall most.append()
+
objref somaref,secref,extVec,strFunc,stim,g1
strFunc = new StringFunctions()
create Exts[1]
- proc hinesDisperseBranching(){localobj sl,secRef
+ proc hinesDisperseBranching(){local i localobj sl,secRef, clist
counter = 0
- forall{
+ forsec most{
secRef = new SectionRef()
- if(secRef.nchild>1){
+ if(secRef.nchild>2){
+ clist = new List()
+ for i=0, secRef.nchild-1 {
+ secRef.child[i] clist.append(new SectionRef())
+ }
Exts[counter]{
L = 1e-9
diam = 1
@@ -18,7 +27,7 @@
for(x){
if (x > 0) {
printf("x is %f i is %d\n",x,i)
- connect secRef.child[i](0), x
+ connect clist.o(i).sec(0), x
i +=1
}
}
@@ -34,14 +43,13 @@
}
proc countExts(){
ext_num=0
- forall{
+ forsec most {
somaref= new SectionRef()
- if (somaref.nchild>1){
+ if (somaref.nchild>2){
ext_num+=1
}
}
}
- load_file("./sp.hoc")
countExts()
printf("Creating Exts %d\n",ext_num)
create Exts[ext_num]