how to add channels.ses to a template

NMODL and the Channel Builder.
Post Reply
arkmand
Posts: 1
Joined: Mon Oct 10, 2011 11:23 am

how to add channels.ses to a template

Post by arkmand »

Hello I'm new in NEURON, I want to reproduce a model that I found in modelDB (Aradi and holmes 1999). as far as I understand this model added distributed mechanisms with the GUI and stored in a session, and then it loads the "channels.ses" to include these mechanisms in the model. What I want to do is to make copies of this cell with templates but it seems like the mechanisms are not included in the new cells. this is the code:

[code]load_file("nrngui.hoc")

v_init = -70
tstart = 0
tstop = 200
dt = 0.025

load_file("channels.ses")
objref p
p = new PWManager()
for i = 2,5 {p.hide(i)}

objectvar Gcellx[2]

begintemplate Granulecellx
public soma, axon, GCL, prox, middle, distal


proc celldef() {
topol()
subsets()
geom()
biophys()
geom_nseg()
}

create soma, axon[4], GCL[2], prox[2], middle[2], distal[2]

proc topol() { local i
connect axon(0), soma(1)
for i = 1, 3 connect axon[i](0), axon[i-1](1)
for i = 0, 1 connect GCL[i](0), soma(0)
for i = 0, 1 connect prox[i](0), GCL[i](1)
for i = 0, 1 connect middle[i](0), prox[i](1)
for i = 0, 1 connect distal[i](0), middle[i](1)
basic_shape()
}
proc basic_shape() {
soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)}
axon {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(30, 0, 0, 1)}
axon[1] {pt3dclear() pt3dadd(30, 0, 0, 1) pt3dadd(45, 0, 0, 1)}
axon[2] {pt3dclear() pt3dadd(45, 0, 0, 1) pt3dadd(60, 0, 0, 1)}
axon[3] {pt3dclear() pt3dadd(60, 0, 0, 1) pt3dadd(120, 0, 0, 1)}
GCL {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, 30, 0, 1)}
GCL[1] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, -29, 0, 1)}
prox {pt3dclear() pt3dadd(-29, 30, 0, 1) pt3dadd(-44, 30, 0, 1)}
prox[1] {pt3dclear() pt3dadd(-29, -29, 0, 1) pt3dadd(-44, -29, 0, 1)}
middle {pt3dclear() pt3dadd(-44, 30, 0, 1) pt3dadd(-59, 30, 0, 1)}
middle[1] {pt3dclear() pt3dadd(-44, -29, 0, 1) pt3dadd(-59, -29, 0, 1)}
distal {pt3dclear() pt3dadd(-59, 30, 0, 1) pt3dadd(-119, 30, 0, 1)}
distal[1] {pt3dclear() pt3dadd(-59, -29, 0, 1) pt3dadd(-119, -29, 0, 1)}
}

objref all, dendrites, GCLs, proxs, middles, distals, allaxon
proc subsets() { local i
objref all, dendrites, GCLs, proxs, middles, distals, allaxon
all = new SectionList()
soma all.append()
for i=0, 3 axon[i] all.append()
for i=0, 1 GCL[i] all.append()
for i=0, 1 prox[i] all.append()
for i=0, 1 middle[i] all.append()
for i=0, 1 distal[i] all.append()

dendrites = new SectionList()
for i=0, 1 GCL[i] dendrites.append()
for i=0, 1 prox[i] dendrites.append()
for i=0, 1 middle[i] dendrites.append()
for i=0, 1 distal[i] dendrites.append()

GCLs = new SectionList()
for i=0, 1 GCL[i] GCLs.append()

proxs = new SectionList()
for i=0, 1 prox[i] proxs.append()

middles = new SectionList()
for i=0, 1 middle[i] middles.append()

distals = new SectionList()
for i=0, 1 distal[i] distals.append()

allaxon = new SectionList()
for i=0, 3 axon[i] allaxon.append()

}
proc geom() {
forsec dendrites { L = 150 diam = 3 }
forsec GCLs { L = 50 }
forsec allaxon { L = 50 }
axon.diam = 0.9
axon[1].diam = 0.7
axon[2].diam = 0.5
axon[3].diam = 0.4
soma { L = 16.8 diam = 16.8 }
axon[3] { L = 1400 }
}
proc geom_nseg() {
forsec dendrites { nseg = 4 }
forsec GCLs { nseg = 2 }
forsec allaxon { nseg = 1 }
soma { nseg = 2 }
axon[3] { nseg = 28 }
}
proc biophys() {
forsec all {
Ra = 210
cm = 1
insert pas
g_pas = 2.5e-05
e_pas = -70
}
forsec dendrites {
cm = 1.6
insert pas
g_pas = 4e-05
e_pas = -70
}
forsec GCLs {
cm = 1
insert pas
g_pas = 2.5e-05
e_pas = -70
insert Na
gmax_Na = 0.018
insert fKDR
gmax_fKDR = 0.004
insert sKDR
gmax_sKDR = 0.003
}
forsec proxs {
insert Na
gmax_Na = 0.013
insert fKDR
gmax_fKDR = 0.004
insert sKDR
gmax_sKDR = 0.003
}
forsec middles {
insert Na
gmax_Na = 0.008
insert fKDR
gmax_fKDR = 0.001
insert sKDR
gmax_sKDR = 0.003
}
forsec distals {
insert fKDR
gmax_fKDR = 0.001
insert sKDR
gmax_sKDR = 0.004
}
forsec allaxon {
insert Na
gmax_Na = 0.21
insert fKDR
gmax_fKDR = 0.028
}
soma {
insert Ca
gtcabar_Ca = 0.0018
gncabar_Ca = 0
glcabar_Ca = 0
insert CadepK
gbkbar_CadepK = 0
gskbar_CadepK = 0
insert Na
gmax_Na = 0.12
insert fKDR
gmax_fKDR = 0.016
insert sKDR
gmax_sKDR = 0.003
}



}
endtemplate Granulecellx




for i=0, 1 {
Gcellx[i] = new Granulecellx()

}

access Gcellx[1].soma


objectvar stim[2]

for i=0, 1 {
Gcellx[i].soma stim[i]= new IClamp(0.5)
stim.amp=0.2
stim.dur=1
stim.del=1
}

[/code]

Thank you.
arkmand
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: how to add channels.ses to a template

Post by ted »

Can't tell by just looking at the code. If you zip up your hoc code and the ses file, and any nmodl files that may be required, and email it to me
ted dot carnevale at yale dot edu
I'll try to reproduce the problem and advise you how to proceed.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: how to add channels.ses to a template

Post by ted »

Summary of off-line email discussion and solution:

In general, it is only necessary to load the ses file for a channel specified with the Channel Builder. After that, the channel mechanism is usable from hoc exactly as if it had been specified with NMODL. The real problem in this particular case was to wrap a single cell model inside a template so that it could be used to spawn multiple instances, as would be useful in making a network model.

It is possible to write a cell class template from scratch, but the task is complicated by the large number of seemingly arbitrary syntax details. Fortunately it is relatively easy to use the GUI to create a template for a simple ("toy") model cell. This template can serve as a "software pattern" for templates that define other cell classes. Basically, one modifies the template so that it contains the specification of whatever model cell one likes.

Start by using
NEURON Main Menu / Build / Network cell / From Cell Builder
to set up a model specification that has a soma, a couple of dend sections, and an axon. Make nseg 1 for the soma, and let it be any odd number > 1 for the dends and axon.fixed values to their nseg Make the dend segments passive and put hh in the soma and axon. Change the name of the cell class to whatever you like; for this particular example I chose Gc (for "Granule cell").

Next bring up a Network Builder, and drag one instance of the Gc class onto the canvas.

Finally click on the Network Builder's "Hoc File" button, and tell NEURON the name of the file that it will write to disk. This file will contain a complete working template of the toy model cell.

"How does this help?"

Using a text editor, extract the template and save it to a new file. Print it, then study it. Note the names that are declared public; these include the names of all the sections in the model. Also note that it is organized around a main procedure called proc init(), which calls other procedures, and that these procedures' names describe what they do.

For this particular example, the structure of the source code for the model cell that was to be wrapped inside a template was very similar to the structure of the toy cell's template. Modifying the toy cell's template consisted primarily of copying statements from the original model cell's source code (thank you, I. Aradi, for using the CellBuilder to create your model cell's hoc code!) and using it to replace corresponding statements in they toy cell's template--for example, the toy cell's
public soma, dend, axon
and
create soma, dend[2], axon
were replaced with
public soma, axon, GCL, prox, middle, distal
and
create soma, axon[4], GCL[2], prox[2], middle[2], distal[2]

A few things had to be deleted, e.g.
synlist and connect2target were eliminated, so
public synlist, x, y, z, position, connect2target
became
public x, y, z, position
Likewise, the two lines
synlist = new List()
synapses()
had to be deleted, as did the code that defined proc synapses()
and objfunc connect2target()

Finally, the statements

Code: Select all

forsec all {
        if (ismembrane("Na")) {ena = 45}
        ek = -85
}
had to be moved inside the template--right to the very end of proc biophys()
(i.e. just before that proc's closing curly bracket).

Also, as minor matter of esthetics, the begintemplate statement was changed from
begintemplate Gc_Cell
to
begintemplate Gc

After that, the finished template was written to a hoc file called gc.hoc, ready to be used any time by including the statements

Code: Select all

load_file("channels.ses") // so the Channel Builder-specified current is available
load_file("Gc.hoc") // Gc class template
All very much more easily done than said--and very quickly, too.
Thanks to arkmand for asking a question that led to this example of how to reuse a GUI-created software pattern to help create user-written hoc code.
Post Reply