Changing NEURON's default units

NMODL and the Channel Builder.
Post Reply
sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Changing NEURON's default units

Post by sgratiy »

It seems that the NMODL allows to change some units but not the other. I have read the units tutorial http://www.neuron.yale.edu/neuron/stati ... units.html but I am still confused. For instance, I was able to changed the units of conductance g to (mS/cm2), however, I cannot change the units of ik to (microamp/cm2). The modlunit complains that the ik must be in (milliamp/cm2). Why can't I control the units of distributed current? I prefer measuring distributed current in milliamp/cm2. Is it possible to do?

Below is the NEURON block for the my mechanism:

Code: Select all

NEURON {
	SUFFIX SK
	USEION k READ ek WRITE ik	
	USEION ca READ cai
	RANGE gbar, g, ik
}
Thanks in advance.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Changing NEURON's default units

Post by ted »

sgratiy wrote:I was able to changed the units of conductance g to (mS/cm2), however, I cannot change the units of ik to (microamp/cm2). The modlunit complains that the ik must be in (milliamp/cm2). Why can't I control the units of distributed current? I prefer measuring distributed current in milliamp/cm2. Is it possible to do?
The units that NEURON assumes for time, membrane potential, ionic equilibrium potentials, current density, etc. are what they are so that users can write code without always having to be concerned about scale factors--as long as they stick with the standard units that NEURON assumes.

That said, if you want some parameter or variable to use some other units, it is very easy to do so. Let's consider the example of your sk mechanism.

(by the way, I would prefer to use lower case rather than upper case for the mechanism's name, because I like to follow the convention of reserving upper case names for object classes, and density mechanisms are not object classes)

Code: Select all

NEURON {
	SUFFIX SK
	USEION k READ ek WRITE ik	
	USEION ca READ cai
	RANGE gbar, g, ik
}
Since this is a density mechanism, the current ik will be in units of mA/cm2. Since you changed the units of g to mS/cm2, your BREAKPOINT block has an assignment statement similar to this:
ik = (1e-3)*g*(v-ek)

But you want to refer to this mechanism's current with a variable whose units are microamp/cm2. Very easy: insert the following statements into your mod file--

In the NEURON block
RANGE i
In the ASSIGNED block
i (microamp/cm2)

In the BREAKPOINT block change
ik = (1e-3)*g*(v-ek)
to

Code: Select all

: ik = (1e-3)*g*(v-ek)
i = g*(v-ek)
ik = (1e-3)*i
Then the hoc name for your current in microamp/cm2 will be i_sk. Which is easier to write than ik_sk, and besides, who needs to be reminded that an sk current is a potassium current?

One more comment:
If I had to type
(microamp/cm2)
more than one time, I'd probably add this statement
(uA) = (microamp)
to the UNITS block
and then I'd be able to type
(uA/cm2)
whenever necessary.
sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Re: Changing NEURON's default units

Post by sgratiy »

Ted, thanks for a quick response. This is a very nice and cleaver solution to my problem. However, I decided that since the units of distributed current and conductance cannot be easily changed throughout the NEURON, it would be best to avoid introducing custom units for some currents. Future user of my code may attempt to subtract i_sk (uA/cm2) from ik (mA/cm2) without knowing that they have different units. Anyway, thanks for explaining this to me. This is one more example where it is best not to temper with the tradition.
Post Reply