strange section count result

Anything that doesn't fit elsewhere.
Post Reply
Rivaldo
Posts: 6
Joined: Mon Jan 12, 2015 8:58 pm

strange section count result

Post by Rivaldo »

Hello there,

Using a "Hippo" template, I generated two cells "Hippos". "dendrite" and "user5" are declared public in the template and I know that each cell has 196 sections. Now I want to group dendrite and user5 of each cell separately into two references "dend1", "dend2" and also count sections for double check. It seems a very easy task but I couldn't make it to work. Actually it counts sections of both cells and at the end, counter "index" is two time 196. I past the piece of the code I wrote for this here. Could you see any obvious mistake?

Thanks

Code: Select all

objref dend[TOTALDEND]
index = 0
forsec Hippos[0].dendrite {
    		dend[index] = new SectionRef()
    		index += 1
	
}
forsec Hippos[0].user5 {
    		dend[index] = new SectionRef()
    		index += 1
}
printf("*********Index: %g ************\n", index)
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: strange section count result

Post by ted »

Presumably dendrite and user5 are both SectionLists. How do you know the answer isn't correct? How many sections are in Hippos[0].dendrite, and how many are in Hippos[0].user5?
Rivaldo
Posts: 6
Joined: Mon Jan 12, 2015 8:58 pm

Re: strange section count result

Post by Rivaldo »

Thanks for the reply. I know this isn't correct because in geometry file I have this two lines of code "create dendrite[109]" and" create user5[77]". So I should have 196 sections in total. Creating only one neuron and using this piece of code I can get the correct index.

Code: Select all

index = 0
forsec "dendrite" { 
    dend[index] = new SectionRef()
    index += 1
}

forsec "user5" {
    dend[index] = new SectionRef()
    index += 1
}
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: strange section count result

Post by ted »

I don't know what's in your cell class's template, but if dendrite and user5 are NOT SectionLists, the first attempt to iterate over either of them should have produced a "stack empty" error message. So I have no idea how the code in your first post managed to execute to completion and produce any nonzero value of "index", let alone why the value was twice as large as the total number of dend and user5 sections.

To see what I mean, consider this very minimal, yet valid, cell class definition

Code: Select all

begintemplate Cell
public init, topol
public soma, dend, user5
proc init() {
  topol()
}
create soma, dend[2], user5[3]
proc topol() { local i
  for i=0,1 connect dend[i](0), soma(1)
  for i=0,2 connect user5[i](0), soma(0)
}
endtemplate Cell
Suppose init.hoc contains just these statements:

Code: Select all

load_file("cell.hoc")
objref foo
foo = new Cell()
topology()
Using NEURON to execute init.hoc produces this output

Code: Select all

|-|       Cell[0].soma(0-1)
   `|       Cell[0].dend[0](0-1)
   `|       Cell[0].dend[1](0-1)
 `|       Cell[0].user5[0](0-1)
 `|       Cell[0].user5[1](0-1)
 `|       Cell[0].user5[2](0-1)
which shows that an instance of the Cell class exists and that it has a soma, two dend sections, and 3 user5 sections.

Now at the oc> prompt enter the following commands and see what hoc replies:

Code: Select all

oc>tally=0
first instance of tally
oc>forsec foo.dend tally+=1
/home/ted/bin/nrn/i686/bin/nrniv: stack empty
 near line 2
 forsec foo.dend tally+=1
                         ^
The key to unraveling this mystery is for you to email me
ted dot carnevale at yale dot edu
your template. Otherwise I can't even guess what's going on.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: strange section count result

Post by ted »

Part of the problem was that the cell class template was not correctly written; the solution for that was to import the model's detailed morphology into a CellBuilder, then use the CellBuilder to export a hoc file that contains a template based on that morphology. An optional final step is to edit the template with a text editor in order to define useful SectionLists ("subsets") e.g. all axonal sections.
Post Reply