Plotting mtau and minf

Anything that doesn't fit elsewhere.
Post Reply
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Plotting mtau and minf

Post by mganguly » Wed Jun 24, 2015 11:32 am

Hi

How can I plot variables mtau and minf when working with NEURON using Python ? I use sec._ref_v and sec._ref_mtau_hh and both of them produce hoc error.

Mohit

ted
Site Admin
Posts: 5598
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Plotting mtau and minf

Post by ted » Wed Jun 24, 2015 12:48 pm

What was the exact statement that you tried to execute and what was the complete error message?

mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Plotting mtau and minf

Post by mganguly » Wed Jun 24, 2015 4:43 pm

Thanks for responding. My statement:

vec['mtau']=h.Vector()
vec['mtau'].record(cell(0.5)._ref_mtau) (cell is my section name)


Error message:
NameError: _ref_mtau was not made to point to anything at PySec_0x7f7acb29cc60(0.5).

When I use vec['mtau'].record(cell(0.5)._ref_mtau_hh), it says
NameError:_ref_mtau was not made to point to anything at PySec_0x7effbaf5bc30(0.5).

I am able to plot other variables using cell(0.5)._ref_n_hh

Mohit

mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Plotting mtau and minf

Post by mganguly » Thu Jun 25, 2015 4:57 pm

I was able to plot them by changing the variables from GLOBAL to RANGE variables.

Mohit

ted
Site Admin
Posts: 5598
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Plotting mtau and minf

Post by ted » Fri Jun 26, 2015 3:59 pm

The original question was
How can I plot variables mtau and minf when working with NEURON using Python ? I use sec._ref_v and sec._ref_mtau_hh and both of them produce hoc error.
but the actual question seems to have been "how can I record the time course of mtau and minf?" It's a good thing I didn't start telling you how to plot things, because you were primarily interested in setting up vector record.

mtau_hh and minf_hh are both GLOBALs, so they don't "belong" to any section or segment--they aren't "properties" of any section or segment. The hoc syntax for referring to a GLOBAL that belongs to a density mechanism is
varname_suffix
Notice that this involves neither the name of the section, nor a numerical value that specifies a segment in a section. The Python syntax is
h.varname_suffix
(assuming you have imported h), and again there is nothing that specifies either the name of a particular section nor a segment in a section.

The hoc syntax for recording a RANGE variable is
vecname.record(&sectionname.rangevarname_suffix(range))
or
sectionname vecname.record(&rangevarname_suffix(range))
where the "range argument" lies in the interval 0..1 and specifies the compartment whose range variable will be recorded.

The Python syntax for recording a RANGE variable is
vecname.record(sectionname(range)._ref_rangevarname_suffix)
or
seg = sectionname(range)
vecname.record(seg._ref_rangevarname_suffix)

The hoc syntax for recording a GLOBAL is
vecname.record(&varname_suffix)
and for Python it is
vecname.record(h._ref_varname_suffix)

Finally, a comment about GLOBALs vs. RANGE variables. GLOBALs are used in NMODL for two main reasons. One is for those parameters that are to have the same value across every instance of a particular ion channel or other mechanism. The other use is a way to reduce memory usage by "intermediate variables" such as gating state time constants and steady state values. The memory savings is proportional to the number of intermediate variables that are declared to be GLOBAL and the number of instances of the mechanism in question. In most cases the savings is trivial, except perhaps in very large models where any savings might spell the difference between being able to fit the entire model into memory versus having to use swap space which can slow things down tremendously.

It is rarely a good idea to record the time course of a GLOBAL, because the value that it holds depends on factors that are outside of your control or even your ability to determine. Why? Consider minf_hh. The value it holds at the end of an fadvance depends on which segment of which section happened to be the very last segment in the model at which minf_hh was calculated. You don't know anything about that segment. In order to make sense of a recording of minf_hh, it is a very good idea to promote that variable to a RANGE variable, as you did. That removes all uncertainty because you have complete control over where you are monitoring minf_hh.

mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Plotting mtau and minf

Post by mganguly » Fri Jun 26, 2015 4:57 pm

Thanks for the response.

ted
Site Admin
Posts: 5598
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Plotting mtau and minf

Post by ted » Mon Jun 29, 2015 1:07 pm

Thanks for asking questions that raised several important issues.

aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Re: Plotting mtau and minf

Post by aaronmil » Tue Jul 07, 2015 1:10 pm

ted wrote:GLOBALs are used in NMODL for two main reasons. One is for those parameters that are to have the same value across every instance of a particular ion channel or other mechanism. The other use is a way to reduce memory usage by "intermediate variables" such as gating state time constants and steady state values.
I recently encountered some sodium and potassium channel models in which steady-state and time constant parameters were declared as global. I was concerned that this would mean those channels would no longer have kinetics that depended on the local voltage of the compartment where they are inserted, but rather some strange average of all compartments where that channel is inserted, or whichever compartment was last to update the variable. So just to clarify, are you saying that this use case of global variables is fine, in the sense that every compartment will be allowed to set the variable to its local value, but it won't cause a loss of independence, because every compartment is computed sequentially? Thanks.

ted
Site Admin
Posts: 5598
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Plotting mtau and minf

Post by ted » Tue Jul 07, 2015 2:22 pm

Execution is carried out in such a way that the state of voltage- and ligand-gated channels in a compartment (segment) depends only on the membrane potential and ligand concentrations in that compartment. There is no cross-talk between compartments, unless you use special programming constructs to introduce it deliberately e.g. to represent effects of ion or transmitter spillover from the neighborhood of one compartment to that of another.

Post Reply