units errors in mod files

NMODL and the Channel Builder.
Post Reply
fabien tell
Posts: 49
Joined: Mon Mar 25, 2013 1:36 pm
Location: france
Contact:

units errors in mod files

Post by fabien tell »

Hello,

I'm trying to model an NMDA synapse. The mod file works well with the expected results but when I checked for the units I got the following message :
units : 0.001 sec
units: 1
The units of the previous two expressions are not conformable at line 40 in file ./synnmda.mod

g= gmax * alpha(t <<ERROR>>) * mgblock (v)

It doesn't seem to corrupt the data but I would prefer to correct it

Regards

Here is the mod file :

Code: Select all

COMMENT
an synaptic  NMDA current modeled with a sum of two exponentials and a correction factor to take
into account the magnesium block that depends on Mg and v. 
ENDCOMMENT
					       
NEURON {
	POINT_PROCESS NMDASyn
	RANGE onset, tau1, tau2, gmax, e, i      :onset allows a delay in synaptic transmission
	NONSPECIFIC_CURRENT i
	THREADSAFE
}
UNITS {
	(nA) = (nanoamp)
	(mV) = (millivolt)
	(uS) = (microsiemens)
	(mM) = (milli/liter)
}

PARAMETER {
	onset=0 (ms)     : delay for synaptic event
	tau1= 5 (ms)	<1e-3,1e6>
	tau2=100 (ms)
	gmax=0.02 	(uS)	<0,1e9>
	e=0	(mV)          : reversal potential
	Mg=2 (mM)     : extracellular magnesium
	Mg50= 4 (mM)  : IC50 for magnesium at 0 mV (from kuner et schoepfner (1996)
	z=2           : valence
	delta=0.6 ()  : delta factor for magnesium block from kuner et schoepfner (1996)
	temperature= 32 ()
R=8.31 ()                   : Gas constant
F=96500 ()                   : Farraday constant
corr=1 (mV)       : to correct for units in mgblock function

}

ASSIGNED { v (mV) i (nA)  g (uS)}

BREAKPOINT {
	if (gmax) { at_time(onset) }
	g = gmax * alpha(t)* mgblock (v)
	i = g*(v - e)
}

FUNCTION alpha(t) {
	alpha = (exp(-(t-onset)/tau2)) - (exp(-(t-onset)/tau1))
	
if (alpha < 0 ) {
		alpha = 0
	}else{
		alpha = (exp(-(t-onset)/tau2)) - (exp(-(t-onset)/tau1))
	}
}
 : function modified from kuner et schoepfner (1996)

FUNCTION mgblock (v) {

mgblock = 1/(1+(Mg/Mg50)*exp((0.001)*(-z*delta*F*v/corr)/(R*(273.15+ temperature))))  : mgblock varies from 0 to  1

}
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: units errors in mod files

Post by ted »

Yes, getting the correct numerical result is essential, but it is reassuring to establish consistency of units.

In this part of modlunit's message
g= gmax * alpha(t <<ERROR>>) * mgblock (v)
the clue is right here:
alpha(t <<ERROR>>)
This means that the declaration of the function or procedure called alpha should specify the units of its argument v.
The fix is easy--change
FUNCTION alpha(t) {
to
FUNCTION alpha(t (ms)) {

modlunit will then be able to complain about something else:

Code: Select all

units:	0.001 m2-kg/sec2-coul
units:	1 
The units of the previous two expressions are not conformable
 at line 40 in file nmdasyn.mod
  g = gmax * alpha(t)* mgblock (v<<ERROR>>)
and if you guess that the fix is to change
FUNCTION mgblock (v) {
to
FUNCTION mgblock (v (mV)) {
you're absolutely right.

modlunit's next complaint seems a bit obscure

Code: Select all

The previous expression needs the conversion factor (0.001)
 at line 59 in file nmdasyn.mod
mgblock = 1/(1+(Mg/Mg50)*exp((0.001)*(-z*delta*F*v/corr)/(R*(273.15+ temperature))<<ERROR>>))
A principled fix for this involves multiple changes. First, the units of F, R, and temperature should be specified. So in the PARAMETER block change
temperature= 32 ()
to
temperature = 32 (degC)
and comment out the declarations of R and F, i.e. change
R=8.31 ()
F=96500 ()
to
: R=8.31 ()
: F=96500 ()
Next, add the following statements to the end of the UNITS block
F = (faraday) (kilocoulombs)
R = (k-mole) (joule/degC)
That's right, NMODL knows the values of these constants (how could you know this? maybe look at Example 9.5: A calcium-activated, voltage-gated current in The NEURON Book, or look at cagk.mod in nrn73/examples/nrniv/nmodl under MSWin, or if you're using OS X or Linux, download and expand a nrn*tar.gz source code file, expand it, and drill down to find examples/nrniv/nmodl/cagk.mod).

modlunit's error message is now

Code: Select all

	1+06 sec2-coul/m2-kg
The previous expression is not dimensionless at line 68 in file nmdasyn.mod
mgblock = 1/(1+(Mg/Mg50)*exp((0.001)*(-z*delta*F*v/corr)/(R*(273.15+ temperature))<<ERROR>>))
because F, R, and temperature have proper units, so there is no need for the /corr kludge.

In the PARAMETER block change
corr=1 (mV)
to
: corr=1 (mV)
and change the mgblock assignment statement to
mgblock = 1/(1+(Mg/Mg50)*exp((0.001)*(-z*delta*F*v)/(R*(273.15+ temperature))))
and check again.

Code: Select all

The previous expression needs the conversion factor (0.001)
 at line 69 in file nmdasyn.mod
mgblock = 1/(1+(Mg/Mg50)*exp((0.001)*(-z*delta*F*v)/(R*(273.15+ temperature))<<ERROR>>))
The trick now is to understand what "the previous expression" means.
(R*(273.15+ temperature))<<ERROR>>)
It means the expression that occurs immediately before <<ERROR>>.

So if the denominator needs to be multiplied by (0.001), but the numerator is already being multiplied by (0.001), just delete the (0.001) from the numerator--change the assignment statement to
mgblock = 1/(1+(Mg/Mg50)*exp(-z*delta*F*v/(R*(273.15+ temperature))))
and now modlunit passes nmdasyn.mod without warnings.

A further hint: hoc has a global variable called celsius that is known to NMODL and used by many mod files to specify temperature; its default value is 6.3 (the temperature in degrees Celsius at which loligo pealei are happy). If you comment out the declaration of temperature in the PARAMETER block, add this declaration to the ASSIGNED block
celsius (degC)
and then change the mgblock assignment statement to
mgblock = 1/(1+(Mg/Mg50)*exp(-z*delta*F*v/(R*(273.15+ celsius))))
your will then be able to set the operating temperature of your model with a hoc assignment statement like this:
celsius = 32
fabien tell
Posts: 49
Joined: Mon Mar 25, 2013 1:36 pm
Location: france
Contact:

Re: units errors in mod files

Post by fabien tell »

Thanks a lot ted.

You're so helpful !!!
Regards
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: units errors in mod files

Post by ted »

Helping NEURON users helps NEURON.
Post Reply