NEURONS v is different than mine

A collection of noteworthy items selected by our moderators from discussions about making and using models with NEURON.

Moderators: ted, wwlytton, tom_morse

Post Reply
Robert Claar
Posts: 23
Joined: Tue Jun 23, 2020 8:52 am

NEURONS v is different than mine

Post by Robert Claar »

Hello,

I am in the process of replicating two models in the NEURON framework to extend them in certain ways. At first I wrote one of the models into a single mod file. I didn't use NEURONs built-n v (membrane voltage), I wrote my own differential equation to calculate membrane potential, and I didn't use any USEION statements. Once I ran that model, it worked well. I was able to replicate figures from the paper the original model had come from.

The next step was to break that single mod file up into individual mod files for each of the currents that went into calculating membrane potential. An example of one is shown below. I left out the INITIAL, ASSIGNED, etc blocks to be concise.


NEURON{
SUFFIX B_CaL
USEION CaL WRITE iCaL VALENCE 2
USEION Ca WRITE eCa VALENCE 2
}

BREAKPOINT{
tdCaL = (2.2 - (1.79 * exp( - (.00020292043084065876 * ( - 9.7 + v) * ( - 9.7 + v)))))
fCaLi = (1.0 / (1.0 + exp(((v - VfCaL) / kfCaL))))
dCaLi = (1.0 / (1.0 + exp(((VdCaL - v) / kdCaL))))
iCaL = (gmCaL * dCaL * f1CaL * f2CaL * (v - eCa))
SOLVE states METHOD cnexp
}

When writing these individual mod files I started to use NEURONs v to calculate membrane potential. I also started to use USEION statements to READ in the reversal potential for different currents that have the same ion. For example I also have a R-type calcium current and in that mod file, I would READ eCa in since I had already defined it in the first calcium current mod file (above).

When I ran a simulation with the separate mod files, using neuron's built-in voltage variable, my cells exhibited greater spike magnitude and frequency than when membrane potential was calculated using a differential equation I had in my original single mod file.

I thought that maybe the reversal potential was held fixed in the model I'm trying to replicate, and that by using the USEION statements to READ and WRITE reversal potential, their values might be changing throughout the simulation. So I commented out the USEION statements for reversal potential in each mod file and wrote the value of the reversal potential in the initial block. This had no effect.

I was wondering if there's something I'm missing that would cause such a difference in membrane potential between my single, big mod file, and the separate ones that calculate membrane potential using NEURONs v. Any help is greatly appreciated!
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NEURONS v is different than mine

Post by ted »

At first I wrote one of the models into a single mod file
I don't know anything about your expertise with NEURON or NMODL, but I do know that
1. Most user-written code contains errors, especially NMODL code.
2. All but the most trivial code has bugs. The only question is whether the effect of any particular bug is benign.
3. Code that has been examined and/or used by many people and found to produce reliable results is less likely to have bugs than code that has only been seen and used by one person.
4. The excerpt you provide contains no useful clues. For example,
I also have a R-type calcium current and in that mod file, I would READ eCa in since I had already defined it in the first calcium current mod file (above).
The provided excerpt omits any assignment of a value to eCa.
I wrote my own differential equation to calculate membrane potential
Different numerical methods produce different numerical results. The code snippet omits the method you used.
I thought that maybe the reversal potential was held fixed in the model I'm trying to replicate, and that by using the USEION statements to READ and WRITE reversal potential, their values might be changing throughout the simulation.
NEURON's default behavior is to treat reversal potentials as constant parameters. However, if an NMODL-specified mechanism WRITEs the concentration of some ion x, then by default ex will be calculated automatically from the Nernst equation at every time step. That said, many modelers have their own, often arbitrary, ideas of how concentrations and equilibrium potentials are initialized or vary in the course of a simulation, so NEURON provides a way to override and customize its default behavior--read the Programmer's Reference documentation of ion_style.
I was wondering if there's something I'm missing that would cause such a difference in membrane potential between my single, big mod file, and the separate ones that calculate membrane potential using NEURONs v
You're in the best position to find out, since only you have seen your code. Here are three alternatives:
1. garden variety bug
2. "sequence of execution" issue (are there dependencies between your various NMODL files?)
3. some other difference in numerical methods (I bet your method doesn't involve numerical differentiation to discover the coefficients used in the model's Jacobian)


Comments to others who may read this thread:

A conceptual model of a physical system is only an approximation of the physical system. It necessarily omits most details of the physical system, and those that it includes are only approximations of the components and phenomena that exist in the physical system. "The most exact model of a mouse is another mouse."

A computational model is only an implementation of a conceptual model in a form that is suitable for solution by a computer. Mapping a conceptual model into a computational model typically involves further approximations (e.g. temporal and/or spatial discretization).

All but the most trivial computational models involve equations that cannot be solved exactly, but instead require "numerical solution" which involves approximate methods and produces approximate solutions.
Different numerical methods produce different results. There is a huge literature about computational precision and accuracy. Those who are new to this might start by reading this informative but very brief note: https://docs.microsoft.com/en-us/office ... tions-info
.00020292043084065876
1. Code is more readable if the decimal point in a decimal fraction is preceded by a digit, e.g. in this case 0.0002... . This applies especially to code displayed on high resolution monitors.
2. All those digits--is that a joke? Oops--that question should have been asked by the reviewers of the article that presented the model. Very few properties of cells and tissues are known to within 5% or even 10% accuracy. Reasons for this uncertainty include:
variation of methods from lab to lab
variation of anatomical and biophysical properties of cells and tissues within and across individual animals
Post Reply