question about hocmech()

NMODL and the Channel Builder.
Post Reply
ximmingli
Posts: 2
Joined: Mon May 06, 2013 4:40 pm

question about hocmech()

Post by ximmingli »

Hi, I was trying to use the hocmech() to add new mechanisms in hoc file, following the instruction on the documentation page( http://www.neuron.yale.edu/neuron/stati ... t=makemech)
I simply loaded the example code using nrngui.

Code: Select all

load_file("noload.hoc")

create soma
access soma
{ L = diam = sqrt(100/PI) insert hh}

objref stim
stim = new IClamp(.5)
{stim.dur = .1  stim.amp = .3 }

begintemplate Max
public V

proc initial() {
    V = v($1)
}

proc after_step() {
    if (V < v($1)) {
            V = v($1)
    }
}
endtemplate Max

makemech("max", "Max")
insert max
run()
print "V_max=", soma.V_max(.5)
The interpreter reported error:
makemech undefined function in hocmech_test.hoc near line 25
Then I noted that even the example code is for hocmech(), the function isn't used in the code. So I changed the makemech to hocmech. Still the interpreter showed error:
makemech undefined function in hocmech_test.hoc near line 25

I tried locate hocmech in the terminal, and the return showed
/home/ximing/neuron/nrn/src/nrniv/hocmech.cpp
/home/ximing/neuron/nrn/src/nrniv/hocmech.lo
/home/ximing/neuron/nrn/src/nrniv/.deps/hocmech.Plo
/home/ximing/neuron/nrn/src/nrniv/.libs/hocmech.o


So the source code of hocmech() is there, but somehow the hoc interpreter doesn't know it. The operating system of my computer is Debian. I installed neuron7.3 using nrn-7.3.i686.deb. After installing, I added the neuron path to PYTHONPATH so the neuron module works in python.
My question is how to call hocmech() in nrngui? Also are there other ways to use the mechanism in the template? Thanks!
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: question about hocmech()

Post by ted »

You're right, it's not working; maybe a fix is available.

I prefer the speed of compiled code. Save this to a mod file, then compile it.

Code: Select all

NEURON {
  SUFFIX max
  RANGE v0, vm, vepsp
}

ASSIGNED {
  v (millivolt)
  vm (millivolt)
  v0 (millivolt)
  vepsp (millivolt)
}

INITIAL {
  v0 = v
  vm = v
  vepsp = vm - v0
}

AFTER SOLVE { 
  if (v > v0) {
    vm = v
    vepsp = vm - v0
  }
}
Insert it into one or more sections, and at the end of a simulation
v0_max will be the initial membrane potential
vm_max will be the most depolarized membrane potential
vepsp_max will be the peak depolarization relative to initial membrane potential (i.e. most depolarized membrane potential - intial membrane potential).
hines
Site Admin
Posts: 1691
Joined: Wed May 18, 2005 3:32 pm

Re: question about hocmech()

Post by hines »

I see that at some point in prehistorical times (back in svn or even cvs days) the name hoc_mech got changed to make_mechanism and make_pointprocess also got introduced.
Sadly, the help files failed to note the change. The example works if you change makemech("max", "Max") to
make_mechanism("max", "Max")
ximmingli
Posts: 2
Joined: Mon May 06, 2013 4:40 pm

Re: question about hocmech()

Post by ximmingli »

make_mechanism() works. Thanks hines and ted for the replies!
Post Reply