Making and Plotting Arbitrary Variables

The basics of how to develop, test, and use models.
Post Reply

Making and Plotting Arbitrary Variables

Post by tseredynski »


I am looking to plot the function:


These variables are all available in a model file HH.mod. Am I able to create a variable in my main .hoc file (Neuron.hoc) similar to:

gna = gnabar_HH*m_hh*m_hh*m_hh*h_hh

and plot it using either code or the NEURON GUI?

Or is it necessary to define and assign the variable gna in HH.mod and reference it as gna_HH? I have had no success trying to create an arbitrary variable in my .hoc file and plot it. Trying to learn what I can and can't do in NEURON.


- Tyler

EDIT: I was able to implement the above calculation inside HH.mod and plot it. However, my real reason in wanting to plot a variable from Neuron.hoc is so that I can try summing the gna from all .mod files and plot the result. Therefore I hope someone can still recommend a way of doing so. Thanks again!
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Making and Plotting Arbitrary Variables

Post by ted »

Presumably you have more than one NMODL-specified ionic current mechanism that WRITEs ina. If you want to know the sodium conductance associated with an instance of such a mechanism, it will be easiest for you if the mechanism's source code
{computes the conductance internally} AND {makes it available to hoc as a RANGE variable}
This means that the NEURON block declares
RANGE g : the sodium conductance
the ASSIGNED block declares
g (S/cm2) : for a density mechanism; units must be uS for a point process
and the BREAKPOINT block contains a statement of the form
g = formula_that_computes_conductance_density_of_open_sodium_channels

If you want to add up the total sodium conductance over the entire surface of the cell, you must also be concerned about units. This means multiplying the conductance associated with each instance of any given density mechanism by the surface area of the segment in which it exists, then scaling this product by whatever factor is necessary to ensure that the result has appropriate units. Conductances associated with any point processes that WRITE ina must also be calculated, scaled as necessary, and added to the sum in whatever segment to which they have been attached.

The simplest case is when the following statement is true:
{no point process WRITEs ina}
{all density mechanisms that WRITE ina specify the channel density in S/cm2}
{if a section contains one mechanism that WRITEs ina, it contains all mechanisms that WRITE ina}.
The total sodium conductance at any particular moment would then be returned by this function:

Code: Select all

func totalgna() { local sum // returns total gna in S
  sum = 0
  forsec has_gna {
    for (x,0) sum += (1e-8)*area(x)*expression_that_sums_all_sodium_conductances_in_this_segment
  return sum
The right hand side of
for(x,0) sum += . . .
depends on the mechanisms that are used in your model.

To force calculation of a new value at every time step, it is necessary to define a new fadvance(). It will also be necessary to ensure that total conductance is calculated at initialization. Just make sure that this bit of code

Code: Select all

gnatotal = 0
proc advance() {
  gnatotal = totalgna()

proc init_gnatotal() {
  gnatotal = totalgna()

objref fih
fih = FInitializeHandler("init_gnatotal()")
is executed AFTER your model setup code but before run() is called. You will then be able to plot gnatotal or record it to a Vector during a simulation.
Post Reply