Changing units in NMODL

NMODL and the Channel Builder.
Post Reply
hkur

Changing units in NMODL

Post by hkur »

Hello,
I have a question about units in a NMODL file.

First, I ran a simulation with the following NMODL code.

Code: Select all

NEURON {
	POINT_PROCESS synAMPA
	RANGE onset, taur, taud, gmax, e, i, Epsilon
	NONSPECIFIC_CURRENT i
}

UNITS {
	(nA) = (nanoamp)
	(mV) = (millivolt)
	(uS) = (microsiemens)
}

PARAMETER {
	onset = 0 (ms)
	taur = 1.0 (ms) 
	taud = 5.0 (ms) 
	gmax = 0.001 (uS) 
	e = 0 (mV)
	Epsilon = 0.000001
}

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

INITIAL {
	Frac = wexpzero( -taur/(taur-taud) * log(taur/taud) , -taud/(taur-taud) * log(taur/taud) )
}

BREAKPOINT {
	at_time(onset)
	g = gmax * (1/Frac) * wexpzero( -(t-onset)/taud , -(t-onset)/taur )
	i = g * (v - e)
}

FUNCTION wexpzero(x, y) {
    if ( x > -Epsilon || y > -Epsilon ) {
        wexpzero = 0
    } else {
        wexpzero = expzero(x) - expzero(y)
    }
}

FUNCTION expzero(x) {
	if (x < -5 || x >= 0) {
		expzero = 0
	}else{
		expzero = exp(x)
	}
}
Next, I ran a simulation with the following NMODL code modified slightly.

Code: Select all

NEURON {
	POINT_PROCESS synAMPA
	RANGE onset, taur, taud, gmax, e, i, Epsilon
	NONSPECIFIC_CURRENT i
}

UNITS {
	(nA) = (nanoamp)
	(mV) = (millivolt)
	(nS) = (nanosiemens)
}

PARAMETER {
	onset = 0 (ms)
	taur = 1.0 (ms) 
	taud = 5.0 (ms) 
	gmax = 1 (nS) 
	e = 0 (mV)
	Epsilon = 0.000001
}

ASSIGNED {
	v (mV)
	i (nA)
	g (nS)
	Frac
}

INITIAL {
	Frac = wexpzero( -taur/(taur-taud) * log(taur/taud) , -taud/(taur-taud) * log(taur/taud) )
}

BREAKPOINT {
	at_time(onset)
	g = gmax * (1/Frac) * wexpzero( -(t-onset)/taud , -(t-onset)/taur )
	i = g * (v - e)
}

FUNCTION wexpzero(x, y) {
    if ( x > -Epsilon || y > -Epsilon ) {
        wexpzero = 0
    } else {
        wexpzero = expzero(x) - expzero(y)
    }
}

FUNCTION expzero(x) {
	if (x < -5 || x >= 0) {
		expzero = 0
	}else{
		expzero = exp(x)
	}
}
Differences between them are units of conductance g and maximum conductance gmax and apparent value of gmax.
Because the actual value of gmax remain unchanged, I predicted that the results are same.
However, actual results are extremely different.
The activity of a cell at first simulation was quiet,
while the one at second simulation was very intense.

What is a cause of this difference?
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Changing units in NMODL

Post by ted »

Excellent question.

The first version is dimensionally consistent, the second is not--(nanosiemens) * (millivolt) does not produce a numerical result with units (nanoamp). Because of the dimensional inconsistency of the second version, the statement
i = g * (v - e)
in the BREAKPOINT block results in i being assigned a value that is 1e3 times too large. If you had checked the second version with modlunit, you would have received the message

Code: Select all

The previous primary expression with units: 1-12 coul/sec
is missing a conversion factor and should read:
  (0.001)*()
 at line 38 in file two.mod
        i = g * (v - e)<<ERROR>>
which tells you to revise the statement so that it reads
i = (0.001) * g * (v - e)
Post Reply