Page 1 of 1

question about hocmech()

Posted: Wed May 08, 2013 8:08 pm
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!

Re: question about hocmech()

Posted: Wed May 08, 2013 10:04 pm
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).

Re: question about hocmech()

Posted: Thu May 09, 2013 6:58 am
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")

Re: question about hocmech()

Posted: Thu May 09, 2013 11:01 am
by ximmingli
make_mechanism() works. Thanks hines and ted for the replies!