question about templates

The basics of how to develop, test, and use models.
Post Reply
ppt
Posts: 5
Joined: Mon Dec 15, 2008 8:16 pm

question about templates

Post by ppt »

Hi,

I built a complicated morphology. I would like to be able to duplicate many clones of that morphology and then wire them together using the usual "connect" statement. I figured the way to do it is to embed the hoc code in a template and then generate as many instances of the morphology as I need. My question is: what is the correct syntax or method for then directly connecting them in this way? I naively (not having used templates before) tried something like "connect Cell[1].dend(0), Cell[0].dend(1)" with dend made public and all, but that doesn't do it.

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

Re: question about templates

Post by ted »

Can't tell where your code went wrong without seeing it, but I'll email you a little program I wrote a while back that may help you find your error and maybe give you some new ideas.
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: question about templates

Post by ted »

Better than email: pick up this file
http://www.neuron.yale.edu/ftp/ted/neuron/btree6s.hoc
and use NEURON to execute it. It could probably be more elegant, but it should at least get you going.
ppt
Posts: 5
Joined: Mon Dec 15, 2008 8:16 pm

Re: question about templates

Post by ppt »

Ted, it works when I follow the example in your code and connect the "template tree" to a section created outside of the template but not when connecting two template trees.

In other words, from your code:

Code: Select all

connect stree[0].dend[0](0), core[0](0)
is fine, but:

Code: Select all

connect stree[0].dend[0](0), stree[1].dend[0](0)
just gives an error.

Is it necessary to connect two template trees through an intermediate section?
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: question about templates

Post by ted »

Tell me if the error message you saw is something like this:

Code: Select all

[...](...) syntax only allowed for array range variables: dend
  in bah.hoc near line 176
  connect stree[1].dend[0](0), stree[0].dend[0](1)
                                                  ^
This is somewhat puzzling because the error is localized to the second occurrence of [...](...) on the line, and I would have expected hoc to gag on the first occurrence. But that's the way it works.

So the error message implies that the parent section must be specified in a different way. The documentation of the connect statement presents these two forms:
connect childsection(0or1), x
connect childsection(0or1), parent(x)

Try the first form, and it works--e.g.

Code: Select all

stree[0].dend[0] connect stree[1].dend[0](0), 1
treats stree[0].dend[0] as the parent section, stree[1].dend[0] as the child, and attaches the 0 end of the child to the 1 end of the parent.
ppt
Posts: 5
Joined: Mon Dec 15, 2008 8:16 pm

Re: question about templates

Post by ppt »

I got the same error message as you, but using the first form of the connect statement, as you suggest, does the trick.

Many thanks for the help! I suspect I would have beaten my head against the keyboard for a long time before thinking the connect statement would work in one form but not the other.
Post Reply