Making nmodl files CVode Compatible
Making nmodl files CVode Compatible
Dear all,
to the best of my knowledge when using the impedance class, the default calculation of the different transfer impedances does not take into account the impedance contributions of gating state differential equations. The calculation is currently limited to systems that can be solved with the CVode method, but unfortunately many mechanisms found in the literature, particularly ion channels models, are not compatible with CVode, and when one wants to analyze the morphoelectrotonic structure of a cell that has those ion channels, one is limited to analyse the passive electrotonic structure of the cell that may greatly differ from the “real” electrotonic structure of the cell.
To overcome this situation:
1) I would like to know if there is a systematic procedure to “generalize” the older/not-CVode-compatible ion channels nmodl files.
or,
2) If this generalization has to be done on a case by case basis, I would like to know where can I find some hints on how to do accomplish that.
Thank you all for the availability!
to the best of my knowledge when using the impedance class, the default calculation of the different transfer impedances does not take into account the impedance contributions of gating state differential equations. The calculation is currently limited to systems that can be solved with the CVode method, but unfortunately many mechanisms found in the literature, particularly ion channels models, are not compatible with CVode, and when one wants to analyze the morphoelectrotonic structure of a cell that has those ion channels, one is limited to analyse the passive electrotonic structure of the cell that may greatly differ from the “real” electrotonic structure of the cell.
To overcome this situation:
1) I would like to know if there is a systematic procedure to “generalize” the older/not-CVode-compatible ion channels nmodl files.
or,
2) If this generalization has to be done on a case by case basis, I would like to know where can I find some hints on how to do accomplish that.
Thank you all for the availability!
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Making nmodl files CVode Compatible
This is discussed in the Programmer's Reference--see
http://www.neuron.yale.edu/neuron/stati ... tionissues
et seq..
As I re-examine that material, I see the discussion of at_time but no mention of using self-events and the NET_RECEIVE block to achieve similar results. at_time does work and it has the particular advantage of working with density mechanisms. However, the NET_RECEIVE block--a feature available only to point processes--facilitates construction of state machines that can implement quite complex stimulus protocols and parameter changes in the course of a simulation.
http://www.neuron.yale.edu/neuron/stati ... tionissues
et seq..
As I re-examine that material, I see the discussion of at_time but no mention of using self-events and the NET_RECEIVE block to achieve similar results. at_time does work and it has the particular advantage of working with density mechanisms. However, the NET_RECEIVE block--a feature available only to point processes--facilitates construction of state machines that can implement quite complex stimulus protocols and parameter changes in the course of a simulation.
Re: Making nmodl files CVode Compatible
Dr. Carnevale,
thank you for the prompt response! For what I indent to do, I will need a large number of CVode compatible ion channels nmodl files for different single neuron models, and probably it will be time consuming. Are you aware of some CVode compatible ion channels nmodl files that I can add to my list? I will start by “generalize” Mainen ZF, Sejnowski TJ (1996) (http://senselab.med.yale.edu/modeldb/sh ... model=2488), but I would like to have a more eclectic set of nmodl files for my simulations.
Looking forward for your response,
Thank you Professor!
thank you for the prompt response! For what I indent to do, I will need a large number of CVode compatible ion channels nmodl files for different single neuron models, and probably it will be time consuming. Are you aware of some CVode compatible ion channels nmodl files that I can add to my list? I will start by “generalize” Mainen ZF, Sejnowski TJ (1996) (http://senselab.med.yale.edu/modeldb/sh ... model=2488), but I would like to have a more eclectic set of nmodl files for my simulations.
Looking forward for your response,
Thank you Professor!
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Making nmodl files CVode Compatible
I can only suggest that you examine the models in ModelDB, and whatever may be available from Channelpedia http://channelpedia.epfl.ch/. Be sure to check each mechanism with modlunit, and fix whatever problem(s) you find. Also, make sure that you use each model at its appropriate operating temperature; that can only be discovered by examining the mod file and reading the associated paper. Note in particular that the mod files used in
Mainen ZF, Sejnowski TJ (1996)
Influence of dendritic structure on firing pattern in model neocortical neurons.
Nature 382:363-6
ModelDB accession number 2488
were written in such a way as to work properly at 37 deg C.
Mainen ZF, Sejnowski TJ (1996)
Influence of dendritic structure on firing pattern in model neocortical neurons.
Nature 382:363-6
ModelDB accession number 2488
were written in such a way as to work properly at 37 deg C.
Re: Making nmodl files CVode Compatible
Dear Ted,
I followed your advice and I examined the mod files from Mainen ZF, Sejnowski TJ (1996), but I got surprised when I ran some simulations (while using the mod files from that model) I realized that those mod files are CVode compatible. When I change the numerical method in the Tools menu from the nrngui to CVode, there was no error warning after the simulations, and the results from the voltage traces measured at the soma and the time course of the axial current reaching the soma were the same for CVode and for the Implicit fixed step (but the real time of the simulations was much faster with CVode). Then I found this in every mod file of the model:
Thank you all for the availability once more!
I followed your advice and I examined the mod files from Mainen ZF, Sejnowski TJ (1996), but I got surprised when I ran some simulations (while using the mod files from that model) I realized that those mod files are CVode compatible. When I change the numerical method in the Tools menu from the nrngui to CVode, there was no error warning after the simulations, and the results from the voltage traces measured at the soma and the time course of the axial current reaching the soma were the same for CVode and for the Implicit fixed step (but the real time of the simulations was much faster with CVode). Then I found this in every mod file of the model:
However, when I try to calculate the electrotonic distance while taking into account the impedance contributions of gating state differential equations of the same cell's models, the following error appears on the terminal:26 Ago 2002 Modification of original channel to allow
variable time step and to correct an initialization error.
Done by Michael Hines(michael.hines@yale.e) and
Ruggero Scorcioni(rscorcio@gmu.edu) at EU Advance Course
in Computational Neuroscience. Obidos, Portugal
But I thought the only requirement to take the impedance contributions of gating state differential equations into account, was that the mechanisms had to be compatible with CVode. What am I missing?/usr/local/nrn/x86_64/bin/nrniv: Segmentation violation
near line 1
{draw()}
^
Impedance[0].compute(0, 1)
LogAvsX[0].compute(0)
LogAvsX[0].draw()
Segmentation fault (core dumped)
Thank you all for the availability once more!
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Making nmodl files CVode Compatible
It is always a good idea to read source code that one gets from others.afc wrote:I found this in every mod file of the model:26 Ago 2002 Modification of original channel to allow
variable time step and to correct an initialization error. . .
Possibly this statement in the Programmer's Reference documentation of the Impedance class's compute() methodI thought the only requirement to take the impedance contributions of gating state differential equations into account, was that the mechanisms had to be compatible with CVode. What am I missing?
"Note that the extended impedance calculation may involve a singular matrix because of the negative resistance contributions of excitable channels."
If that's what happened here, it would be nice if NEURON complained of a singular matrix instead of a segmentation violation, but I suspect that the latter is all one can expect. If a singular matrix is what's happening, reducing the conductance density of voltage-gated sodium and/or calcium channels BEFORE the first impedance calculation "with dstate/dt contribution" should make it go away.
By the way, I don't recall reading a statement to the effect that "the only requirement to take the impedance contributions of gating state differential equations into account, was that the mechanisms had to be compatible with CVode." Where did you find it? (not in something that I wrote, I hope . . . )
Re: Making nmodl files CVode Compatible
Dear Ted,
I followed your advice and I further analyzed the mod files from Mainen ZF, Sejnowski TJ (1996), I found out two "problems":
1) the cad.mod was modified to allow variable time step, but then afterwards the cnexp was replaced with derivimplicit. But i read in http://www.neuron.yale.edu/neuron/stati ... tionissues that one has to replace the SOLVE statement in the BREAKPOINT block with SOLVE states METHOD cnexp. However, even when I did not include this mod file in my models the same error continued to appear.
2) when I checked the kca.mod mechanism with modlunit, an error occurred:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you once more!!
I followed your advice and I further analyzed the mod files from Mainen ZF, Sejnowski TJ (1996), I found out two "problems":
1) the cad.mod was modified to allow variable time step, but then afterwards the cnexp was replaced with derivimplicit. But i read in http://www.neuron.yale.edu/neuron/stati ... tionissues that one has to replace the SOLVE statement in the BREAKPOINT block with SOLVE states METHOD cnexp. However, even when I did not include this mod file in my models the same error continued to appear.
2) when I checked the kca.mod mechanism with modlunit, an error occurred:
and when I declared it at the UNITS block, the following error appeared:Need declaration in UNITS block of the form:
(mM) (units)
Cannot recognize the units: mM at line 54 in file kca.mod
but since this mod file is extensively used in the literature, I assumed that the the absence of the (mM) in the UNITS block was on purpose for some reason.Checking units of kca.mod
1 /m3
The previous expression is not dimensionless at line 129 in file kca.mod
a = Ra * cai^caix<<ERROR>>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I reduced the conductance density of these channels, first one by one, and then both at the same time, and the same error appeared.If a singular matrix is what's happening, reducing the conductance density of voltage-gated sodium and/or calcium channels BEFORE the first impedance calculation "with dstate/dt contribution" should make it go away.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
At this thread: https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=771 there is a comment in a chunk of code that says the following:By the way, I don't recall reading a statement to the effect that "the only requirement to take the impedance contributions of gating state differential equations into account, was that the mechanisms had to be compatible with CVode." Where did you find it? (not in something that I wrote, I hope . . . )
from this I assumed that the generalization of the mod files of the channels would be a sufficient condition to enable one to compute the electrotonic distance of the cell taking into account the influence of those channels. But so far, all the mod files from this model are CVode compatible, but I can not compute the electrotonic distance of the cells when they have these active conductances, so I guess I misinterpreted that statement.zz.compute(FREQ, 1) // takes the impedance contributions of
// gating state differential equations into account
// but requires mechanisms to be compatible with CVODE
Thank you once more!!
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Making nmodl files CVode Compatible
This is not a problem. derivimplicit, like cnexp, is compatible with adaptive integration ("cvode"). To learn more about NEURON's integration methods, and why derivimplicit is sometimes used, seeafc wrote:I followed your advice and I further analyzed the mod files from Mainen ZF, Sejnowski TJ (1996), I found out two "problems":
1) the cad.mod was modified to allow variable time step, but then afterwards the cnexp was replaced with derivimplicit.
Integration methods for SOLVE statements
in the Hot topics area of the NEURON Forum.
That is true in the context of that discussion because the mechanisms that were being addressed in that discussion are HH-style channel descriptions, that is, descriptions of voltage-gated channels that are couched as families of ordinary differential equations, in which the state variables are limited to the range 0..1. derivimplicit is used for accumulation mechanisms, in which one wants to avoid the nonsense result of having a concentration become negative.i read in http://www.neuron.yale.edu/neuron/stati ... tionissues that one has to replace the SOLVE statement in the BREAKPOINT block with SOLVE states METHOD cnexp.
That's a good test.even when I did not include this mod file in my models the same error continued to appear.
modlunit tests for two different things: consistency of units, and NMODL syntax. A report that some units are not defined, or that some inconsistency was discovered, is only a warning and not a report of an error. The code will still compile and run, but the user is advised to verify that any necessary scale factors have been applied so that the results will not be garbage.2) when I checked the kca.mod mechanism with modlunit, an error occurred:Need declaration in UNITS block of the form:
(mM) (units)
Cannot recognize the units: mM at line 54 in file kca.mod
When modlunit reports a syntax error, that's a serious problem that should be fixed. Syntax errors generally produce code that doesn't even run.
What statement did you insert?when I declared it at the UNITS block
Not to say that consistency of units is unimportant, but none of this is relevant to the impedance calculation problem.
Not at all. Common practice is often entirely accidental and arbitrary. In particular, much source code written by scientists rather than experienced programmers is riddled with minor oddities, many of which serve no useful purpose and are neither deliberate nor harmful.since this mod file is extensively used in the literature, I assumed that the the absence of the (mM) in the UNITS block was on purpose for some reason.
Yes, I just did the same myself withI reduced the conductance density of these channels, first one by one, and then both at the same time, and the same error appeared.If a singular matrix is what's happening, reducing the conductance density of voltage-gated sodium and/or calcium channels BEFORE the first impedance calculation "with dstate/dt contribution" should make it go away.
oc>forall if(ismembrane("na")) for (x,0) gbar_na(x) = 0
oc>forall if(ismembrane("ca")) for (x,0) gbar_ca(x) = 0
and it had no useful effect. This will take some further investigation.
Just because something is necessary does not mean that it is also sufficient.At this thread: https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=771 there is a comment in a chunk of code that says the following:from this I assumed that the generalization of the mod files of the channels would be a sufficient condition to enable one to compute the electrotonic distance of the cell taking into account the influence of those channels.Code: Select all
zz.compute(FREQ, 1) // takes the impedance contributions of // gating state differential equations into account // but requires mechanisms to be compatible with CVODE
But I wonder where the problem with the impedance calculation lies.
Re: Making nmodl files CVode Compatible
I'd like to reproduce the problem. Can you send me al the hoc,ses,mod files needed in a zip file to michael dot hines at yale dot edu along with instructions
as to how to see the error?
as to how to see the error?
Re: Making nmodl files CVode Compatible
Nevermind. I downloaded the 2488 model, selected "Figure 1 demo" and then "L3 Aspiny" and "Init&Run".
Then popped up a NEURONMainMenu/Tools/Impedance/Frequency . On selecting
"include dstate/dt contribution" I get the message:
Graph:: presently invalid expression: input(f)
and pressing "Redraw" givse the segmentation violation.
I'll look into this and get back to you.
Then popped up a NEURONMainMenu/Tools/Impedance/Frequency . On selecting
"include dstate/dt contribution" I get the message:
Graph:: presently invalid expression: input(f)
and pressing "Redraw" givse the segmentation violation.
I'll look into this and get back to you.
Re: Making nmodl files CVode Compatible
The Impedance dstate/dt contribution calculation had a bug when the BREAKPOINT block involved a thread instance variable. ie. in ca.mod the statement
gca = tadj*gbar*m*m*h
used tadj.
http://www.neuron.yale.edu/hg/neuron/nr ... e217f4738e
fixes the problem.
You might want to be sceptical of nonlinear impedance results until you have experimented with situations where you know or can intuit the proper behavior from other independent
considerations. At least experiment with different dt if you are looking at movies of the impedance. There seem to be occasional transient singularities in the frequency plot of the
impedance ratio during recovery of the ap for the L3 Aspiny for both fixed and variable step methods. It would probably take days to investigate some of them using small sinusoidal current
sitmuli.
gca = tadj*gbar*m*m*h
used tadj.
http://www.neuron.yale.edu/hg/neuron/nr ... e217f4738e
fixes the problem.
You might want to be sceptical of nonlinear impedance results until you have experimented with situations where you know or can intuit the proper behavior from other independent
considerations. At least experiment with different dt if you are looking at movies of the impedance. There seem to be occasional transient singularities in the frequency plot of the
impedance ratio during recovery of the ap for the L3 Aspiny for both fixed and variable step methods. It would probably take days to investigate some of them using small sinusoidal current
sitmuli.
Re: Making nmodl files CVode Compatible
Thank you so much for your prompt response!!
But just to be sure, How/Where should I add the extra line of code?
Thank you!
But just to be sure, How/Where should I add the extra line of code?
Thank you!
Re: Making nmodl files CVode Compatible
Did you build NEURON from sources? Or did you use an installer. If the latter which installer did you use?
Re: Making nmodl files CVode Compatible
I used an installer, particularly the Debian/Ubuntu for 64 bit (amd86/x86_64) (version 7.3).
Re: Making nmodl files CVode Compatible
Try
http://www.neuron.yale.edu/ftp/neuron/v ... x86_64.deb
If you have a problem launching due to "No module named site" then do an
export PYTHONHOME=/usr
and launch again.
http://www.neuron.yale.edu/ftp/neuron/v ... x86_64.deb
If you have a problem launching due to "No module named site" then do an
export PYTHONHOME=/usr
and launch again.