aluchko wrote:97756 where they fit soma.g_KCHANNEL*(v(0.5)-ek)*area(0.5)/1000
Using Fitness Function I'm able to calculate this value, but I'm not sure how to do the same with the Run Fitness generator.
I hope you can come up with a more compelling example. The model cell is a single compartment, and soma.g_KCHANNEL*(v(0.5)-ek)*area(0.5)/1000 is simply the net transmembrane current carried by the KCHANNEL mechanism. The authors could have avoided this awkward expression (and likely time-consuming, because it would have to be interpreted anew at each time step) by doing two things:
1. Recognizing that the model involved only one mechanism that WRITEs ik.* Immediately the expression for net transmembrane current carried by the KCHANNEL mechanism becomes ik*area(0.5)/1000.
2. Recognizing that, if the surface area of a compartment is 100 um2, current density in mA/cm2 is numerically identical to total current in nA. No need to multiply by area or apply any other scale factors. Just set soma diam to 10 um and L to 10/PI. Now the net current in nA carried by the KCHANNEL mechanism is simply ik.
*--"Ah, but suppose there are other mechanisms that also WRITE ik?"
Fair question. To which here's another: why write the NMODL code for the KCHANNEL mechanism in such a way as to hide its contribution to ik? Or, stated in a more positive way, why not make a few minor changes to Kchannel.mod so that its current is exposed to hoc? Specifically:
1. In the NEURON block insert
RANGE i
2. In the ASSIGNED block insert
i (mA/cm2)
3. As the very last statement in the BREAKPOINT block insert
i = ik
Compile the mechanism, and you will find that it now has a new range variable, known to hoc as i_KCHANNEL, which tells you the current generated by the KCHANNEL mechanism.
"Yeah, but what if I the time comes when I really have to use some awful hoc expression instead of a simple variable name?"
Here's a hint, but it comes at the cost of a bet, specifically: I bet you a nickel you'll never have to.
The hint is to use a custom proc advance() (see page 161 of The NEURON Book).
Code: Select all
proc advance() {
fadvance()
foo = . . . some ugly code that calculates a value . . .
}
The value of foo will be updated at each time step and you can use it for whatever purpose you like.
One last item: I know you didn't write the code in question, but here's a comment about naming conventions: for the sake of readability.
--UPPERCASE is best reserved for names of constants.
--Capitalized or CamelCase is best reserved for names of point processes and other object classes.
--all other names--names of scalar variables, doubles, strings, objrefs, sections, and density mechanisms (i.e. suffixes)--should probably be in lower case.
Remind me to collect on my bet when I run into you at The Restaurant at the End of the Universe.