problem with .mod code

NMODL and the Channel Builder.
Post Reply
behbehmm
Posts: 2
Joined: Sat May 27, 2006 1:19 pm
Location: Univ. of Cincinnati

problem with .mod code

Post by behbehmm »

Hi all,
I use the code on page 277 of the Neuron Book. (ExpSyn1). The mod file compiles without any error. However when I try to use the ExpSyn1 in a hoc code I get an error stating that ExpSyn1 is not a template. Any idea what this error means and how I can correct it. Bellow is the ExpSyn1.mod code followed by the hoc code.

The mod cod

Code: Select all

:ExpSyn1
NEURON {
POINT_PROCESS ExpSyn1
RANGE e,i,weight
NONSPECIFIC_CURRENT i
}
PARAMETER{
tau=0.1
e=0 (millivolt)
weight=0.1
}
ASSIGNED {
v (millivolt)
i (nanoamp)
}
STATE { g (microsiemens)
}
INITIAL {g=0}
BREAKPOINT {
SOLVE state METHOD cnexp
i=g*(v-e)
}
DERIVATIVE state {g'=-g/tau}
NET_RECEIVE (weight (microsiemens)){
g=g+weight
}


The hoc code

Code: Select all

// test of ExpSyn1 page 277 The NEURON book

begintemplate testcell
public soma,dend,netconlist
create soma, dend[2]
objref netconlist

proc init() {
create soma
netconlist= new List()
soma{
	nseg=1
	L=15
	diam=15
	Ra=150
	insert hh
	gnabar_hh=0.25
	gl_hh = .0001666
     	gel_hh = -60.0
	}
dend[0]{
	nseg=21
	L=300
	diam=1
	insert pas
	}
dend[1]{
	nseg=21
	L=300
	diam=1
	insert pas
	}
connect dend[0](0), soma(0)
connect dend[1](0), soma(1)
}
endtemplate testcell


objref source
source= new testcell()

objref dest
dest= new testcell()

tstop = 200


objref stim
source.soma {
	stim= new IClamp(0.5)
	stim.del=20
	stim.dur =100
	stim.amp = 0.2
	}
//create two different types of synapses
nsyn=2
objectvar syn[nsyn]
/*
AMAP like synapse on dend 0
dest.dend[0] syn[0] = new ExpSyn(0)
syn[0].tau=3
syn[0].e=0
*/
dest.dend[0] syn[0] = new ExpSyn1(0)


// NMDA type synapse
dest.dend[1] syn[1] = new Exp2Syn(0)
syn[1].tau1=3
syn[1].tau2=10
syn[1].e=0


//make connection by appending
source.soma dest.netconlist.append(new NetCon(&v(1),syn[0], -20,1,1.5))
source.soma dest.netconlist.append(new NetCon(&v(1),syn[1], -20,1,0.5))
access dest.soma


Note that if you uncomment codes related to ExpSyn the code works OK.
Mike
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

I use the code on page 277 of the Neuron Book. (ExpSyn1).
Except that in your code
1. tau is not a RANGE variable, so there is no way to change it from hoc.
2. tau is dimensionless, so modlunit will complain about inconsistent units.
3. there is a new RANGE variable called weight, which will have absolutely no effect on
the synaptic conductance change produced by arrival of an event (the weight associated
with an event is an attribute of the NetCon that delivered the event, not an attribute of the
point process that receives the event).
when I try to use the ExpSyn1 in a hoc code I get an error stating that ExpSyn1 is not a template.
Probably because you are starting a NEURON executable that doesn't know about the
compiled mechanism. Examine the banner that NEURON prints at startup. If you don't
see a list of mod files, then NEURON didn't find your compiled mechanisms. Here's what
I see on my Linux box:

Code: Select all

[ted@fantom behbehmm]$ nrngui his_test.hoc
NEURON -- Version 5.9  2006-07-14 (1461)
by John W. Moore, Michael Hines, and Ted Carnevale
Duke and Yale University -- Copyright 1984-2005

loading membrane mechanisms from /home/ted/myhoc/behbehmm/i686/.libs/libnrnmech.so
Additional mechanisms from files
 his_es1.mod
Something similar should appear under OS X and MSWin.

The easiest way to make sure that NEURON "knows about" your compiled mechanisms
is to make sure that the current working directory when you launch NEURON is the one
where the mod files are that you compiled with NMODL--see page 346 of The NEURON
book. Also see this new item in the list of NEURON Book errata:
Banner changes after adding new mechanisms with NMODL
https://www.neuron.yale.edu/phpBB2/view ... =2369#2369

By the way, is there any particular reason why you're using ExpSyn1 rather than the
built-in ExpSyn?
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

behbehmm wrote:
Thanks for your help. I corrected the typos and I placed the whole folder that contains my hoc and mod codes in the NEURON folder they all worked. I used ExpSyn1 because I was getting the same error (XXX is not a template) for any program that I wrote. Therefore I reasoned that if I use a code in the Neuron book it should work.
What NEURON folder? You mean where NEURON itself is installed? Don't do that.
Don't put anything there. Make a new directory somewhere else, and use that as the
root of all your programming projects. That directory is where you will create new
subdirectories, one for each project that you're working on. That's how to avoid breaking
things and having your projects step on each other.

Here's an example of what I mean (excuse me if I have incorrectly assumed that you're
using MSWin):
c:\myhoc would contain all your NEURON projects
Inside c:\myhoc you would have subdirectories, one for each project, named so that you
will remember what their contents are about.
behbehmm
Posts: 2
Joined: Sat May 27, 2006 1:19 pm
Location: Univ. of Cincinnati

Glutamic acid and GABA channels + Code impementation

Post by behbehmm »

Thanks. I have all my codes in a folder “hoc_codesâ€
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

1. Rregarding the use of C code in NMODEL. The NEURON book advises against using this.
Not quite. It literally advises using great care if one chooses to do that.
would it be faster if I code this in C and use VERBATUM to insert it in the model?
If all you are trying to get is faster execution, don't bother. It is unlikely that any speedup at
all will be achieved by inserting your own code for solving ODEs, but quite probable that you
will end up with something that breaks the ability to switch effortlessly from one integrator to
another. However, under the principle of nothing ventured, nothing gained, give it a try if you
wish.
2. There is a real need for having standard NMDA receptor . . .
Until the field settles on an "industry standard NMDA receptor model," NEURON will not
anoint any of the published models as being "the" one. In the meantime, users are free to
read the various articles, make a rational selection among them, then either build their
own or pick up a ready-to-go implementation from ModelDB.
Post Reply