PROCEDURE vs. FUNCTION blocks

NMODL and the Channel Builder.
Post Reply
MH

PROCEDURE vs. FUNCTION blocks

Post by MH »

I'm confused about the procedure block and the function blocks... Do I use procedures when there are no units to return? Could you please look at this code and tell me if I have used function and procedure correctly?
Sincerely,
MH

Code: Select all

UNITS {
	(mV) = (millivolt)
    	(nA) = (nanoamp)
	(molar) = (mole/litre)
    	(mM) = (millimolar)
    	(uS) = (microsiemens)
}

NEURON {
	SUFFIX if
	USEION f READ ena, ek WRITE if
	RANGE g_f
}

PARAMETER {
	g_f = 0.00145 (uS)	: Table 5: Membrane Current Parameters - maximum conductance for Hyperpolarization Activated Current
	f_na = 0.2		: p. 3047 - a constant
	y = 3.578708e-03	: Table 7: Initial conditions for State Variables - y is the inactivation gating variable for the Hyperpolarization Activated Current
}

ASSIGNED {
	v (mV)
	if (nA/cm2)
}

STATE { y_alpha }

BREAKPOINT {
	SOLVE states METHOD cnexp
	if = g_f * y * (f_na * (v - ena(mV)) + f_k( ) * (v - ek(mV)))
}

DERIVATIVE states {
	y' = (y_alpha(v) - y) / tao_y(s)
}

FUNCTION tao_y (v(mV))(s) {
	UNITSOFF
	tao_y = 1 / (0.11885 * exp((v + 80.0) / 28.37) + 0.56236 * exp((v + 80.0) / -14.19))
	UNITSON	
}

PROCEDURE y_alpha (v(mV)) {
	UNITSOFF
	y_alpha = 1 / (1 + exp((v + 138.6) / 10.48))
	UNITSON
}

PROCEDURE f_k (f_na()) {
	UNITSOFF	
	f_k = 1 - f_na
	UNITSON
}
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

PROCEDURE vs. FUNCTION blocks

Post by ted »

Functions must return values, procedures mustn't. The PROCEDURE should be called a
FUNCTION. However, the whole file contains many other errors. You should read
chapter 9 of The NEURON Book and work through the first four examples (i.e. up to
and including "A voltage-activated current"). If you don't have the book, at least read the
corresponding part of "Expanding NEURON's Repertoire of Mechanisms with NMODL",
which you can download from
http://www.neuron.yale.edu/neuron/docs

It is essential to check for units consistency with modlunit. If you are using MSWin, be sure
to update to the most recent alpha version of NEURON first--see the latest *exe at
http://www.neuron.yale.edu/ftp/neuron/versions/alpha/
modlunit will also help you identify and eliminate many other kinds of errors. If you are
unsure about how to use modlunit, go to the FAQ page
http://www.neuron.yale.edu/neuron/faq/general-questions
and look for the item
How do I compile mod files?
Post Reply