NeuronC statements and syntax


Writing NeuronC programs


Overview

NeuronC is a language for simulating physiology experiments on large retinal circuits. It is an interpreted language based on the "hoc" (high order calculator) described in Kernighan and Pike (1984). With the NeuronC language, one can describe and simulate a neural circuit along with a complete stimulus and recording paradigm. NeuronC includes statements to define the morphology, connectivity, and biophysical parameters of a neural circuit, as well as 2-dimensional stimuli and recordings (voltage, current) from any node in a circuit. NeuronC stimuli can be voltage or current clamps at single locations in the neural circuit or may be 2-dimensional patterns of light which cause simulated photoreceptors to transduce visual signals. Thus NeuronC is a general-purpose neural simulator with enhancements for visual neural circuits.

"Construct" mode

NeuronC has 2 distinct modes of operation, "construction" and "run". In the "construction" mode, NeuronC builds a neural circuit from programmed instructions, along with stimuli and recordings.

In the "construction" mode, one can perform simple calculations, program loops, procedures and subroutines to define neural elements. You may organize these procedures to create a neuron or circuits of many neurons. You may also include stimuli and records in loops and procedures. "Construction" mode is familiar to computer programmers because it is similar to a language like "C" in which procedures are used to accomplish tasks.

A simple calculation:

     print 54/7;                  (prints simple calculations)
A print statement within a loop:
     for (i=0; i<10; i++)
            print i, sqrt(i);     (prints square roots)
To define a circuit, add a neural element definition:
   for (i=1; i<=5; i++)  conn i to i-1 cable dia 10-i length 10;

                                (makes a tapered cable) 

Run mode

NeuronC's "run" mode stops "construction" mode and translates the neural circuit already defined into difference equations that can be numerically integrated at high speed. The only actions that can be performed during "run" mode are numerical integration of voltage and stimulus, record, and plot. Everything else must wait until the run is completed. However, it is possible to stop a simulation, go into "construction" mode to graph some variables or add to the neural circuit, and continue run mode (using the "step" statement). This is useful for printing results on the screen when more than simple time plots are desired.
     statement 1;   (these statements construct neural circuit)
     statement 2;
     statement 3;
     .
     .
     .
     step .05;      (stops circuit construction, runs 50 msec)

Run time translation from elements to compartments

The neural circuit defined by a list of neural elements and nodes is a high level description which NeuronC translates to a lower level before starting the simulation. The translation is accomplished automatically by creating compartments to represent nodes and cables and creating various types of connections to represent synapses, transduction elements and active channels. There's no need to pay attention to these details of the compartments and connections because NeuronC defines them automatically from the high-level neural element definition. However, it is possible to print out a complete description of all the compartments and connections if needed to check them for correctness.

The result of the translation at run-time is a set of linked lists of compartments, connections and pointers between them which the computer scans at high speed for every time step of the simulation run. Each compartment has a linked list of pointers (no limit on the number) which define its connections. Each connection has a set of pointers to the compartments it connects. Every type of connection to a compartment has its own set of mathematical instructions that describe the voltage and current flow through the connection.


Nodes, neural elements

In the NeuronC language, one describes circuits as a set of neural elements connected to each other at nodes. A node is a common point at which neural elements connect electrically to each other. Thus a node is not a neural element; it is needed only to define connections between elements when a neural circuit is being defined. A node can have as many connections as needed; the only limitation is the amount of memory in the computer.

NeuronC has several types of neural elements. Each element connects to either 1 or 2 nodes, and the nodes must be given when the element is defined. The types are:

   Type    Nodes    Description

   cable    2       defines multiple compartments.
   sphere   1       defines one compartment.
   synapse  2       defines connection between 2 nodes.
   gap junc 2       defines resistive connection between 2 nodes.
   rod,cone 1       transduction apparatus connected to node.
   vbuf     2       buffer (voltage follower). 
   load     1       resistor to ground.
   resistor 2       defines resistive conn. between 2 nodes (same as g.j.)
   cap      2       series capacitor between 2 nodes.
   gndcap   1       capacitor to ground; adds capacitance to node.
   batt     2       series battery between 2 nodes.
   gndbatt  1       battery to ground.
   chan     1       active set of channels in membrane.

Declaring parameters

Parameters such as "length" and "rm" may be specified for neural elements if needed. These assignments may be given as normal assignment statements without a semicolon after them, e.g. "length=50" or "rm=9500" or the "equals" sign may be left out.

Default parameters

Each neural element has a set of parameters which may be specified when the individual neural element is declared. If a parameter is not defined when the neural element is defined, it has a default value specified by a predefined variable. For instance the default value of "Rm" for passive dendrites is defined by the "drm" variable. This variable may be set with an assignment statment (e.g. "drm = 3000") like any other variable.

It is often useful to change the default value of a parameter that you have defined in your script. You can do this with the "setvar()" function, which sets variables in your script from values you give on the command line with the "-s variable xx" option (see Setting variables from command line below).


Units

NeuronC assumes certain units for biophysical parameters, and cannot understand units if one types them in. All diameters and lengths are in microns, and membrane parameters have the units in the above table. Time is in seconds, voltages are in volts, current is in amps.

Syntax for node connections


Syntax for neural elements

The syntax for the neural elements is given below. Extra spaces (not needed for separating words) are ignored, as are newlines (line feeds or the "enter" key). Words not inside angle brackets must be spelled exactly. The angle brackets indicate a category of input, for example, "<expr> means an expression:
     Symbol         What to type in:

      word          Must be spelled exactly.
     <expr>         Expression needed here.
       |            Logical OR (either this stmt or another). 
     'word'         Optional part of statement.
     <node>         Node number, either simple expression,
                    or a 1- 2- 3- or 4-dimensional number
                    inside square brackets (see below).
                    Can also include "loc" statement (see below).
Each element has either "conn" or "at" as its required first word, followed by node expressions:
    conn  <expr> to <expr>   
    at    <expr>             

Node numbers

The node number may be defined as a constant or variable or expression. The node expressions must evaluate to numbers, and must be unique within the program given to NeuronC.

Node numbers can also be 2-, 3- or 4-dimensional, but in this case the node numbers must be enclosed with 2 or 3 sets of square brackets "[]"; for example:

    conn [<expr>][<expr>][<expr>] to [<expr>][<expr>]  
    at   [<expr>][<expr>][<expr>]                        
Since the node number may be specified either as a simple expression or as a 2-, 3- or 4-dimensional number inside square brackets, node numbers in this manual appear like this:
    conn <node> to <node>  
    at   <node>              
Three- and four-dimensional node numbers are useful for specifying which presynaptic cells should connect to a post- synaptic cell. To design your circuit this way, you can specify connections to a neuron based on its type and cell number, without explicitly keeping track of the total number of nodes or compartments defined (which in many cases is a distraction) . To do this, assign the first node dimension to mean "neuron type", the second dimension to mean "cell number", and the third dimension to mean "node number within the cell". If you have an array of cells, you can assign a 2-dimensional "cell number" (dimensions 2 and 3), leaving the fourth to describe the "node within the cell".

Node locations

Each node may optionally be defined to have an (x,y) or (x,y,z) location; this is useful for determining how close two neural elements are when a NeuronC program is building a neural circuit:
   conn <node> loc (<expr>,<expr>) to <node> loc (<expr>,<expr>) 
   at   <node> loc (<expr>,<expr>)                 
However, locations of both nodes need not be defined in every "cable" statement. It is unnecessary to define the location of a node more than once. For example, if you are defining a cable with several segments, define the locations this way:
   conn  loc (10,0) to     
   conn  loc (20,0) to     
or:
   for (i=0; i<10; i++) {
     conn [i] loc (i*10,0) to [i+1]     
   };
Also, the node locations may be specified in a "dummy" definition statement:
    at   <node> loc (<expr>,<expr>)
This defines no neural elements but defines the node and sets the node's location. This method is useful when you have a list of cables with absolute locations. In this case, you can specify the locations of the nodes all at once, and then define the cables and their diameters. The lengths are then determined automatically from the node locations.

Photoreceptors are required to have a location in their definition (see "photoreceptors" below). But the photoreceptor location is for the purpose of light stimuli only.


Declaring parameters

Neural element statements can include optional parameters such as "length" and "rm". These assignments may be given as normal assignment statements without a semicolon after them, e.g. "length=50" or "rm=9500". Alternatively the "equals" sign may be left out. For example:
       seglen = 50;
       conn <node> to <node> cable length=seglen rm=9500;
is equivalent to:
       conn <node> to <node> cable length 50 rm 9500;
Whenever an optional parameter is not specified, its corresponding default value is used instead. Default values are listed in Section 7, "Predefined variables". Setting an optional variable does not change the value of its default. An attempt to set a variable other than one of the valid parameters inside a neural element statement will be trapped as an error.

Errors

The neural circuit must be described completely and correctly in setup mode because "run" mode checks the neural circuit. If anything is wrong all that run mode can do is report an error, and keep going if it can. Usually this is not useful, so if errors are reported, the simulation must be stopped. The NeuronC interpreter reports the line number and character position of errors that it identifies. But don't take line number error reports too literally: often the error can be found on a line before the one reported!

To find errors, run NeuronC in "text mode" for printing the errors on the screen:

     nc -t file
This prints out the graph commands as a set of numbers on the screen, instead of graphics. If an error is discovered, the line number and position of the error on the line are printed, too. See section 5 for more information about how to run NeuronC.

Cable

conn <node> to <node> cable dia <expr> 'parameters'
     optional parameters:

     dia    = <expr>
     length = <expr>
     rm     = <expr> 
     ri     = <expr>
     cm     = <expr>
     cplam  = <expr>
     vrev   = <expr>
     vrest  = <expr>                           
     jnoise = <expr>                           
     rsd    = <expr>
     Na type <expr> 'vrev=<expr> 'density=<expr> 'thresh=<expr>' 'tau=<expr>'
     K  type <expr> 'vrev=<expr> 'density=<expr> 'thresh=<expr>' 'tau=<expr>'
     CGMP type <expr> 'vrev=<expr> 'density=<expr> 'thresh=<expr>' 'tau=<expr>'
     Ca type <expr> 'vrev=<expr> 'density=<expr> 'thresh=<expr>' 'tau=<expr>'
where:
     parm:   default:              meaning:
-------------------------------------------------------------       
     length  um                        length of cable segment
     dia     um                        diameter of cable segment
     rm      40000 Ohm-cm2 (drm)       membrane leakage resistance. 
     ri      200   Ohm-cm  (dri)       axial cytoplasmic resistivity. 
     cm      1e-6  F/cm2   (dcap)      membrane capacitance.
     cplam   0.1           (complam)   fraction of lambda per compartment.
     vrev    -.07 V        (vcl)       battery voltage for leakage cond. 
     vrest   -.07 V        (vrev)      initial startup voltage for cable seg. 
     jnoise   0 (off)      (djnoise)   Johnson noise in membrane resistance
     rsd      set by rseed             random seed for Johnson noise
     density .25 S/cm2  (dnadens)      density of channel in membrane.
             .07 S/cm2  (dkdens)
             .005 S/cm2 (dcadens)

     Na type 0,1    'vrev <expr>' 'density <expr>' 'thresh <expr> 'tau <expr>'
     K  type 0,1,2  'vrev <expr>' 'density <expr>' 'thresh <expr> 'tau <expr>'
     CGMP type 1    'vrev <expr>' 'density <expr>' 'thresh <expr> 'tau <expr>'
     Ca type 0      'vrev <expr>' 'density <expr>' 'thresh <expr>' 'tau <expr>'

     density .25 S/cm2  (dnadens)  density of channel in membrane.
             .07 S/cm2  (dkdens)
             .005 S/cm2 (dcadens)

 
                    = additional voltage-sensitive macroscopic channel
                       conductance in cable membrane.
                       Vrev and density both have default values
                       appropriate for their channel types.
                       Type 0 channels are the HH type and are 
                       taken from Hodkgin and Huxley, 1952.
                       Type 1 channels are the exact sequential 
                       state equivalent to the type 0 channels.
                       See the "chan" statement below for a more 
                       complete description.

     density  .07 S/cm2 (dna)  = density of channel conductance membrane.     
A "cable" statement defines a passive cable segment, normally used to construct the dendritic tree of a neuron. The cable is broken up into compartments, each with the length of the cable's "space constant" multiplied by the value of the parameter "cplam" (default set by the variable "complam", initally 0.1. See "predefined variables"). If the parameter "length" is not defined, the length of the cable is calculated as the distance between the two nodes at the cable ends. The defined length may be different than the distance between the location of its ends.

Each compartment consists of a chunk of membrane, which defines capacitance and leakage values, and internal cytoplasm, which defines axial resistance. A string of connected compartments is created automatically from the cable. The compartments are equal in size except for the two end compartments, which are 1/2 the size of the others. Each compartment is connected to its neighbors with resistors defined by the axial resistances. The membrane capacitance and resistance assigned to the end compartments are added to the capacitance and resistance values of the existing compartments defined for the cable's 2 nodes. If these compartments do not exist yet, they are created new.

Johnson noise

The "jnoise" parameter turns on Johnson (thermal) noise in the membrane. When specified with a cable or sphere it gives the membrane noise equal to:

     noise (std. deviation) = sqrt(4kTBG)

  Where:
         k  = Boltzmann's constant 
         T  = temperature (deg K)
         B  = bandwidth (set to inverse timinc)
         G  = membrane conductance in compartment
To turn on Johnson noise in all compartments, set the global variable "jnoise". Its value is a multiplier for the basal level of noise, i.e. jnoise=10 gives a standard deviation 10 times higher than normal. Each compartment has its own individual random number generator for Johnson noise so turning on "jnoise" does not affect the random sequence of other noise sources.

Note that the amplitude of Johnson noise in a compartment is dependent on the total conductance in the compartment, including all channels and synapses.

Taper

The optional parameter "dia2" specifies a diameter for the second end. If "dia2" is specified, the cable may be tapered, depending on the values specified in "dia" and "dia2". If "dia2" is not specified, the cable has a uniform diameter set by "dia". Note that if a cable is tapered, the compartments created by it will vary in size.


Cable connections

Cables that interconnect at nodes condense their end compartments together. In the case of two cables of the same diameter that are connected together at a node, the 1/2 size end compartments always condense to form one compartment at the node exactly equal to the sum of the other compartments in the cable. If more than 2 cable segments connect at the node, the resulting compartment is a little bigger. When a cable is short enough that no intermediate compartments are necessary, the end compartments are connected by one "ri" resistance. In the case of an extremely short cable segment (less than 0.1 times the space constant for a cable of that diameter) the compartments would be too small and would slow down the model because much more computation is required when compartments are closely coupled.

Compartment condensation

NeuronC by default removes small compartments by "condensing" them with their neighbors into larger compartments. The axial resistor in the connection thus eliminated is partitioned between (and added to) the connections in the new larger compartment. The variable "lamcrit" defines the minimum allowable compartment size, as a fraction of "cplam" (defined compartment size). "Lamcrit" is initialized to 0.3, which means that a compartment gets condensed into its neighbor if the "lamba" (sqrt (rm/ri)) calculated for the compartment is smaller than 0.3 times the value set in "cplam". You can modify "lamcrit" (also -l num on command line) to produce different types of "condensation" behavior. If you want to maintain small compartments, set the variable "lamcrit" to zero ("nc -l 0"). This prevents small compartments from being condensed. After compartments are condensed, channels connected to each compartment are condensed (see "Channel condensation" in "Channel" below). A value of lamcrit of .001 prevents compartments from being condensed but condenses channels.

Recording along cable

If you need to record from within a cable (i.e. not just at its ends) you can use the "V @ cable" statement. This statement finds the nearest two compartments to the location you specify and performs linear interpolation to approximate the voltage. See "Record". Another way, of course would be to make lots short cables and record from the nodes between them.

Diagram of two connected cables and their compartments:

node1 <----------- cable1 ----------> node2       (nodes)

 ^                                      ^
comp1 - comp2 - comp3 - ... compN-1 - compN       (compartments)

1/2      1       1            1        1/2        (comp. sizes) 

                                      these
                                      comps
                                       add     

                     (nodes)          node2 <------ cable2 --- > node3

                                        ^                                                    ^
              (compartments)          comp21 - comp22 - comp23 - ...comp2N 

               (comp. sizes)           1/2        1        1         1/2   


Sphere

at <node> sphere dia <expr> 'params' (same params as cable)

The "sphere" statement defines an isopotential sphere, normally used for the soma or axon terminal of a neuron, that has membrane capacitance and leakage resistance but no internal resistance. Thus it is basically a shunting impedance. The values of resistance and capacitance are derived from the surface area of the sphere and the appropriate definition of membrane capacitance and resistance (default or specified). A sphere connects to 1 node, thus the resistance and capacitance are added to the compartment defined for the node. Macroscopic channel conductances are available for spheres just as for cables.


Synapse statement

Click here to return to NeuronC Statements

Synapse

conn <node> to <node> synapse 'parameters'
 optional parameters:    default:           meaning:
--------------------------------------------------------
    open | close          open             Neurotrans opens or closes chans.
    linear = <expr>  |    expon            can be either linear or expon
      expon= <expr>        5 mv            exponential const (1/b) (mvolt)
    vrev   = <expr>     -.00 V   (vna, vk) reversal pot. (battery) (Volts)
    thresh = <expr>     -.05 V   (dst)     threshold for transfer  (Volts)
    cgain  = <expr>      1       (dsc)     synaptic cycG gain (after sat.)
    nfilt1 = <expr>      2       (dsfa)    number of presynaptic filters.
    timec1 = <expr>      .2 msec (dfta)    synaptic low pass filter (msec).
    timec1h= <expr>      1 msec (dftah)    synaptic high pass filter (msec).
    nfilt1h= <expr>      0                 no. of presyn. high pass filters.
    nfilt2 = <expr>      1       (dsfa)    no. of filters after nt release.
    timec2 = <expr>      .2 msec (dfta)    synaptic low pass filter (msec).
    tfall2 = <expr>      timec2            tau for falling phase (msec).
    nfilt3 = <expr>      0                 no. of filts for cond. after binding.
    timec3 = <expr>      0 msec            conductance low pass filter (msec).
    tfall3 = <expr>      timec3            tau for falling phase (msec).
    kd     = <expr>      1       (dskd)    saturation point: cond/(cond+kd)
    hcof   = <expr>      1       (dshc)    Hill coefficient: cond^h/(cond^h+kd^h)
    trconc = <expr>      1e-3 M  (dstr)    Transmitter conc factor for AMPA, etc.(Molar)
    maxcond= <expr>      200e-12 S(dmaxsyn) Conductance when chans fully open (Siemens)
    mesgout cyca                            synapse controls local cyca level.
    mesgout cycg                            synapse controls local cycg level.

    resp                                    Postsyn sequential-state receptors.
      AMPA                                  AMPA receptor with desensitization.
      NMDA                                  NMDA receptor with voltage-sens.
      GABA                                  GABA receptor.
      cGMP                                  cGMP receptor.
      SYN2                                  Simple 2-state channel.
      <chanparm> = <expr>                   "vrev", "offsetm/h", "taum/h", "chnoise", etc.
                                              (params taken from "channel")

   chnoise = <expr>     0 (off)             = 1 -> define chan noise (after "resp")
     N     = <expr>     100       (dscn)    number of channels
     unit  = <expr>     50e-12    (dscu)    unitary channel conductance
     taud  = <expr>     1         (dsyntau) rel. time const for noise (abs=.001)
     rsd   = <expr>     set by rseed        random seed

  vesnoise = <expr>     0 (off)             = 1 -> define vesicle noise
     N     = <expr>     5         (dsvn)    number of vesicle release sites
     vsize = <expr>     100       (dvsz)    size of vesicles released 
     rsd   = <expr>     set by rseed        random seed
     CoV   = <expr>     Poisson             mult * stdev / mean ves rate 
     refr  = <expr>     0 sec               minimum time betw vesicle release

Synaptic time step

A synapse consists of separable amplitude and time functions which modify the signal passing through them. Since the calculations involved in these synaptic functions may in some cases be lengthy, they are performed at a timestep set by "stiminc" (default=1e-4) which is coarse enough that they normally take only a small fraction of the simulation CPU run time. If you need more time resolution you can set "stiminc" to be smaller, e.g. the same value as the basic integration timestep ("timinc").

1) Presynaptic delay function

1) A presynaptic delay function represents delay between a change in presynaptic voltage and neurotransmitter release. The function consists of up to 4 variable "resistor-capacitor" filter stages in series. The signal from one filter is passed to the input of the next, and these may have the same time constant (set with "timec1") or can be different (see below). The last filter sends its signal to the static transfer function, described as 2) below. This filter is useful for defining a synaptic delay that does not affect the properties of the (optional) vesicle noise. There are 2 parameters, the number of filters ("nfilt1"), and the time constant for the filters ("timec1").

Each filter (from 1 to 4) is represented by the following equation:

Each stage is described by:

      Vout (t+1) = Vout (t) +  (Vin (t) - Vout(t)) * (1 - e-t/tau)
where:
           Vout = output of delay filter.
            Vin = input to filter. 
              t = time in increments of basic timestep      
            tau = time constant of filter (timec1) in increments of timestep.
To minimize the lowpass filter effect of this function, use a short time constant. To maximize delay use all 4 filters. Total time delay is approximately equal to the sum of the individual time constants. The default setting is 2 filters with 0.2 msec time constants. If the time step is 1 sec. or greater, then the low-pass filter is removed and the synapse becomes a static transfer function.

The signal that passes through the presynaptic delay function represents the steps that lead to transmitter release such as calcium entry and vesicle fusion. The signal that is actually filtered in this function represents the voltage above threshold, and so may range from -100 mV to 100 mV. The static release function 2) below converts this voltage into transmitter released. The signal values in the presynaptic filters may be recorded using the "FA0-4" notation (see "record").

It is possible to set several different time constants in any of the filters, with a different form of the "timec" parameter, for example, for 2 5-msec delays and 1 2-msec delay:

    timec1 [5 5 1]
Defaults

The presynaptic delay function is set by default to 2 filters of 0.2 msec time constant. If the time step is 1 sec. or greater, then the low-pass filter is removed and the synapse becomes a static transfer function.

Speeding up the synapse to save time

During equilibration of large neural circuits that include feedback, it can cause perturbations of a neural circuit's voltage signals that last a long time, even when there is no stimulus. The problem is that in a circuit with nonlinear elements, it's difficult to compute all the resting potentials before the simulation runs. To save CPU time, you can set the synapses to run faster during equilibrium, and then slow them down during the rest of the simulation. Use the global variable "synaptau" to set the time constant (=1 -> normal, =.01 -> faster):

    conn 1 to 2 synapse ...
    synaptau = .01;
    step .05;                         ( set 50 msec for equilibration )
    synaptau = 1;
    run; 
Click here to return to Synapse statement index

Synaptic transfer function

A transfer function which converts from mvolts at the presynaptic node to a normalized "transmitter" level. Transmitter is shut off at the synapse's "threshold", which is normally set between -50 and -20 mv. There are two types of transfer function for transmitter release, linear and exponential. Transmitter release levels are computed every 0.1 msec (1e-4 sec) which is the standard time increment used for numerical integration in NeuronC.

Linear transfer

Synaptic gain is specified by the value of the "linear" parameter. When set to 1.0, the neurotransmitter released is 1 for a presynaptic voltage of 100 mv above threshold. This value of Trel=1 half-saturates the saturation function (see below). For voltages less than the threshold, no transmitter is released. Larger values reduce the range over which the input voltage operates, i.e. a value of 2 increases the synaptic gain so that 50 mv above threshold releases transmitter of 1.

       Trel = 0.01 * (Vpre - Vthresh)  * gain                        (1)
where:
       Trel = transmitter released to postsynaptic receptor.
                    (limited to be non-negative)
       Vpre = presynaptic voltage (normalized to mv).
    Vthresh = synaptic threshold (normalized to mv).
       gain = linear transfer gain. 
Exponential transfer

The transfer function may also be exponential, defined by the equation

       Trel = .025 * e(Vpre-Vthresh)/expon                       (2)
where:
       Trel = transmitter released, delayed to postsynaptic receptor.
       Vpre = presynaptic voltage (mv).
    Vthresh = synaptic threshold (mv).
      expon = constant defining mvolts per e-fold increase (1/b). 
 
     Reference: Belgum and Copenhagen, 1988
For exponential transfer, the transmitter released is equal to the exponential function of the presynaptic voltage above threshold. The value of "expon" sets how many millivolts cause an e-fold increase in transmitter release. Exponential release implies a gradual increase with voltage, and it also implies that release is gradually shut off below the threshold voltage. A synapse with exponential release may require a presynaptic voltage 10 to 20 mv. below threshold to extinguish transmitter release.

Note that "Trel", the signal representing released neurotransmitter, normally ranges from 0 to 1, or greater for saturation (maximum=1000). These values are "normalized" so that a value of Trel=1, when passed through the saturation function 5) below, causes a conductance of 0.5 of the maximum conductance ("maxcond"). Thus a value of Trel=5 is necessary to reach 80% of the maximum conductance.

3) Click here to return to Synapse statement index

Synaptic vesicle noise

3) Vesicle noise is defined by two parameters, the number of release sites (N), and the amplitude of a vesicle release event (size). The number of vesicles released is a random function (binomial deviation) of the probability of release at each release site and the number of sites. Quantal release probability is calculated with the following equations:
          p = Trel / (size * N)
          q = binom(p,N)
     Tnoise = q * size 
 
where:
          p = probability of release.
       Trel = transmitter released (amount / 100 usec timestep; 1=half-sat).
       size = size of release events (1=half saturating). 
          q = number of quantal vesicles released per time step.
          N = number of release sites.
      binom = random binomial deviation funtion of p, n.
     Tnoise = transmitter released (Trel) with noise.

     Reference: Korn, et al., 1982.
 
For a given amount of transmitter released (Trel) (and therefore a given postsynaptic conductance) the "size" parameter affects the size of quantal vesicles released. A higher value of "size" means a lower probability of a vesicle being released per time step which implies fewer quantal vesicles released and but larger vesicle size. Changing "size" does not change the average amount of transmitter released. The only other parameters affected by "size" are vesicle rate and "amount" of noise.

The "size" parameter sets the amount of neurotransmitter in a vesicle released in a 100 usec timestep (the timestep used in calculating synaptic noise). Normally one doesn't want a vesicle's effect to disappear so quickly so one sets the vesicle duration by setting the time constant of the filter between neurotransmitter release and saturation (i.e. the "second" filter).

When setting "size", remember that a vesicle size of 1 means a the vesicle will produce a 1/2 max. conductance for a 100 usec timestep if there is no low-pass filter activated. When a low- pass filter is activated (nfilt2,timec2), the "energy" of the vesicle is maintained, i.e. its duration is increased and its amplitude is decreased. If you want to set the size of the vesicle after filtering, multiply the "size" by the time constant of the filter in 100 usec steps. For example, a size of 100 is required to produce a 1/2 max conductance with a filter time constant of 10 msec (i.e. (10 msec)/(100 usec) = 100).

The instantaneous rate of neurotransmitter release is always a function of synaptic activation (i.e. presynaptic voltage and gain). Since the "size" parameter also affects the rate of release of vesicles, normally during the course of testing a simulation one chooses a "size" that gives correct vesicle release rate (i.e. rate at 1/2 max total conductance). To lower the release rate without changing the vesicle size one changes the synaptic gain, normally the "expon" parameter. This affects probability of release (and therefore postsynaptic conductance) but not vesicle size or the vesicle rate necessary to produce a 1/2 max conductance.

The "N" parameter describes the number of independent release sites for the purpose of the noise computation but does not affect conductance. The effect of varying N is noticeable only when the probability of releasing a vesicle is high (i.e. when N is small and Trel is high), and this normally happens only when the release rate is higher than 1000/sec/synapse. The maximum rate of release is set (internally by the simulator) to 10 vesicles/release site/timestep (100 usec), a value that should never be reached in practice. When release rates are lower than this (the usual case) the timing of release is "Poisson", meaning that the standard deviation of the rate (i.e. its "noise") is proportional to the square root of the mean. When N is set to zero, noise is turned off.

Note that saturation can affect a noisy synaptic signal differently than one without noise: the high amplitude noise peaks may saturate and cause the signal mean to be lower than a similar synapse without noise. To minimize this effect, 1) add filters at stage 2 to reduce fluctuation noise, or 2) reduce the amount of saturation by decreasing gain and increasing synaptic conductance ("maxcond").

Click here to return to Synapse statement index

Setting random seed for synapse

The noise function is computed using a (pseudo-) random number generator compiled into NeuronC. The random sequence is started off by a number called a "seed" that completely determines the sequence. You can change the sequence (randomly) to another different random sequence by giving an alternate seed, either by setting the "rseed" variable ("rseed=42") or with a command line switch for nc ("nc -r 42"). A given seed will always produce the same "random" sequence so it is possible to repeat an experiment several times with the same exact noise sequence. Alternately, it is possible to randomize the seed so that it is different each time. To do this, set the command-line seed to a negative number ("nc -r -1") and the actual seed used is set by the UNIX process number. In this case, the actual seed value for a run is printed in the output file (in text mode) so that if necessary the run may be repeated later with the same seed value.

Note that multiple synapses with random noise will not affect each other, even though their sequences are set from the main random sequence "rseed". If you want to change one synapse's sequence without changing any others, you can set the pseudo-random sequence for that each synapse with the "rsd" parameter. When set, the "rsd = <expr> parameter keeps the random noise sequence constant for the synapse. The vesicle and channel noises can be initialized separately. Any synapses (or vesicle or channel noise generators within any synapses) that are not initilized with "rsd" are set by the overall "rseed" random number seed.

The "CoV" parameter causes vesicle release to be more regular than Poisson (which otherwise is the default behavior). This is accomplished with the "gamma distribution" of order "a" which is equivalent to waiting for "a" events from the unit Poisson distribution (i.e. an exponential distribution of random intervals). A large value for the order "a" causes the release to be more regular. For example, if you set CoV=0.2, the vesicle release is set to a gamma distribution with order 25, which causes the standard deviation to be reduced by a factor of 5. Since the vesicle release rate is set by the simulator from the presynaptic voltage and the neurotransmitter release function, you only control the relative "regularity" of release with CoV, not the absolute regularity, exact standard deviation, or mean rate. Note that release is more regular with higher rates.

The "refr" parameter is an alternate way to specify regularity in vesicle release. It is specified in seconds and if non-zero it causes an absolute refractory period to be set up so that no vesicles are released during that period after each vesicle event. This causes release at high rates to be more regular than at low rates. Note that release will stop if the refractory period is equal to the mean period between vesicle events.

Click here to return to Synapse statement index

4) Post-release delay function for release neurotransmitter

4) The neurotransmitter signal is passed through a second delay function that represents the delay between release at the presynaptic membrane and binding at postsynaptic receptors. The function also slows the rate of rise and fall of neurotransmitter binding to the post- synaptic receptor. The function is identical to the first one described above: it consists of up to 4 variable "resistor-capacitor" filters in series. As in the first delay function, the filters may use the same time constant or can be set to different time constants. In addition, the last filter in the series has an optional falling phase time constant that allows the duration of neurotransmitter action to be prolonged. The last filter connects to the static saturation function, described in 5) below.

The signal that passes through the post-release delay function represents the "neurotransmitter" released by the presynaptic terminal. This signal normally ranges from 0 to 1, or greater when saturated (up to 100 max), where a value of 1 is half-saturated (see saturation in 5) below. The signal values in the filters may be recorded using the "FB0-4" notation (see "record").

This delay function is useful for defining a delay that affects the properties of the (optional) vesicle noise. There are 3 parameters, the number of filters ("nfilt2"), the time constant for the filters ("timec2"), and the optional falling phase parameter ("tfall"). To minimize the lowpass filter effect of this function, use a short time constant. To maximize delay, use all 4 filters. To pass all frequencies but maximize delay, use a short time constant with all 4 filters.

Each filter (from 1 to 4) is represented by the following equation:

  Tdel (t+1) = Tdel (t) + (Trel (t) - Tdel(t)) * 0.63(1/tau) / tau
where:
      
       Tdel = output of delay filter.
       Trel = input to filter. 
          t = time in increments of basic timestep      
        tau = time constant of filter (timec2) in increments of timestep. 
Falling phase tau

To use the optional falling phase, set the "tfall" parameter to the time constant you want for neurotransmitter removal. This time constant replaces the falling phase time constant in the last filter and gives an exponential decay to neurotransmitter action.

Note: nonlinear interactions with delay function

Note that if the synapse is set up for substantial saturation (Trel > 5), any low-pass "averaging" filtering action in the post-release filter function will interact with the saturation in a "non-intuitive" nonlinear fashion. For example, if the function is given 1 msec delay, a large presynaptic signal may cause the post-synaptic signal to rise quickly (because the initial rise to saturation happens in less than 1 msec) but to fall with 5-10 msec delay because the "averaged" filtered signal keeps the synapse saturated even while the filter output is falling.

Defaults

The postsynaptic delay function is set by default to 0 filters (no filter) with 0.2 msec time constant. If the time step is 1 sec. or greater, then the low-pass filter is removed and the synapse becomes a static transfer function.

Click here to return to Synapse statement index

5) Binding of transmitter to postsynaptic receptor: saturation

Transmitter levels delivered from the second delay function are passed through a Michaelis-Menten saturation function, modified by raising the quantities to a power with a Hill coefficient:
      Rbound = Tdel^h / (Tdel^h + kd^h)                        (3) 
where:
      Rbound = Fraction of receptors bound with transmitter.
        Tdel = transmitter (delayed and filtered Trel). 
          kd = binding constant for synaptic saturation. (default = 1)
           h = Hill coefficient, representing cooperativity.
The released transmitter, delayed and averaged, is delivered to the saturation function which allows the conductance of the postsynaptic membrane to be limited to the maximum defined by the "maxcond" parameter. The default value for the binding constant (kd) is 1, so saturation occurs when the transmitter released is greater than 1, defined in equations (1) and (2) above. For a linear synapse, saturation normally occurs with the default parameters only for presynaptic voltages greater than 100 mv above threshold, but this is dependent on both "gain" and "kd". To change the level of presynaptic voltage at which saturation occurs, increase "gain". For an exponential synapse, the saturation occurs at a presynaptic level dependent on "gain", "expon", and "kd". The Hill coefficient, defined by the "hcof" parameter, represents the number of molecules of neurotransmitter that must be bound to a receptor for it to be activated, and describes the "degree of cooperativity". A Hill coefficient greater than 1 gives the saturation curve an S-shape, which means a "toe" at low concentrations of neurotransmitter, and a steeper slope in the mid-portion of the curve. Typical Hill coefficients are 2 or 3, although commonly a non-integer Hill coefficient is reported when measured from a pharmacological preparation.

Click here to return to Synapse statement index

6) Effect of synaptic transmitter

At many synapses, transmitter bound to postsynaptic channel receptors opens the channels. However, depolarizing bipolars in retina have channels that close with neurotransmitter release (Nawy and Copenhagen, 1987; Attwell ^Set al^S, 1987, Shiells and Falk, 1994). These synapses have "metabotropic" postsynaptic mechanisms with a sign-inverting biochemical cascade. NeuronC describes this action with the keyword "close" when used in the "synapse" statement. For these channels, the postsynaptic conductance is:

      Gcyc = (1 - Rbound * cgain)                         (5)
      Gcyc >= 0
      Gpost = Gcyc / (Gcyc + gkd) * (1 + gkd) * maxcond

      where the default level of gkd is set by "dgkd" (default 0.1)
If the neurotransmitter action at the synapse has been set to "close", the "cgain" parameter represents the biochemical gain that couples bound receptors to the closing of membrane channels. Amplification in the biochemical cascade after saturation (i.e. cgain > 0) reduces the effect of saturation near the point where all the channels are closed. Gain may be very high at such a synapse with modest values of cgain (e.g. voltage gain = 100). The intermediate parameter "Gcyc" represents the level of second-messenger that binds to the membrane ion channel. Note that the value of "Gpost" above is limited to the range 0 to 1.

The default action for neurotransmitter in NeuronC is to open channels, but this may be explicitly stated with the keyword "open". If a "resp cGMP" is added in the parameter list after the "synapse" keyword, a cGMP channel becomes the output for the synapse's action:

      ... synapse close maxcond=1e-9 resp cGMP chnoise=1
This would generate a synapse in which neurotransmitter closed a cGMP channel through a second-messenger system, with 40 channels having a unitary conductance of 25 pS (default for cGMP).

Click here to return to Synapse statement index

7) Postsynaptic delay function

After saturation, the neurotransmitter conductance is passed through a third delay function that represents the delay between transmitter binding at the postsynaptic receptor and ion channel activity. The function is identical to the first and second filter functions described above: it consists of up to 4 variable "resistor-capacitor" filters in series. As in the first and second delay functions, the filters may use the same time constant or can be set with different time constants. In addition, the last filter in the series has an optional falling phase time constant that allows the duration of channel action to be prolonged. The last filter connects to the synaptic conductance in the postsynaptic compartment.

The signal that passes through the post-saturation delay function represents normalized conductance and ranges from 0 to 1. The signal values in the filters may be recorded using the "FC0-4" notation (see "record").

This delay function is useful for defining a delay that affects both (optional) vesicle noise and (optional) channel noise. There are 3 parameters, the number of filters ("nfilt3"), the time constant for the filters ("timec3"), and the optional falling phase parameter ("tfall"). To minimize the lowpass filter effect of this function, use a short time constant. To maximize delay, use all 4 filters.

Each filter (from 1 to 4) is represented by the following equation:

  Gdel(t+1) = Gdel(t) + (Gi(t) - Gdel(t)) * 0.63(1/tau) / tau
where:
       Gdel = output of delay filter, goes to "Reversal Potential" below.
         Gi = input to filter, from Gpost above or previous filter. 
          t = time in increments of basic timestep      
        tau = time constant of filter (timec3) in increments of timestep 
Falling phase tau

To use the optional falling phase, set the "tfall" parameter to the time constant you want for neurotransmitter removal. This time constant replaces the falling phase time constant in the last filter and gives an exponential decay to neurotransmitter action.

Defaults

The postsynaptic delay function is set by default to 0 filters (no filter). If the time step is 1 sec. or greater, then the low-pass filter is removed and the synapse becomes a static transfer function.

Click here to return to Synapse statement index

8) Postsynaptic Markov sequential state function.

Instead of the standard postsynaptic response function (synaptic action, postsynaptic delay) you can give the "resp" keyword and add the "AMPA", "NMDA", "GABA", "cGMP" or "syn2" keywords to implement a sequential-state Markov function for the postsynaptic receptor. The Markov function gives the AMPA receptor (based on Jonas et al. 1993) the ability to have desensitization as a function of neurotransmitter binding, and it gives the NMDA receptor sensitivity to voltage and neurotransmitter. The cGMP channel is a rod outer segment channel (based on Taylor & Baylor 1995) and can work from the local cGMP concentration (i.e. from "mesgout" at the synapse) as a membrane channel or as part of the synapse (after "resp"). The "syn2" channel is a simple 2-state Markov channel that has a default 0.001 sec time constant.

The sequential state Markov function for AMPA and NMDA channels is placed between neurotransmitter concentration (i.e. temporal filter 2) and channel opening. The cGMP Markov function is placed after postsynaptic binding and the third temporal filter. Calibration of the absolute concentration of neurotransmitter at the postsynaptic receptor is set by the "trconc" parameter. During the simulation, the actual concentration is computed by multiplying "trconc" by the output of the second temporal filter. The level of neurotransmitter bound to the receptor drives the Markov function through the rate constants which are functions of neurotransmitter. (In the NMDA receptor, they're also functions of voltage). Output from the Markov function drives the postsynaptic channels. When channel noise is added to a Markov channel, the kinetics of channel opening and closing are set by the Markov state transitions but can be tuned with the "taua-taud" parameters (see below).

Channel noise can be defined without the "resp" keyword. When this is done a "syn2" channel is created automatically. This example defines a synapse that opens a 2-state Markov channel with 20 channels (with a default unitary conductance of 25 pS):

    ... synapse ... open chnoise=1 N=20
Note that the "N" and "unit" parameters can be placed before, without, or after "chnoise". If placed before "chnoise", they define the conductance of the channel. If placed after chnoise, they define only the noise properties of the channel, not its conductance:

    ... synapse ... open N=20 chnoise=1
You can modify the behavior of the Markov functions with the "tau" and "offset" parameters (similar to those in "channel"): "offset" defines a voltage to be added to the membrane voltage for the NMDA channel, and "tau" defines a multiplier for the rate constants. You can separately specify "taum" (activation) and "tauh" (inactivation) for some channels and "taua-taud" provide a way to tune 4 separate rate functions.

Click here to return to Synapse statement index

9) Synaptic channel noise

Channel noise is implemented by a "Markov" sequential-state channel to the postsynaptic response of the synapse. Noise is defined by several parameters, one describing the number of channels ("N"), another describing the unitary conductance ("unit"), and a "tau" (time constant) that describes how fast the noise goes.

The "unit" parameter describes the unitary conductance of a single channel and allows the simulator to calculate the number of channels from the maximum total conductance "maxcond". If you specify a value for "N", the value of "unit" is ignored, otherwise, the total number of channels is calculated as:

          N = maxcond / unit
The "N" parameter describes the number of independent channels for the purpose of the noise computation but does not affect conductance. The instantaneous number of open channels is a random function (binomial deviation) of the probability of each channel opening and the number of channels. Defaults for "unit" (the unitary conductance) are:

   
   dscu = 25e-12   @22       default 2-state synaptic channel
   dampau=25e-12   @22       default AMPA unitary conductance
   dcgmpu=25e-12   @22       default cGMP unitary conductance

   dnau  = 12e-12  @6.3     default Na unitary cond, gives 20 pS @ 22 deg
   dku   = 12e-12  @6.3     default K unitary conductance
   dkau  = 12e-12  @6.3     default KA unitary conductance
   dkcabu= 44e-12  @6.3     default BKCa unitary cond, gives 115 pS @ 35 deg
   dkcasu= 8.4e-12 @6.3     default SKCa unitary cond, gives  22 pS @ 35 deg
Note that the default unitary conductances have a temperature coefficient, set by the Q10 for channel conductance "dqc" (default = 1.4). The base temperature at which the unitary conductance is defined is set by the "qt" field of the channel constants. For HH-type rate functions, the base temperature is normally 6.3 deg C, and for synapses it is often 22 deg C. For more details, look in "Adding New Channels".

Click here to return to Synapse statement index

10) Channel noise and time constant

Changing the time constant for a channel affects the level of noise in the postsynaptic membrane. A greater time constant means a lower probability of opening per time step which means fewer openings and more noise (relative to the mean open level). The channel conductance signal is normalized so that changing the time constant does not change its average value. The frequency spectrum of the noise is low-pass filtered by the time step so the spectrum may not be affected much by the exact value of the time constant.

The time constant controls the frequency spectrum of the channel noise. The default time constant for the "syn2" simple 2-state channel is 1 ms and this can be changed (multiplied) with the "taud" parameter. The time constant defines a noise event with an average single exponential time course (single Lorenzian), whose "roll-off" frequency is:

          fc = 1 / ( 2 * PI * tau)
The power spectral density at frequency = fc is half of that at lower frequencies.

See the description of vesicle noise above for a discussion of the random "seed" and how to change it.

Click here to return to Synapse statement index

11) Synaptic conductance

The postsynaptic conductance is the product of the saturated transmitter bound and the maximum synaptic conductance:
      Gpost = G * maxcond                        (4)
where:
      Gpost = postsynaptic conductance.
          G = Fraction of receptors bound, after saturation and noise.
    maxcond = maximum postsynaptic conductance 
               (default = 1e-8 S)
The fraction receptor bound is always less than 1, so the postsynaptic conductance can only approach the level specified by "maxcond". The instantaneous conductance may be recorded with the "G0" notation (see "record").

Click here to return to Synapse statement index

12) Synaptic reversal potential

The postsynaptic potential is produced by a voltage source (battery) in series with the postsynaptic conductance. The battery voltage is defined by the "vrev" parameter, and this can be any physiological voltage. Excitatory synapses need a more positive (depolarized) battery than the normal resting potential in the postsynaptic cell, and this is normally set at 0 to -20 mv. Inhibitory synapses have a more negative (hyperpolarized) voltage source, normally set at -60 to -80 mv.

The post-synaptic current reverses when the intracellular voltage passes above or below the synaptic battery potential; thus the name "reversal potential".

       Ipost = (Vcell - Vrev) * Gdel
where:
       Ipost = postsynaptic current
       Vcell = intracellular voltage
        Vrev = reversal (battery) voltage for synapse
        Gdel = postsynaptic conductance, (Gpost delayed)
Click here to return to Synapse statement index

13) Postsynaptic second messenger

A postsynaptic second-messenger can be specified with the "mesgout cyca/g" option. When this option is given, a new compartment is created to hold the concentration level for the second-messenger. The value is derived from the synapse's normalized conductance value (ranging from 0 to 1). This value can then be accessed as a modulating factor by other neural mechanisms, such as the "gap junction" below.

If you specify a cGMP-gated postsynaptic channel with the "resp" option it will automatically receive its signal from the synapse in the same manner as if you use the "mesgout" option and a separate "chan cGMP" statement.

Note that the third temporal filter can approximate the low-pass filtering action of a second-messenger without the need to specify one with the "mesgout" option (see "Postsynaptic delay function" above).

Click here to return to Synapse statement index

Gap junction

conn <node> to <node> gj <expr> 'parameters'

   parameters:     units:   default:      meaning:
   
   gj <expr>       S                      conductance of gap junction.
   area  = <expr>  um2                    membrane area of gap junction (alt.).
   dia   = <expr>  um                     diameter of gap junc(alt. to area).
   rg    = <expr>  Ohm-um2 5e6 (drg)      specific resistance of gj membrane.
   vgain = <expr>  mV      1.0            evolts per e-fold change in rate.
   offset= <expr>  V       1.0 (dgjoff)   offset voltage.
   taun  = <expr>  ratio   1.0 (dgjtau)   multiplier for time constant.
   gmax  = <expr>  S                      conductance of gap junction. 
   gnv   = <expr>  ratio   0.2 (dgjnv)    non-voltage-sensitive fraction.
   rev 'params'                             rectifying params for neg voltage.
   mesgin cyca                              modulation by cycA at local node.
   mesgin cycg                              modulation by cycG at local node.
   mesgin cycg <node>                       modulation by cycA from remote node.
   mesgin cycg <node>                       modulation by cycG from remote node.
   mesgin 'params' open   (close)           cycA/G opens the gj channel.    
   mesgin 'params' close  (default)         cycA/G closes the gj channel.
 
A gap junction is implemented as a resistive connection between two nodes, much like the connection between compartments along the length of a cable. Its conductance can change as a function of the cross-junctional voltage. The change is small and slow in response to a voltage step of less than 10 mV, but increasingly strong and rapid above 15 mV. The maximum conductance can be defined immediately after the keyword "gj" (in Siemens), or alternately can be defined by its area, or diameter. Optional parameters define the specific resistance, defined in units of ohm-um2 (default 5e6 ohm-um2), voltage gain ("vgain"), the number of mV per e-fold change in rate, and the time constant "taun", which changes the opening and closing rates proportionately. The opening and closing rates are also influenced by temperature (set by "tempcel") with a Q10 of 3, in a manner similar to other membrane channels (Hodgkin and Huxley, 1952). To disable the voltage sensitivity, set the Gmin/Gmax ratio ("gnv") to 1.0, or set its default ("dgjnv") to 1.0.
   alpha = tempcoeff * taun * exp(-Aa * (vj - offset) / vgain);
   beta  = tempcoeff * taun * exp( Ab * (vj - offset) / vgain);

   n += -beta * n + alpha * (1.0 - n) * t;
   Ggj = (gnv + n * (1.0-gnv)) * (1.0-cyc)

Where:  tempcoeff = temperature coefficient determined by Q10 of 3.
        Aa = power coefficient for alpha
        Ab = power coefficient for beta
        t  = time increment for synapses (always 100 usec).
        n  = normalized voltage-gated conductance from 0 to 1.0.
        gnv = non-voltage-gated fraction, from 0 to 1.0
        cyc = level of cyclic nucleotide "second-messenger".
        Ggj = normalized total gap junction conductance.
For details on the voltage gating properties, see Harris, Spray, Bennett, J. Gen Physiol. 77:95-117, 1981.

The "reverse" parameters are vgain, offset, and taun. If any of these are set, the gap junction is effectively split in half with the forward parameters defined before the "rev" keyword, and the reverse parameters defined after the "rev" keyword. In this case, the reverse parameters are used when the voltage across the gap junction is negative. Defaults for the reverse parameters are specified by the forward ones.

The "cyca" and "cycg" parameters set modulation by these second- messengers. If no node is specified, the second-messenger levels at both nodes connected by the gap junction will influence the gap junction conductance. When a node is specified for the second messenger, the gap junction is modulated by second-messenger at only that single node.

Click here to return to NeuronC Statements

Photoreceptor statement

Click here to return to NeuronC Statements

Photoreceptor parameters and defaults

at <node>; rod  (<xloc>,<yloc>) 'parameters'
at <node> cone (<xloc>,<yloc>) 'parameters'
at <node> transducer (<xloc>,<yloc>) 'parameters'
optional parameters:
                    units:  default:

  <xloc>,<yloc>     um                 location of receptor in (x,y) plane.
  maxcond=<expr>    S       1.4e-9 S   dark cond of light-modulated channels.
  dia   = <expr>      um      2 um     dia of receptor used for phot. flux.
  pigm  = <expr>              1        0=rod, 1-3=cone l,m,s. 4,5,6 = turtle l,m,s.
  pathl = <expr>      um      35 um    path length for light through receptor
  attf  = <expr>             .9        light attenuation factor (lens, etc.)
  filt  = <expr>              0        0=none; 1=macular pigm, 2=lens, 3=macular+lens
  timec1= <expr>              1.0      time constant multiplier. 
  photnoise = <expr>          0        1=on. Poisson photon noise from light flux.
  darknoise = <expr>          0        0-1, frac. of Gaussian continuous noise.
  rsd   = <expr>      set by node #    Individual random seed, -1 -> set by rseed
  save                                 save current values for later "restore"
  restore                              restore values from previous "save"
A rod or cone photoreceptor is a transduction mechanism which responds to light and modulates a channel with certain gain, saturation, and time properties. The channel is added (in parallel) to the membrane properties for the compartment of the node which the receptor connects.

A transducer photoreceptor converts a light stimulus directly into a voltage that it injects (through a voltage clamp) into the node's compartment. Otherwise it is similar to the rod and cone photoreceptors.

Click here to return to Photoreceptor statement index

Description of photoreceptor parameters

Each photoreceptor has an (x,y) location (calibrated in um) so that it can receive a stimulus. The receptor receives a photon flux calculated by multiplying its area (calculated from the diameter, default 2 um) times the intensity of the stimulus for that location. The photon flux can be an average value (i.e. without photon noise; default) or may define a random number of quantal photon absorptions (set by "photnoise=1"). In addition, the "darknoise" parameter controls how much continuous noise is added into the photoreceptor's dark current. When darknoise is set to 0.2, the single-photon signal/noise ratio is 5, about what has been measured in mammalian rods (see Baylor et al., 1984).

Click here to return to Photoreceptor statement index

Setting random seed

One very convenient feature of "pseudo-random" noise in "nc" is that you can turn it off and on to explore its effect. One problem with this feature is that multiple photoreceptors whose noise originates from the same noise generator will affect each other's noise, so that 1) changing the light intensity for one photoreceptor will change the noise that other photoreceptors receive, and 2) adding a new photoreceptor will also change the noise that the others receive. To prevent this problem, photoreceptors have (by default) separate noise generators for photon noise and dark continuous noise that are initialized by their node numbers, which are assumed to be unique to each photoreceptor. In normal use, this maintains a precisely constant noise stream for each photoreceptor. To allow you to change the photoreceptor noise sequence while maintaining a different noise for each one, you can change the "prseed" global variable. This seed modifies the random sequence supplied by the default photoreceptor noise generator but has a default value so you normally need not modify it. If you specify a negative number for "prseed", its value is taken from the overall random number seed "rseed" variable (which can be set in several ways, see "rseed"). In this case, the photoreceptor's noise interacts with other random events as described above.

If you would prefer to set each noise generator, you can independently set the pseudo-random sequence that each photoreceptor receives with the "rsd" parameter. When set, the "rsd = " parameter initializes a separate noise generator for each photoreceptor. If you set "rsd" to -1, then that photoreceptor is initialized by the overall random number seed "rseed" as described above.

Click here to return to Photoreceptor statement index

Aperture and spatial filtering

For simplicity of computation, a photoreceptor is a "point receiver", i.e. for the purposes of spatial summation it has an aperture of zero. The diameter used to calculate photon flux does not imply an additional convolution beyond the convolution for optical blur. For many simulations, this is not a problem because the diameter of optical blur is substantially greater then the photoreceptor aperture. In this case, an aperture would add a negligible spread to the optical blur point-spread function.

To specify a non-zero aperture for simulating low-pass spatial filtering, you can add the effect of the aperture to either the stimulus or the optical blur. For instance, if you are using a point-source stimulus (with or without blur), enlarging the point-source into a spot the size of the photoreceptor aperture simulates the spatial-filtering effect of the aperture in the photoreceptor. Alternately, if the optical blur Gaussian is at least twice the diameter (at 1/e) of the aperture, you can "pre-convolve" the optical blur with the aperture. This can be accomplished using either a separate convolution algorithm or the "root-mean- square rule" for convolution of 2 Gaussians (the resulting Gaussian diameter is the square root of the sum of the squares of the two constituent Gaussian diameters).

Click here to return to Photoreceptor statement index

Save, restore
When repeating a stimulus several times during a simulation, it is often useful to "reset" a simulation's state to what it was before the stimulus. The "save" parameter causes the photoreceptor to save the current values of its internal biochemical difference equations. Later, a duplicate photoreceptor statement with the "restore" parameter set causes the photoreceptor to retrieve the previously stored values immediately. In order to access the original photoreceptor, the "save" and "restore" parameters must be used with the "ename" and "modify" commands.

Example:

     dim ncone [100];

     at n cone (50,0) attf .75 ename ncone[i];
     .
     .
     .
     modify ncone[i] cone () save; 
     code for stimulus here.
     .
     step xtime;
     .
     code for recording response here.
     .
     modify ncone[i] cone () restore;
The element number of the original photoreceptor is saved in the array "ncone[]" and this number is used to access the element later in the program. The "save" is placed just before the stimulus, and the "restore" is placed just after the response has been recorded.

Click here to return to Photoreceptor statement index

Difference equations

The photon flux is the input to a set of difference equations which are derived from the transduction scheme of Nikonov et al (1998). This transduction mechanism simulates the initial phase of the biochemical cascade from rhodopsin through G-proteins to phospodiesterase, cyclic-G and finally the light-modulated conductance. In addition there are 4 difference equations which simulate the calcium-feedback control of the recovery phase (see Nikonov et al. 1998). These difference equations are integrated with the Euler method with a constant timestep of 0.1 msec.

By varying the "timec1" parameter, you can run the photoreceptor faster or slower. The photoreceptors are set by default to have a time to peak appropriate for mammals, or about 200 msec for rods and 60 msec for cones. You can lengthen these values to be appropriate for lower vertebrates (1 sec time to peak for rods). Or you can shorten the time to peak, which is useful to minimize the amount of computation in a simulation that records the response to a quick flashed light stimulus. Somemetimes, waiting around for 100 msec to get the response seems wasteful. Remember that membrane time constants will reduce the amplitude of the quicker voltage response recorded inside a neuron.

Photoreceptor light-modulated conductances are set with the "maxcond" parameter. The total bound fraction is always less than 1 so the maximum conductance is never exactly reached. Actual rod and cone conductances are non-linear but they are approximated by linear conductances in NeuronC. The rod conductance is nearly a current source (Baylor and Nunn, 1986) so that the light-modulated current is nearly constant over the physiological range (-20 to -60 mv). Thus the rod reversal potential is set to a large value (+720 mv). The cone conductance is more linear (Attwell et al., 1982), and reversal potential is predefined to be -8 mv. In order to give physiologically correct intracellular voltages, the rod and cone transduction mechanisms must be used with an appropriate leakage conductance (see definition files "rod.m" and "cone.m").

The rod and cone receptors are similar but the rod is approximately 100 times more sensitive. The rod mechanism responds to 1 photon with a voltage bump of about 0.5 mv and the cone mechanism responds to a 100 photon flash similarly. The cone response also is somewhat faster (peak in 60 msec), and has a negative undershoot on the recovery phase. New types of photoreceptors can be created (using the same set of difference equations) by adding a new set of "receptor constants" to the subroutine "initrec()" in the file "ncmak.c" and recompiling.

You can plot the values in the transduction cascade with the "plot G(n) <element expr>" statement, where n is:

   G(0)    conductance
   G(1)    rhodopsin
   G(2)    meta rhodopsin I
   G(3)    meta rhodopsin II (R*) activates G protein
   G(4)    G protein 
   G(5)    PDE
   G(6)    G cyclase  
   G(7)    cGMP   
   G(8)    Ca feedback for recovery and adaptation
   G(9)    Cax (protein between Ca and G cyclase)
   G(10)   Rhodopsin kinase (turns off rhod in response to decrement in Ca)
Click here to return to Photoreceptor statement index

Pigment sensitivity functions

Rod and cone type pigments are specified with the "pigm" parameter. The first 4 pigment sensitivity functions (rod=0, l,m,s = 1,2,3) are from Baylor, et al, 1984 and 1987 (monkey) and operate between 380 and 800 nm. The functions are implemented using a lookup table with values every 5 nm, quadratically interpolated between points. Default path length is dependent on pigment type: rods have a 25 um path, red and green cones have a 35 um path, and blue cones (assumed to be extrafoveal) have a 25 um path. The absolute sensitivity of a photoreceptor is calculated from tables of specific density vs. wavelength, multiplied by the path length. This calculation takes into account the photoreceptor's absolute density and its consequent self-screening.

The macular pigment is a yellow filter that excludes blue light from foveal cones, and the lens filter cuts off sharply in violet. The macular+lens filter adds the filtering properties of both filters in series (by adding their optical densities). The transmission spectrum for these filters is determined by table lookup, and the tables are from standard references. See the source code in "ncstim.cc", "wave.cc", "odconv.n", "macul.txt", and "lens.txt".

The turtle pigment sensitivity functions (pigm=4,5,6) are narrower than the corresponding primate pigments because turtles have colored oil droplets in the inner segment of the M and S cones that selectively filter the light reaching the outer segment. The turtle data are from Perlman, Itzhaki, Malik, and Alpern (1994), Visual Neuroscience, 11:247, Figs.4, 10, as digitized by Amermuller et al, Oldenburg, DE. The peaks were modified for smoothness, and the curves extrapolated from 400 to 380 nm and from 700 to 800 nm. The longwave extrapolation was done by the method of Lewis (1955) (J.Physiol 130:45) in which the log(sens) of a visual pigment is linear when plotted against wavenumber. (See "turtlesens.n" which was used to make "turtle.h", which contains the log(sensitivity) functions included in "wave.cc", which generates log(specific OD) functions in "wave.h" for "ncstim.cc".)

The light absorbed by a receptor is calculated from:

   sod  =  function of pigment and wavelength (table lookup)
   od   =  sod * path length
   T    =  exp10 ( -od )
   Labs =  ( 1 - T ) * mfilt * attf * QEFF
     
Where:
   sod   =  specific optical density (extinction coeff. x concentration)
   od    =  optical density
   T     =  Transmitted light
   mfilt =  macular filter (if defined)
   attf  =  miscellaneous attenuation factor 
   Qeff  =  quantum efficiency (set at .67)
   Labs  =  Light absorbed (absolute sensitivity)
Click here to return to Photoreceptor statement index

Voltage follower

conn <node> to <node> vbuf 
conn <node> to <node> vbuf delay=<expr>
Where:
              units:  default:  

   delay      msec    0           Time delay in msec.
A "vbuf" is a connection between two nodes that causes the voltage at the second node to exactly duplicate the voltage at the first node. In effect, it functions as a voltage clamp.

The "delay" parameter allows a "vbuf" to function as an axon of a neuron to carry an action potential from one node to another node instead of requiring a set of compartments normally generated by a cable. This scheme greatly reduces computation.

The voltages passed through the delay buffer are limited to +_ 300 mV with a resolution of 0.01 mV because the data is internally stored in 16-bit words. The delay time is specified in milliseconds and can be arbitrarily long. A "circular buffer" holds the data and storage space for each delay buffer is dynamically allocated according to its length. The storage requirements are 10 16-bit word for each millisecond of delay.

Click here to return to NeuronC Statements

Channel statement

Click here to return to NeuronC Statements

Channel

at <node> chan Na type <expr> 'parameters'
at <node> chan K  type <expr> 'parameters'
at <node> chan CGMP type <expr> 'parameters'
at <node> chan Ca type <expr> 'parameters' 'caexch params' 'pump params'
at <node> cacomp 'Ca parameters' 'caexch params' 'pump params'

    parameters:       default:
--------------------------------------------------------------------
    vrev   = <expr>   .04 V (Na) (~vna)      Na reversal potential (Volts)
                     -.08 V (K)  (~vk)       K reversal potential (Volts)
                      .05 V (Ca) from cao/i and [K]i
    offsetm = <expr>   0.0 V    (dnaoffsm)  relative threshold for Na chan activation (Volts)
    offseth = <expr>   0.0 V    (dnaoffsh)  relative threshold for Na chan inactivation (Volts)
    offsetm = <expr>   0.0 V    (dkoffsm)   relative threshold for K chan activation (Volts)
    offseth = <expr>   0.0 V    (dkoffsh)   relative threshold for K chan inactivation (Volts)
    offset  = <expr>   0.0 V    (dcaoffs)   relative threshold for Ca chan activation (Volts)
    tau    = <expr>    1.0                  relative act & inact 1/rate.
    taum   = <expr>    1.0      (dnataum)   relative activation 1/rate. 
    taun   = <expr>    1.0      (dktaun)    relative activation 1/rate.
    tauh   = <expr>    1.0      (dnatauh)   relative inactivation 1/rate.
    tauc   = <expr>    1.0                  relative (mg) flicker 1/rate. 
    taud   = <expr>    1.0                  relative flicker 1/rate. 
    maxcond= <expr>    1e-9 S   (dmaxna)    maximum conductance (Siemens)
                       2e-10 S   (dmaxk)
                       1e-10 S   (dmaxca)
    density= <expr>    no default           membrane chan density (S/cm2).
    ndensity=<expr>    no default           membrane chan density (N/um2).
    N      = <expr>    no default           Number of channels.
    unit   = <expr>    (set by chan type)   Unitary channel conductance
    caperm=  <expr>    (set by chan type)   rel Ca permeability (NMDA,AMPA,cGMP).

    k1     = <expr>   1e-7 M (dsk1), 1e-6 (dbk1)  mult for Ca sens of KCa type 0,1,2,3 chan (KCa)
    k2     = <expr>   1e-7 M (dsk2), 1e-6 (dbk2)  mult for Ca sens of KCa type 0,1,2,3 chan (KCa)
    d1     = <expr>   0 (dsd1), 1 (dbd1)     mult for volt sens of KCa type 0,1,2,3 chan (KCa, type SK, BK)
    d2     = <expr>   0 (dsd2), 1 (dbd2)     mult for volt sens of KCa type 0,1,2,3 chan (KCa, type SK, BK)

    cao    = <expr>   .005 M     (dcao)     extracellular Calcium conc (Molar)
    cai    = <expr>   50e-9 M    (dcai)     intracellular Calcium conc (Molar)
    cbound = <expr>   5          (dcabnd)   ratio of bound to free Ca
    cshell = <expr>   10         (dcashell) number of Ca diffusion shells

    cabuf             off                  use Ca buffer
    kd     = <expr>   1e-6 M (dcabr/dcabf) Kd for Ca buffer (rev/forw rates)
    vmax   = <expr>   1e8 /M/S   (dcabf)   Forward rate for Ca binding buffer
    btot   = <expr>   3e-6 M     (dcabt)   Buffer concentration in shells
    btoti  = <expr>   30e-6 M    (dcabti)  Buffer concentration in first shell

    caexch            off                   use Na-Ca exchanger
    kex    = <expr>   5e-9 A/mM4/cm2 (dcakex)   exchanger current density

    capump            off                   use Calcium pump
    vmax   = <expr>   1e-4 A/cm2 (dcavmax)  pump maximum velocity
    km     = <expr>   2e-7 M     (dcapkm)   pump 1/2 max conc

   chnoise = <expr>   0 (off)               = 1 -> set channel noise on
     N     = <expr>   set by unitary cond   Number of channels
     unit  = <expr>   (set by chan type)    Unitary channel conductance
     rsd   = <expr>   set by rseed          random seed

These statements define a macroscopic conductance at a node. Several classes of ion-selective channels can be created: Na, K, Ca. Within each class there are several types. Type 0 is the Hodgkin-Huxley (1952) standard type. Type 1 is a sequential-state version of the H-H type, and other types have different behavior (see below). Type 0 channels' conductance is the product of activation (m or n) and inactivation (h) variables in the form m3h for Na, and n4 for K. Standard rate constants (alpha, beta) are calculated from look-up tables generated at the beginning of each run, based on the temperature (set by "tempcel") and a Q10 set by a default variable (see below).

Setting the channel conductance

There are several ways to set the channel conductance. To set the absolute conductance, use the "maxcond" parameter. To set a channel density, use the "density" or "ndensity" parameters. If you know how many channels you would like, use the "N" parameter. These parameters can be set in conjunction with the "chnoise" parameter to define noise properties (see "Markov channel noise" below).

The "maxcond" and "density" parameters define the open conductance of the channels. If you need to create a channel of a specific conductance at a node, specify the conductance with the "maxcond" parameter. Otherwise, use the "density" or "ndensity" parameters to specify a conductance density. The "ndensity" parameter along with a unitary conductance (either specified or default) defines the maximum conductance (see "see setting unitary conductance and N" below. You should not use both "maxcond" and "density" in the same statement, because they both define the channel conductance.

Click here to return to Channel statement index

Voltage offset parameters

The "offset(m,h)" parameters define a voltage offset in the channel voltage gating properties relative to the default value (normally 0). The "offsetm" and "offseth" parameters modify the activation and inactivation voltages, respectively, and the "offset" parameter changes both. The default value represents the standard activation (i.e. 0 = no offset) defined by Hodgkin and Huxley. You can change the channel's activation level by selecting a different threshold. For example, by using a more positive "offsetm" for a sodium channel, the channel will activate at a more positive voltage and action potentials will occur at a slower rate. A more negative sodium threshold can increase the frequency of action potential firing.

If you prefer your "offset" parameters to define absolute voltages instead of relative offsets, set the default offset values in the beginning of your script to the voltage thresholds you determine for your default condition.

Click here to return to Channel statement index

Tau parameters

The "tau" parameters control the amplitude of the rate constants alpha and beta for each of the control variables m,h (for sodium), and n (for potassium), (m for calcium). They are "relative" parameters, meaning that the number you set is normalized by the parameter's default value and the resulting quotient multiplies the (in)activation rate constant.

If you prefer an "absolute" calibration for tau, just set the value for "base tau" in the beginning of your script to the time constant you determine for your default condition. Then you can then specify the "tau" as an actual time constant.

  base_tau = time constant you find for default tau

  actual rate = rate * base_tau / tau
"taum" corresponds to the sodium activation time constant, "tauh" corresponds to sodium inactivation, and taun corresponds to activation of potassium. If you want to change all of the rates proportionately, set the "tau" parameter.

A longer tau than the default value causes the action potential to be lengthened in time. A shorter tau shortens the action potential. If both "taum" and "tauh" are changed by the same factor, the action potential will retain the same general shape. If they are not changed by the same factor, the action potential shape will change and may fail entirely. If the time constants are too short, the action potential will fail because capacitive membrane charging shunts the ion currents and prevents voltage from changing quickly.

Click here to return to Channel statement index

Temperature dependence (rates, conductances)

The rates and conductances of voltage-gated channels changes with temperature in a predicatable way. The change is specified with a "Q10" which is the change in rate over a 10 degree change in temperature. Q10 values of between 1.4 and 3 are common. A high value of a Q10 implies a high activation energy for the corresponding chemical reaction.

The temperature dependence of most of the rate functions is set to a default Q10 value of 3, as assumed by Hogkin and Huxley (1952), except for alpham and betam which are set to a default of 2 (Frankenhaeuser and Moore, 1963).

The default values are: 
  dqm  = 2 (alpham, betam)
  dqh  = 3 (alphah, betah)
  dqn  = 3 (alphan)
  dqca = 3 (alphac, betac)
  dqd  = 3 (alphad, betad, for KA h) 
 dqkca = 3 (for Kca chan)
 dqsyn = 3 (synaptic channels)
For each channel type the rate function is defined at a certain temperature (the "base temperature"). At other temperatures the rate is multiplied by the increase or decrease calculated from the Q10 over the change in temperature from the original definition. Since voltage gated channels have a well-known temperature depency, it is always used, even when you specify a change in rate (with the multipliers "taum", "tauh", etc.) from the original absolute rate.

For most voltage-gated channels the "defined" temperature is that used by Hodgkin and Huxley (1952) of 6.3 degrees Celsius. For channels whose rate functions have been recently defined at some other temperature, e.g. room temperature (20-25 deg C) this temperature is used for calculating the rate change due to temperature. For synaptic conductances the base temperature is 22 degrees C.

 dqcab   = 2   (Q10 for Ca buffer)
dqcavmax = 2   (Q10 for Ca pump)
For the calcium buffer and pump the Q10 has been arbitrarily set to 2. The rates will change with temperature only when the default rates for the buffer and pump are used, i.e. if you specify a rate, it will not change with temperature.

  dqc  = 1.4 (Q10 for unitary conductances)
When a unitary conductance for a channel is not specified by the user, a default value defined for the channel type is used. The default rate changes according to the temperature and the Q10 set by "dqc". If you specify a unitary conductance, this value is used directly, i.e. it will not change with temperature.

Unitary conductances reported in the literature generally have a Q10 between 1.3 (for diffusion in water) to 1.6, so the value of 1.4 is a compromise (it can be changed for any channel in the source code).

Click here to return to Channel statement index

Setting unitary conductance and N

You can define the unitary conductance of the channel in several ways. You can define it with "unit". Or if you have defined "maxcond" and "N", the unitary conductance will be calculated. If you don't define "N", you can set it from "ndensity", and the resulting value for N will be used with the "unit" value that you set or with the channel's default unitary conductance.

If "unit" and "N" are both set and "maxcond" is not, the conductance is set by the product of N times unit:

   chan ....  chnoise=1 N=25 unit=10e-12

    N = you define
    unit = you define
    channel conductance is then calculated as = N * unit
If you define "N" but not "unit" or "maxcond", the conductance will be determined from the N you set along with the default "unit" for the channel type:

   chan ....  chnoise=1 N=25

   N = you define
   unit = default for channel
   channel conductance is then calculated as = N * unit
If you place the "N" parameter before or without "chnoise", it will define the channel conductance. You can place a second "N" after "chnoise" and it will define N for the noise properties only.

 
   chan ....  N=100 chnoise=1 N=25

   N = you define
   unit = default for channel
   channel conductance is calculated as = N * unit
   Noise is calculated from second N (25).
Note that you can turn off noise by setting "N" or "chnoise" to zero.

You can use the "ndensity" parameter instead of the "N" parameter to define the conductance and noise properties automatically:

 
   chan ....  ndensity=10 chnoise=1 

   ndensity = you define
   unit = default for channel
   N is calculated as = ndensity * membrane surface area
   channel conductance is calculated as = N * unit
   Noise is calculated from N (from ndensity).
If you use a channel's default unitary conductance (by not defining "unit"), the unitary conductance will have a temperature dependence (Q10 set by "dqc", default=1.4)

Click here to return to Channel statement index

caperm parameter

The "caperm" parameter sets the relative permeability to Ca++ ions. If you specify a value for caperm when defining a channel, this value will override the default channel permeability for Ca++. Several types of synaptic channel (e.g. NMDA-, AMPA-, and cGMP-gated channels) carry about 10-20% of their conductance as Ca++ ions, and this Ca flux is thought to be important for controlling postsynaptic mechanisms. If caperm is set (either individually or by default) for a channel, its Ca current will be automatically connected to the local calcium diffusion mechanism. Channels that can be specified alone such as Ca or second- messenger types such as cGMP-gated can have "calcium parameters" to define a calcium compartment, but you may also define one with the "cacomp" statement.

Click here to return to Channel statement index

Channel types: type 0, Hodgkin-Huxley

Type O channels are derived from the original Hodkgin and Huxley (1952) papers, and diagrams that precisely match Hodgkin-Huxley kinetics. Rate functions are the standard alpha and beta values. The rate functions are placed in tables so their values can be found efficiently. If you add noise to a type 0 channel, a 2-state Markov machine is added to the conductance. This may change the kinetics some depending on the time constant for the noise ("taud") you choose (see "Markov channel noise" below).

Na (green) and Kdr (red) channels voltage clamped in steps from -70 to +20 mV. Note that Na currents are inward, activate quickly, and inactivate after 1-2 msec, whereas Kdr currents activate slowly and do not inactivate.

  
Na type 0 rate functions:

Given Vm in mV, calculate rate /sec:

Activation:

   alpham = taum ( -100 (V- -40.) / (exp ( -0.1 (V- -40.) - 1))
   betam  = taum ( 4000 exp ((V- -65) / -18.))

   alphah =  70 exp ((V- -65) / -20.)
   betah  = 1000 / (exp (-0.1(V - -35)) + 1.0)

Inactivation:

   alphah =  tauh ( 70 exp ((V- -65) / -20.))
   betah  =  tauh (1000 / (exp (-0.1(V - -35)) + 1.0))

Where:

       V = Vm - voffset
 voffset = voltage voffset (set by user)
    taum = activation rate multiplier   (set by user)
    tauh = inactivation rate multiplier (set by user)
Click here to return to Channel statement index

List of all channel types

Channel types

 ion   type   states  characteristics

 Na    0      0       Standard Hodgkin-Huxley kinetics, m3h.

       1      8       Standard Hodgkin-Huxley kinetics,
                        Markov sequential-state.
       2      9       Improved Markov kinetics from
                        Vandenberg and Bezanilla, 1991
       3      6       Simplified Markov, like type 1 above.
       4      2       Integrate-and-fire, Markov.

 K     0      0       Standard Hodgkin-Huxley kinetics, n4, non-inactivating.
       1      5       Standard Hodgkin-Huxley kinetics, Markov sequential-state+
       2      0       KA channel, inactivating, HH-type, n3h.
       3      8       KA current, inactivating, HH-type, Markov sequential-stat+
       4      3       Ih channel, hyperpolarization-activated,
                          from Hestrin (1987), see chank4.cc.

 KCa   0      0       SKCa, Hodgkin-Huxley-like, no voltage sensitivity. 
       1      2       SKCa, Markov sequential-state.
                        Ca-sensitivity can be varied, see below.
       2      0       BKCa Hodgkin-Huxley-like. 
       3      2       BKCa channel, Markov sequential-state.
                        Voltage- and Ca-sensitivity can be varied, see below.
       4      6       SKCa channel, Markov sequential-state,
                          from Hirshberg et al. (1998).

Ca     0      0       L-type Ca (high voltage activeated, tonic)
Ca     1      4       L-type Ca, sequential state.
Ca     2      0       T-type Ca (low voltage activated, fast inactivating)
Ca     3      6       T-type Ca, sequential state.

cGMP   1      8       cGMP-gated chan from rod outer segment (Taylor & Baylor 1995)

AMPA   1      7       AMPA-gated chan (Jonas et al 1993)
AMPA   2      7       AMPA-gated chan, independent gating (Jonas et al 1993)
AMPA   3      9       AMPA-gated chan (Raman and Trussel 1995)

GABA   1      5       GABA-gated chan (Busch and Sakmann, 1990)
The type 1 Na channel has an 8 state transition table with four inactivated states. The K channel has 5 states with no inactivated states. They produce identical results to the HH (or type 0) channels, but run a little slower. The type 2 Na channel has "improved" kinetics that are defined by a 9-state Markov diagram. It is the "extended type 3" model of Vandenberg and Bezanilla, (1991) and is preferable to other models when biological accuracy is wanted. The type 3 Na channel has a 6 state transition table with 4 activated and 2 inactivated states, and does not exactly match the HH (type 0) channel. The type 4 Na channel is an "integrate-and-fire" model (see below).

Click here to return to Channel statement index

Channel types: type 1

Type 1 channels are derived from "Markov" sequential-state diagrams that very closely match Hodgkin-Huxley kinetics. Rate functions are the standard alpha and beta values. The conductance is normally zero or a small fraction for all the closed or "inactivated" states.

Other sequential-state channels (type 1 and above) are macroscopic descriptions of sets of channels in a membrane. The population of a state represents its "concentration" as a fraction of 1. The concentration of all states always sums to 1. Each state also has a fractional conductance which when multiplied by the effective maximum conductance "maxcond" produces the instantaneous channel conductance. Microscopic descriptions of channels are possible for the same transition state diagram using noise parameters (see below).

When noise is added to these sequential-state channel types (with the "chnoise" parameter), the population of a state is an integer that represents the actual number of channels in the state, and the number of channels that move between between different states is an integer number calculated from the binomial function. The total number of channels (i.e. from all the states) remains constant. This scheme gives a very accurate representation of the channel kinetics and noise. A time step of 50 usec or less must be used when sequential state channels are given noise properties or the numerical integration becomes unstable.

Top, eight-state Markov state diagram for Na type 1 channel. Time courses of 6 of the 8 states are illustrated below. Middle, average state populations for a typical action potential. Each state varies between 0 and 1, and the total of all states is 1. Bottom, same plot except noise for 100 channels added. Transition between states is computed from binomial distribution based on population of the source state and the probability of the transition (rate function).

Click here to return to Channel statement index

KA (fast inactivating K channel)

The K type 2 channel is an inactivating version of the standard delayed rectifier K channel. It is described by a m3h kinetic scheme like the Type 0 Na channel. The K type 3 channel is a sequential-state version with eight states. It is useful when an accurate representation of the noise properties of the KA channel is required.

The function of the KA current in some neurons is to stablize the membrane in combination with Na and Kdr channels. Since KA activates and inactivates rapidly it is active during the time when Kdr channels are building up activation, but during a prolonged stimulus KA inactivates when Kdr is fully active. This action tends to dampen oscillatory behavior. In a spike generator, KA helps to terminate the spike, and is quickly inactivated on hyperpolarization. In some neurons, it activates at a more hyperpolarized voltage than Na channels, so it slows down repolarization in the interspike interval.

KA rate functions:

Given Vm in mV, calculate rate /sec:

Activation:

    y = -0.1 * (V+90); 
    alphan = taun * 10.7 * y / (exp(y) - 1) 
    betan  = taun * 17.8 * exp ((V+30) / -10.)

Inactivation:

    alphad = tauh * 007.1 * exp (-0.05 * (V+70))
    betad  = tauh * 10.7 / (exp (-0.1  * (V+40)) + 1.0)

Where:

       V = Vm - voffset
 voffset = voltage voffset (set by user)
    taun = activation rate multiplier   (set by user)
    tauh = inactivation rate multiplier (set by user)
   

Activation of K type 2 and 3 channels by a voltage clamp from -70 mV to -10 mV. Dark blue traces show conductance. On top, green trace is the "m" state variable (activation), and the light blue trace is the "h" state variable (inactivation). At bottom, each trace represents the fractional population of one of the 8 states.

KCa (calcium-activated potassium channel)

The KCa channel types 0,1,2,3 are a calcium-sensitive potassium current that can be voltage sensitive, modeled after Hines, 1989 and Moczydlowski and Latorre, 1983. It is a Hodgkin- Huxley style channel with first-order rate equations alpha and beta which are voltage and calcium dependent:

    Gk    = maxcond * n
    dn/dt = alphakca - (alphakca + betakca) * n

   alphakca = taun / (1 +  k1 / [Ca] *  exp(d1 * -V / 10) 
   betakca  = taun / (1 + [Ca]/ (k2  *  exp(d2 * -V / 10)

Where:
      d1, d2 are voltage coefficients
      k1, k2 are calcium coefficients
      V = membrane voltage in mV
      V = Vm - voffset  (set by user)
   taun = rate multiplier (set by user)
The constants maxcond, tau, voffset, d1,d2,k1,k2 can be specified by the user. The d1 and d2 constants set the voltage sensitivity, and k1 and k2 set calcium sensitivity.

Reasonable values of d1 and d2 are between .5 and 5. To eliminate voltage sensitivity, set both d1 and d2 to 0 (which is default for KCa types 0 and 1). A good start for the k1 and k2 values is the average range of internal [Ca] expected. Above this average Ca level, alphakca increases, and below the average betakca increases.

Some KCa channels have minimal voltage sensitivity (SK type), a small unitary conductance (~20 pS), and are thought to be involved in lengthening the interspike interval. Other types involved in spike termination have a large unitary conductance, and both voltage and calcium sensitivity (BK type). If you specify KCa type 0 or 1 channels (SK type) they will have no voltage sensitivity by default. If you specify KCa type 2 or 3 channels (BK type) they will have voltage and calcium sensitivity by default. You can change this default behavior by setting d1, d2, k1, and k2.

The KCa type 2, 3 channels are similar to the 0, 1 channels except that they are the "BK" type (sensitive to voltage and Ca, with large conductance = 200 pS). They have different default values for the unitary conductance and the d1, d2, k1, k2 constants.

The KCa type 4 channel is a sequential-state channel with 6 states that has no voltage sensitivity and is the best model so far for the SKCa channel (apamin-sensitive). This channel is derived from Hirshberg et al, 1998 (see chankca.cc for details). As in the other sequential state channels, when noise is added the states become populated with an integer number of channels with the changes in population computed from the binomial function. You can modify the activation and inactivation rates with the parameters "taua" (Ca binding), "taub" (Ca unbinding), "tauc" (opening flicker rate), and "taud" (closing rate).

The KCa type 5 channel is a sequential-state channel with 6 states that describes an sKCa channel with no voltage sensitivity but insensitive to apamin. This channel is derived from Sah and Clements, 1999 (see chankca.cc for details). Its affinity for Ca++ is relatively high, so Ca++ unbinds slowly, which accounts for the slow deactivation of the channel. You can change the Ca++ binding rate with "taua", the unbinding rate with the parameter "taub", and the open/close flicker rate with "taud". You can test these channels with the "tcomp/chantestkca.n" script.


Ih channel (activated by hyperpolarization)

Currents through a K type 4 channel (Ih current). The cell is clamped to -30 mV and then stepped to -50 down to -110 mV for 500 msec, then stepped to +30 mV. Note that the activation currents have a long time constant but deactivation is short, and that the channel does not inactivate.

The K type 4 channel is a sequential-state version of the Ih channel from photoreceptors. It is activated when the membrane voltage hyperpolarizes beyond -50 mV, and has a slow activation time constant, between 50 and 200 msec. It does not inactivate, but deactivates at voltages more depolarized than -30 mV with a time constant between 20 and 50 msec. Normally K channels have a default reversal potential set by the K Nernst potential to near -80 mV, however for the Ih channel the default is -20 mV. You can change the reversal potential with the "vrev=" option.

Click here to return to Channel statement index

Integrate-and-Fire Na channel

The Na type 4 channel is a 2-state channel whose alpha and beta rate functions integrate a compartment's voltage and turn on the channel when the integration reaches a threshold. The "offsetm" parameter defines the zero point for the integration, for example if set to -0.07 then the channel will integrate the voltage above -70 mV. After the channel reaches threshold, it opens its conductance for a short time (1-2 msec) and resets the integration allowing the integration to start for the next interval.

Since the channel imitates a Na channel it can only depolarize so another channel (typically a K channel) is required to set up a working spike generator. This channel can therefore be used in combination with other channel types to test out hypotheses in a way not possible with standard integrate-and-fire spike generators (because they don't work with a standard compartment that sums the synaptic inputs and the spike currents).

To look inside the operation of the IF NA channel, you can plot the G1 and G2 values to show the population of the two states; G2 is the conducting state. Plot G3 and G4 to look at the integration and state switching.

Click here to return to Channel statement index

Calcium channels

Several types of calcium channel are implemented. Two types (0,2) are based on the Hodgkin-Huxley style of first-order rate constants:

Type 0    Gca   = c3 * maxcond                        = L-type calcium
          dc/dt = alphac - (alphac + betac) * c          high threshold

Type 1    same as type 0 but Markov sequential-state

Type 2    Gca   = c2h * maxcond                       = T-type calcium
          dc/dt = alphac - (alphac + betac) * c          low threshold
          dh/dt = alphah - (alphah + betah) * h
    
Type 3    same as type 2 but Markov sequential-state

The alpha and beta rate equations are similar to those for the Na conductance (look in "initchan.c" for "accalc()" and "bccalc()").

Calcium compartment

Whenever a calcium channel is specified, a "calcium compartment" is generated that is linked to the voltage compartment, modeled after Hines, 1989 and Yamada et al., 1989. If several calcium channels are defined at the same location, they share the calcium compartment.

The calcium compartment contains a series of concentric shells of "cytoplasm", each 0.1 um thick, that restrict the flow of calcium into the interior of the cell according to the law of diffusion. The parameter "cshell" sets the number of shells (default 10). The inner part of the cell is considered to be a well-stirred "core" with a uniform concentration of calcium. In a dendrite that's too small to fit the number of specified or default shells, the number of shells is reduced so they fit. Only the calcium concentration at the outer shell "Ca(1)" affects the membrane reversal potential. The parameters "cao" and "cai" define the starting concentrations of calcium in extra- and intra-cellular space, respectively. You may also specify a calcium compartment with the "at cacomp " statement.

At each time step, the calcium flux through the membrane is computed from the sum of the current through the calcium channel, the calcium pump, and the sodium-calcium exchanger. This flux is then added to the compartment and calcium diffusion between the concentric shells is computed.

Click here to return to Channel statement index

Calcium buffering

Static buffering is selected with the "cbound" paramter. It represents the ratio of the bound calcium to the free concentration. When "cbound" is a large value ( > 50) the concentration of calcium is much lower and less calcium is available for diffusing through the shells.

Dynamic calcium buffering in the shells is specified with the "cabuf" parameter. The total concentration of buffer is set by the "btot" parameter ("btoti" for the first shell). Calcium binds to the buffer at a high rate that is proportional to the concentration of both calcium and buffer:

               f>
    Ca + B <--------> Ca.B
              <r

You specify the forward (binding) and reverse (unbinding") rates (default values "dcabf", "dcabr") using the "kd" (= ratio of reverse/forward rates) and "vmax" (=forward rate) parameters. Many different effects can be set up by varying the forward binding rate, kd, and the buffer concentration.

The forward rate is dependent on the concentration of calcium and buffer. The reverse rate is a function of time and is independent of concentration. If the forward rate is not set (with "vmax"), the default values are dependent on temperature (Q10 set by "dqcab", default=2).

Note that when the "cabuf" parameter is defined, the "cbound" parameter is ignored.

Click here to return to Channel statement index

Calcium pumps

There are two types of calcium pump. A high-affinity, low volume "pump" ("Ca-ATPase") transports calcium from the cell. Its current is:
       Ica = Vmax * ([Ca]-[CaB]) / ( km + ([Ca]-CaB] )
Where:
       Ica  = calcium current from this pump (outward).
       [Ca] = calcium concentration at inner surface of membrane.
       [CaB]= basal level of calcium below which it is not pumped = cai. 
       Vmax = Maximum rate of calcium current (density: mA/cm2).
       km   = concentration for 1/2 max rate.
The pump's calcium current is added to the total current in the voltage compartment and also to the total calcium flux in the calcium compartment.

Note that the pump current is independent of membrane voltage but is dependent on the internal Ca concentration. If the pump "vmax" is not set, its default value ("dcavmax") is dependent on temperature (set by its Q10 value, "dqcavmax" default=2).

A second type of calcium pump is the "exchanger". It is a low-affinity, high-volume calcium transporter that exchanges Na ions for Ca ions. Its currents are:

                            
       Ica = Kex * [ Cao * Nai * Nai * Nai exp (EG     * V * F/RT) -
                     Cai * Nao * Nao * Nao exp ((EG-1) * V * F/RT) ]
       Ina = -r * Ica / 2

Where:
       Ica  = calcium current from this exchanger (outward).
       Ina  = sodium current from this exchanger (inward).
       Cao  = external calcium concentration. 
       Cai  = calcium concentration at inner surface of membrane.
       Nao  = external sodium concentration. 
       Nai  = internal sodium concentration. 
       Kex  = defines rate of calcium current (density: A/mM4/cm2).
       EG   = partition parameter representing position of V sensor (0.38).
       r    = exchange ratio (3 Na+ per Ca++)
The exchanger's calcium and sodium currents are added to the total current in the voltage compartment. The calcium current is added to the total calcium flux in the calcium compartment.

Note that the exchanger current is dependent on membrane voltage and on the concentration of both internal and external Ca and Na and temperature. At low internal Ca concentrations the exchanger supplies Ca to the cell which raises internal Ca and generates a net outward current. At high internal Ca concentrations the exchanger extrudes Ca from the cell which lowers internal Ca and generates a net inward current.

For simulations with typical concentrations and temperatures (temp = 22-35 deg C, dcao = 1.15 mM, dnao = 143 mM, dnai = 12.5 mM, i.e. Ena = +65 mV), the equilibrium point ranges from 90 to 150 nM, so typically the exchanger tends to deplolarize. The pump and exchanger rates therefore can be adjusted to achieve a balance at one concentration.

Click here to return to Channel statement index

Current through Ca channels

The current through a Ca channel can be highly nonlinear because the internal Ca concentration is very low and thus internal Ca does not pass through the channel easily to the outside. This effect is simulated in NeuronC with an approximation of the "GHK current equation" which gives the current as a function of the voltage and channel permeability:

    if((cratio=(cai + dpki) / cao) < 1.0) {
      if (abs(vm) > 1e-5)  {
         vfact = exp(vm* 2F/R/T);
         df =  -vm * (1.0-cratio*vfact) / (1.0 - vfact);
      }
      else df = r2ft * (1-cratio);
    }
    else df = capnt->vrev - vm;               /* driving force */

  Where:

     df = driving force for calculating current
     vm = membrane voltage
    cai = internal Ca
    cao = external Ca
   dpki = internal K
Click here to return to Channel statement index

Setting Nernst and GHK reversal potentials

The "vrev" parameter defines the reversal potential for a channel's driving force (voltage). You can set "vrev" for any channel arbitrarily to cause the channel to be depolarizing or hyperpolarizing. However it is convenient to have default values for channels so they automatically work in the way one would expect in a physiology experiment. One way to do this is to calculate reversal potentials from the major ions (Na+, K+, Cl-, Ca++), so that each channel is defined to use one ion and its reversal potential is set from the ion's Nernst potential.

However, the Nernst potentials "vna", "vk", "vcl", etc. are not equal to the reversal potential that is experienced by a channel, for several reasons. Other ions besides the channel's major ion can pass through the channel and this affects the reversal potential, defined by the "GHK voltage equation" (see "Reversal potentials, Nernst and GHK equation" in the first section of the manual). Also, when the internal and external concentrations of an ion such as Ca are very different, the effective driving force for the channel changes with membrane voltage (see "Current through Ca channels" above).

The reversal potential for a NeuronC channel is set by default to its GHK voltage, calculated from the concentrations of various ions and their permeabilities through the channel. The internal and external concentrations for an ion are set by default from predefined Nernst potentials for the ion (i.e. vna, vk, vcl), but you can change these values to give arbitrary Nernst and reversal potentials. Note that the default reversal potential for a channel and the Nernst potential for an ion are functions of "tempcel" = temperature (see "Reversal potentials, Nernst and GHK equation" in the first section of the manual). They are also functions of the "surface potential" that is created when external calcium concentration is high (see "Voltage offset from external calcium" below).

If you want to ignore the GHK voltage equation and set reversal potentials from the Nernst voltages vna, vk, and vcl, you can set the relative permeabilities of channels to their minor ions to zero:

   dpkna  = 0;          ( sets K  permeability in Na chans to 0 )
   dpcana = 0;          ( sets Ca permeability in Na chans to 0 )
   dpnak  = 0;          ( sets Na permeability in K  chans to 0 )
   dpcak  = 0;          ( sets Ca permeability in K  chans to 0 )
   dpnaca = 0;          ( sets Na permeability in Ca chans to 0 )
   dpkca  = 0;          ( sets K  permeability in Ca chans to 0 )

If you want to keep the Nernst potentials constant without being redefined automatically with temperature, you can set:

   calcnernst = 0;     ( do not recalculate Nernst potentials )
                       (  after set by user )
The reversal potential issue is especially important for Ca channels because internal [Ca] is normally so low that even a slight permeability to [K] ions is a large factor in the Ca channel's reversal potential (see "Current through Ca channels" above).

If you specify the internal Ca level (cai) this will override the default internal concentration at the Ca compartment associated with the channel, and the Ca channel's current and reversal potential will be modified accordingly from the GHK current and voltage equations assuming a default level of K permeability (dpkca = 0.001 by default). If you set the Ca channel's reversal potential (vrev) this will set the internal calcium for the compartment also assuming a default level of K permeability.

If you specify both internal calcium and reversal potential (cai and vrev) the calcium flux will be set by the levels of cao and cai, and the Ca channel's total current will be set by vrev, assuming for both the GHK current equation but not K permeability. This would be the case, for example, if you don't want to use relative K permeability in Ca channels (dpkca) but want to define the reversal potential and the resulting total current through a Ca channel.

If you set:

    chan Ca ... vrev=0.05             (sets cai, controls caflux and Ica)

    chan Ca ... cai=100e-9            (sets vrev, controls caflux and Ica)

    chan Ca ... vrev=0.05 cai=100e-9  (vrev sets Ica, cai controls caflux)
Click here to return to Channel statement index

Strategy for computing reversal and Nernst potentials.

In order to simulate the effect of temperature and nonselective permeabilities on the reversal potential for a channel (e.g. the effect of internal K+ ions on a Ca channel reversal potential), every channel type contains information about relative permeability to the major ions, and the simulation keeps track of the concentration of internal and external ions. Of course only Ca concentration varies during a simulation (at least for now). This allows the "correct" reversal potential to be computed for all Na, K, and Ca channels when there is a minor fraction of the current carried by another ion.

Setting the right internal and external ion concentrations is a bit tricky, and has been designed to be automatic so no changes are necessary for most simulations.

Here's the sequence: the vna, vk, and vcl values are set arbitrarily to +65, -98, and -70 mV. Then the external ion concentrations are specified (from Ames & Nesbett, 1981, i.e. the composition of Ames medium, and Hille, 2nd ed and some retinal papers: dnao=143, dko=3.6, dclo=125.4 mM). Then using the vna, vk, and vcl values and the external concentrations, the internal concentrations are set from the Nernst equation at 37 degrees C. These are the default values.

If the user wants to set the Nernst potentials vna, vk, or vcl, these values could then be used to recompute the internal ion concentrations from the Nernst equation at whatever temperature is currently set. One problem with this method of setting the internal ion concentrations is that internal K+ concentration varies a lot when temperature ("tempcel") is changed. This is not really correct, as a typical cell regulates its membrane potential and ion concentrations quite tightly. Howver it is not known exactly which parameters in the real physiology of a cell have priority over others when external ion concentrations or temperature change.

One would like a method for simulating control of ion concentrations and reversal potentials that mimics various types of physiological dependence of Nernst potential and internal ion concentrations on temperature. This strategy is implemented in NeuronC with the variable "calcnernst" which sets the simulator's priority for ion concentrations and Nernst potentials. If calcnernst = 0, the internal ion concentrations are recomputed from the temperature and the Nernst potentials. However, when calcnernst = 1, Nernst potentials are recomputed from temperature and ion concentrations.

If "calcnernst" is set between 0 and 1, (default 0.6) a hybrid strategy is used where Nernst potentials and ion concentrations both change. A new reversal potential is calculated from the temperature and ion concentrations, but "calcnernst" sets the "fraction" of this value that is used. The difference is made up by a change in internal ion concentration. For example, if calcnernst=0.9, most of the change is assigned to the Nernst potential, and the ion concentrations change only a little.

Note that for this strategy to be useful, you should not change both Nernst potentials (vna, vk, vcl) and ion concentrations (dnai, dki, dko), since these parameters are automatically set at run time. If you want to precisely define the Nernst potentials at different temperatures, then you can set "calcnernst=0" and the ion concentrations will be recomputed. Otherwise, if you want to keep ion concentrations precisely defined, you can set calcnernst=1, and the Nernst potentials will be recomputed.

Of course at any time "vrev" for a synapse or channel can be defined which overides the Nernst potential and the channel's default value.

These additions have the effect of making the simulator more realistic, but there is a *price* for it. The default reversal potentials for the channels are not vna, vk, or vcl. They are calculated from the GHK voltage equation so they represent all the ion currents that flow through a channel. The currents are defined by setting permeabilities for several ions for each channel.

What this means in practice is that vrev for an Na channel is *near* +40 mv (43 at 22 deg and 47 at 37 deg), and *near* -80 for a K channel (83 at 22 deg, and 82 at 37 deg). So the reversal potentials are close but not exact to the usual values, and they change with temperature and the ion concentrations and permeabilities.

If you would prefer to have the Nernst potentials define the reversal potentials for channels, you can set the permeability for each channel type to be exclusively for the major ion, (i.e. set dpnak, dpkna = 0). Then you can set the reversal potentials for all the channels with vna, vk, and vcl.

The permeabilities are set to default values (dpkna, dpnak, dpkca, etc.) in the channel definitions (in "chanxxx.cc"). However, to change the value of the Ca permeability for a channel, you can set its "caperm" parameter. This overrides the channel's default Ca permeability. Note that these parameters range from 0 to 1.

    dpkna        relative permeability for K  in Na channels
    dpcana       relative permeability for Ca in Na channels
    dpnak        relative permeability for Na in K channels
    dpcak        relative permeability for Ca in K channels
    dpnaca       relative permeability for Na in Ca channels
    dpkca        relative permeability for K  in Ca channels
Click here to return to Channel statement index

Voltage offset of channel gating from external calcium

When external [Ca] is increased, the effective voltage that many membrane voltage-gated channels sense is hyperpolarized, e.g. Na conductance is less (Frankenhaeuser and Hodgkin, 1957), and reversal potentials are slightly depolarized (see below). Changing the value of "dcao" or "dcoo" (external cobalt) causes a change in effective voltage offset, which is approximately 18 mV per factor of 10 change in the concentration of divalent cations. The amount of change is set by 2 parameters: "dcavoff" sets how many mV per factor of 10 increase, and the "qcao" field in the chanparm structure for each channel parameter sets the "base cao" (i.e. the [Ca] for zero offset) for the voffset calculation. This automatic feature allows the comparison of voltage gating data collected at different levels of [Ca]o in the medium.

To disable the automatic computation of voltage offset, set "dcavoff=0" in the beginning of your script. This is not normally necessary, however, as the voltage offset is zero if "dcao" or "dcoo" is not changed. If you want to set the [Ca]o for some channels without causing a voltage offset, set the "cao" parameter for the channel without changing "dcao":

   dcavoff  = 0;            ( External Ca does not produce voltage offset )

   chan Ca ... cao=0.004    ( Set external Ca for local Ca compartment ) 

Voltage offset of reversal potential from external calcium

The effect of an increase in external divalent cations on the reversal potential of channels is less than on gating but is positive, and is set by the "dcaspvrev" variable (default = 0.18), which multiplies dcavoff (0.018) for a value of 3.2 mV positive shift in a channel's reversal potential for each factor of 10 increase in cao. See "Reversal potentials, Nernst and GHK equation" in section 1 of the manual.

To turn off this feature, you can set either "dcavoff" or "dcaspvrev" to zero, or you can leave "dcao" set to its default value:

   dcavoff  = 0;            ( External Ca does not produce voltage offset )
   dcaspvrev = 0;           ( Voltage offset does not affect reversal potential )

   chan Ca ... cao=0.004    ( Set external Ca for local Ca compartment ) 
Click here to return to Channel statement index

Markov channel noise

Channel noise is implemented by adding a "noise signal" to the channel conductance. The noise signal is activated with the "chnoise" parameter. When "chnoise" is present, the channel noise is defined by several parameters, "N", "unit" and several time constants ("taum, tauh, taun, tauc, taud"). Some of these parameters have default values and some of them parameters are also used without Markov noise (see "Setting unitary conductance"

Trace of a K channel in a small patch of membrane (green) that contains channel noise (large jumps) and Johnson noise (small fluctuations) filtered at 1000 Hz, and an identical channel on a separate patch of membrane (red) without Johnson noise. Channels are voltage clamped to -20 mV. Note that the K current is outward.

The "N" parameter describes the number of independent channels for the purpose of the noise computation but does not affect total conductance (unless "maxcond" is not specified, see below). The instantaneous number of open channels is a random function (binomial deviation) of the probability of each channel opening and the number of channels. For HH type channels this is equivalent to a 2-state Markov scheme, which gives approximately correct kinetics for channel opening and closing.

    at .... chan ....  chnoise=1 [noise parameters]

noise parameters:         default

         N    = <expr>     (no default)        number of channels for noise
         unit = <expr>     (set by chan type)  size of unitary conductance
         rsd  = <expr>     (set by rseed)      random seed for noise
         tauc = <expr>     1.0                 rate multiplier for Mg noise
         taud = <expr>     1.0                 rate mult for noise flicker 
The "unit" parameter describes the unitary conductance of a single channel and allows the simulator to calculate the number of channels from the maximum total conductance "maxcond". When N is set to zero, channel noise is turned off. If you specify a value for "N", the value of "unit" is ignored:

   maxcond = you specify
   N = you specify
   unit is calculated as = maxcond / N
Otherwise, if you specify both "maxcond" and "unit", the total number of channels is calculated as:

   maxcond = you specify
   unit = you specify
   N is calculated as = maxcond / unit
If you don't define "N" or "unit", but do specify "chnoise", the value of N will be computed from either the value of "maxcond" specified or its default value, and the unitary conductance will also come from its default:

   channel conductance = maxcond or its default
   unit = you define or default for channel type
   N is calculated as = maxcond / unit
Defaults for "unit" (the unitary conductance) are:

   dnau =  12e-12  @6.3      default Na unitary cond, gives 20 pS @ 22 deg
   dku  =  12e-12  @6.3      default K  unitary conductance
   dkau =  12e-12  @6.3      default KA unitary conductance
   dkcabu= 44e-12  @6.3      default BKCa unitary cond, gives 115 pS @ 35 deg
   dkcasu= 8.4e-12 @6.3      default SKCa unitary cond, gives  22 pS @ 35 deg

   dampau = 25e-12 @22       default AMPA unitary conductance
   dcgmpu = 25e-12 @22       default cGMP unitary conductance
   dscu   = 25e-12           default 2-state synaptic channel
Note that the default unitary conductances have a temperature coefficient, set by the Q10 for channel conductance "dqc" (default = 1.4). The base temperature at which the unitary conductance is defined is set by the "qt" field of the channel constants. For HH-type rate functions, the base temperature is normally 6.3 deg C, and for synapses it is often 22 deg C. For more details, look in "Adding New Channels".

Click here to return to Channel statement index

Two-state channels

Quantal conductance for HH type channels is calculated with the following equations that define a 2-state Markov channel (see "Adding New Channels"):

     pa = conduct / tau;                    /* tau for close -> open */
     pb = (1.0-conduct) / tau;              /* tau for open -> close */
     nco = bnldev(pa,nc);                   /* delta closed to open */
     noc = bnldev(pb,no);                   /* delta open to closed */
     no += nco - noc;
     conduct = no / nchan;

where:
         pa = probability of opening
         pb = probability of closing
        tau = average frequency of channel opening
         no = number of open channels
        nco = number of channels opened per time step
        noc = number of channels closed per time step
      nchan = number of channels
     bnldev = random binomial distribution funtion
    conduct = channel conductance
Click here to return to Channel statement index

Multi-state channels

Channel noise for Markov sequential-state channels (e.g. Na type 1) is implemented by running the sequential-state machine in "noise mode" where a state describes an integer number of channels. This defines the kinetics of channel opening and closing, so no "dur" parameter is needed (and is ignored if specified). The number of channels "N" and the unitary conductance "unit" can be specified or can be calculated from the other parameters (see above), or a standard default unitary conductance will be used.

See the description of "synaptic vesicle noise" above for a discussion of the random "seed" and how to change it.

Recording conductance and state concentration

Using the "G", "G(1)-G(12)" expressions, the channel internal states may be recorded (see "plot" below). The expression "G(0) <expr> records the channel conductance in a manner similar to the "FCx" expression (calib. in S). For a "sequential-state" type of channel (type 1), the "G(x)" (x=1-12) expression records the channel state concentrations, (dimensionless fractions of 1).

For all channel types:

    G          channel conductance (Same as G(0) or G0)
    G(I)       ionic current through channel
    G(vrev)    vrev (reversal potential, from GHK V eqn. and permeabilities)
    G(Ca)      Calcium current through channel (if Ca, NMDA, cGMP chan)
For HH channel types:

    G(M)       m (if Na chan) or n (if K chan), or c (if Ca chan), frac of 1.
    G(H)       h (if inactivating type)
For sequential-state Markov types:
    G          channel conductance (Siemens)
    G(0)       channel conductance (Siemens)
    G(1)       amplitude of state 1 (Fraction of 1, or population if "chnoise")
    G(2)       amplitude of state 2
    .
    .
    .
    G(n)       amplitude of state n.
Note that the number inside the parentheses is a numerical expression and can be a variable or a function. At a node with a calcium channel:
    Ca          cai = [Ca] at first Ca shell, same as Ca(1)
    Ca (0)      cao = [Ca] outside
    Ca (1)      cai = [Ca] at first Ca shell
    Ca (2)      [Ca] at second shell
    .
    .
    .
    Ca (n)      [Ca] at nth shell
    Ca (100)    [Ca] in core
    Ca (vrev)   local reversal potential for Ca (Nernst potential)
    Ca (I)      total Ca current through Ca channels and pumps
    Ca (IP)     Ca current through pump
    Ca (IE)     Ca current through exchanger
    Ca (IPE)    Ca current through Ca pump and exchanger
[ Note that exchanger current Ca(IE) includes Ca and Na currents, and that it is dependent on Vrev of Ca and Na.]

If the channel is a Na type 4 (Integrate-and-Fire)

    G(0)        channel conductance
    G(1)        population of state 1
    G(2)        population of state 2
    G(3)        integration state
    G(4)        state switching
Click here to return to Channel statement index

Setting the rate constants

If you need to modify the behavior of a channel, remember that you can use the standard channel types and modify their behavior by changing the effective voltage (e.g. voffsetm, voffseth) and/or rate (e.g. taum, tauh). Often this provides enough flexibility to change the behavior of a channel to make it work the way you need.

The rate constants were defined by Hodgkin and Huxley (1952) th of channels, you can define your own rate constant functions for channels by writing the functions in a "nc" program. These functions are used instead of the default ones at the beginning and also whenever the time increment changes during a run. For instance, you could change the sensitivity to voltage for activation (the alpha rate function) and this would modify the range over which the channel would start to activate.

The rate functions defined by Hodgkin and Huxley (1952) are the default functions used in "nc" exactly as given in this original paper, except for the voltage definition. The voltage definition used in "nc" is the membrane voltage in mV. A channel's default rate functions are defined in the file containing the channel data structures (e.g. channa1.cc for Na type 0 and 1 channels).

To replace these predefined functions, make your own functions that define the alpha and beta rates, normally called "calcna0m" (calculate m for Na type 0), "calcna0h", etc., in your script file that you run with "nc". Whenever any of these functions are defined inside your file, they are used automatically instead of the default ones. The functions return their respective rate constants and have two parameters: a) membrane voltage, and b) a number describing the function (e.g. 1 = alpha, 2 = beta). Voltage is calibrated here in mV, using the modern definition of "membrane voltage" (i.e. cell membrane voltages are negative when hyperpolarized). This definition of voltage differs from the original Hodgkin and Huxley (1952) paper but is more convenient. The functions define rate per sec.

Example:

Definition of alpha and beta for the "m" parameter

func calcna1m (v, func)

/* Calculate Na rate functions given voltage in mv.  
   All rates are calculated exactly as in HH (1952) paper.
   Original rates were 1/msec, we multiply by 1000 here (MSSEC)
   to convert to 1/sec.

   The "func" parameter defines:

    1   alpha m
    2   beta  m */
{
     local val,x,y;

  if (func==1) {                                /* alpha m */

    y = -0.1 * (v+40.);
    x = exp (y) - 1.;
    if (abs(x) > 1e-5)                          /* singularity at v = -40 mv */
       val = y / x * MSSEC
    else
       val = 1.0 * MSSEC;
  }
  else if (func==2) {                           /* beta m */

    val =  MSSEC * 4 * exp ((v+65) / -18.);
  };
  return val;
};                                                                             
At the beginning of each "run", this subroutine is used to calculate alpha for "m" to make the lookup table used by the channels during the run. The name used to define the function is set in the "mak???()" procedure that defines each channel type. For more details on adding new channels, see Section 6, "Adding new channels".

Click here to return to Channel statement index

Adding new channel types

New channel types can easily be added to NeuronC by specifying additional transition tables and rate constant functions. These must be programmed in "C" and are located in separate files (e.g. "channa1.cc", "channa2.cc", etc). See Section 6, "Adding New Channels".

Distributed macroscopic channels are available for cable membranes and are defined much like the "chan" statement, except that their maximum conductance is defined as a function of the membrane area and not as an absolute conductance. Multiple types of channels may be defined by including multiple channel options in sequence after the "cable" statement. See "cable".

Click here to return to Channel statement index

Channel condensation

After compartments are condensed (see "Compartment condensation above in "Cable"), the membrane channels in a compartment are condensed. The reason is to give an advantage in CPU speed by eliminating unnecessary "data structures" in the simulation. When channel noise is defined, a channel can represent an arbitrary number ("N") of unitary conductances at the same point in a neuron, since they all receive the same voltage stimulus at the compartment where they are defined. Multiple channels of an identical type are formed when channels are placed in compartments that eventually get condensed with their neighbors. By condensing the channels, one channel structure can represent all the unitary conductances of the same type at the compartment.

Each channel is checked against every other one in the compartment to see if they are identical in their properties (vrev, voltage offset, tau, unitary conductance). If they are, their conductances and values of "N" (number of unitary conductances) are added together. The value of N is a floating point number so if the channel conductance is low, the fractional channels from several compartments can add to give a final value of N greater than 1 (or higher integer). After this process, the value of N is rounded up to the nearest integer so the channel stochastic noise computations can be correctly run with the binomial distribution (see "Markov noise") below.

To see this process work, you can set the "lamcrit" variable or the "-l" command-line option: a lamcrit value of 0 prevents condensation of any kind so you get lots of compartments. Setting lamcrit to .001 prevents compartment condensation but activates channel condensation, and a value of lamcrit in the range 0.1-1 will give both compartment and channel condensation. Use the "nc -p 1" option to print out the compartments and channels.

Click here to return to Channel statement index

Load

at <node> load <expr> [vrev <expr>
This defines a load resistor in series with a battery which connects to the membrane leakage at a node. Calibrated in ohms. Can be used to simulate a synapse, photoreceptor, or membrane channel.

Resistor

conn <node> to <node> resistor <expr> 
This defines a series resistor between two nodes which acts exactly like a gap junction. Calibrated in ohms.

Gndcap

at <node> gndcap <expr> 
This defines a capacitor which adds to the membrane capacitance in a node's compartment. Calibrated in farads.

Cap

conn <node> to <node> cap <expr> 
This defines a capacitor which connects two compartmemnts. The addition of this element makes the model unstable and it must be run slowly with the "implicit" mode turned on for stability. Calibrated in farads.

Batt

conn <node> to <node> batt <expr>
This defines a battery connected between two compartments. The addition of this element makes the model slightly unstable and it must be run with "implicit" mode turned on for stability. Calibrated in volts.

Gndbatt

at <node> gndbatt <expr> 
This defines a battery connected between a node and ground. Calibrated in volts.

Statements for describing stimulus, recording, and running

These statements are used to complete the description of an experiment after a neural circuit is defined. They may all be included in programs as any other NeuronC statement, but they do not start with the node connection as do the neural element statments.
     stimulus             light, voltage or current clamp stimulus
     plot                 make continuous plot of a node during run
     graph                graph any variables at end of step or run
     display              display the neural circuit on screen
     step                 run for short time and stop to allow graphing
     run                  run simulation continuously for high speed

Expressions that "record" values:

V, I, L return voltage (current,light) at a node FA0-4,FA9, FB0-4, FC0-4 return synaptic neurotransmitter from filter stage G0-8 return channel conductance or state concentration (see paragraphs below for specific descriptions)

Stimulus

stim node <node> vclamp=<expr> start=<expr> dur=<expr>
stim node <node> cclamp=<expr> start=<expr> dur=<expr>
stim node <node> puff <ligand>=<expr> start=<expr> dur=<expr>
where:
                        unit:
     vclamp    =<expr>  (volts)       set voltage for clamp 
     cclamp    =<expr>  (amperes)     set current for clamp
     start     =<expr>  (sec)         time to start stimulus
     dur       =<expr>  (sec)         duration of stimulus after start
     puff <nt> =<expr>  (M)           puff ligand

     Ligands available for "puff ":

        GLU AMPA NMDA CNQX 
        GABA BIC PTX 
        GLY STR 
        cAMP cGMP
  
The "stim node" statements define node stimuli. To stimulate a single node, a voltage or current clamp may be used, in which case the node current or voltage, respectively may be be plotted. An I/V measurement can be performed by placing a "stim node" statement inside a "for" loop. These statements are not interpreted by the program "stim" (see below).
stim cone <node> inten=<expr> start=<expr> dur=<expr>
stim rod  <node> inten=<expr> start=<expr> dur=<expr>
where:
     inten =<expr>  Q/um2/sec         intensity of stimulus
     start =<expr>  sec               time to start stimulus
     dur   =<expr>  sec               duration of stimulus after start
     wavel =<expr>  nm                wavelength (also, sun, tungsten or xenon)         
The "stim cone" and "stim rod" statements allow single photoreceptors to be given a point-source light stimulus. These statements are not interpreted by the "stim" program (see below). See below for explanation of parameters.
stim spot <expr> loc (<expr>expr)) blur=<expr>
                     inten=<expr> start=<expr>
dur=<expr>

stim bar  <expr> loc (<expr> blur <expr>
                     inten=<expr> start=<expr> dur=<expr>

stim sine <expr> loc (<expr>,<expr>) blur=<expr>
                     inten=<expr> start=<expr> dur=<expr>
                     sphase=<expr> orient=<expr> tfreq=<expr>
                     drift=<expr> contrast=<expr> 

stim gabor <expr> loc (<expr>,<expr>) blur=<expr>
                     inten=<expr> start=<expr> dur=<expr>
                     sphase=<expr> orient=<expr> tfreq=<expr>
                     drift=<expr> contrast=<expr> 
                     xenv=<expr> yenv=<expr> 

stim file <filename>

stim backgr <expr>

stim center (<expr>,<expr>)
where:
                       units:
     spot     <expr>   um                 diameter of spot
     bar      <expr>   um                 width of bar
     sine     <expr>   um                 spatial period of sine wave grating
     gabor    <expr>   um                 spatial period of gabor wave grating
     loc     (<expr>,<expr>)              spatial location or (xmin,xmax) for stimulus
     blur   = <expr>   um  [optional]     dia (at 1/e) of Gaussian blur func.
     sscale = <expr>   default=1          resolution of blur convolution 
     inten  = <expr>   Q/um2/sec          intensity of stimulus
     start  = <expr>   sec                time to start stimulus
     dur    = <expr>   sec                duration of stimulus after start
     backgr = <expr>   Q/um2/sec          intensity of background
     wavel  = <expr>   nm                 wavelength (also, sun, tungsten or xenon)
     contrast=<expr>   (L1-L2)/(L1+L2)    fractional contrast of grating
     tfreq  = <expr>   Hz (cy/sec)        Temporal frequency 
     drift  = <expr>   0                  = 1 -> Drifting grating 
     sphase = <expr>   deg [optional]     Spatial phase (offset) for grating
     orient = <expr>   deg [optional]     Orientation from vertical
     xenv   = <expr>   um [optional]      Radius of X Gaussian envelope (gabor only)
     yenv   = <expr>   um [optional]      Radius of Y Gaussian envelope (gabor only)
The "stim spot", "stim bar", and "stim sine" statements allow large fields of photoreceptors to be given an optical stimulus. These statements are interpreted at run time by "nc" so that the photoreceptor receives the appropriate amount of photon flux. Stimuli are additive so multiple simultaneous stimuli may be given without interaction. "nc" does no blurring at run time.

Optical blur and scatter

For more realism, the "stim" program can generate stimuli with optical blur and light scatter (see section 6 on running "stim"). "Stim" ignores neural element statements (except photoreceptors) and operates only on the stimulus and photoreceptor statements. The blur is a Gaussian function, defined by its diameter at 1/e of peak amplitude. This blur defines a convolution of the stimulus (from one or more "spot", "bar", or "sine" statements above) with the appropriate optical blur function. Only one convolution is performed (i.e. no separate convolution is performed to simulate the effect of photoreceptor aperture). However the effect of photoreceptor aperture can be simulated by 1) increasing the size of the stimulus (i.e. increasing a point-source stimulus into a spot the size of the photoreceptor aperture) or 2) increasing the size of the optical blur Gaussian. See the description of "rod" and "cone" photoreceptors for more details on this process.

Stimulus convolution

The stimulus convolution is performed on 2-dimensional arrays normally at a resolution of 1 micron. The size of the stimulus convolution array is equal to the sum of the photoreceptor array size and "blur array" size (5 x the Gaussian blur diameter). This implies two things: 1) all stimuli within reach of a photoreceptor will always fall within the stimulus array, and 2) the stimulus array becomes very large with large photoreceptor arrays or wide blurs. Although all the location and size parameters for stimuli can be specified in "floating point" (i.e. they may have fractional parts) the convolution is done with location coded as an integer.

To run the convolution at finer resolution than 1 micron in the stimulus position, set the "sscale" parameter which magnifies the resolution of the convolution arrray (e.g. sscale=.2 means magnify by 5 times). Of course, if you don't require blur, you will not require the convolution and therefore don't need a stimulus file or the "stim" program to generate it. In that case, full "floating-point" precision (6 decimal places) is available for the stimulus position.

The convolution that "stim" performs goes as follows: for each photoreceptor, each element in the "blur" array is multiplied by the corresponding element in the "stimulus" array. The sum of these multiplications becomes the stimulus intensity for the photoreceptor. In order to save space, the "blur" array is made only large enough to hold the Gaussian blur. The array is created with a radius of 5 times the standard deviation of the Gaussian blur specified by the "stim" statement. If the "sscale" factor is defined smaller than 1, the blur array is made larger.

Stim file

The computation of a blurred stimulus takes a lot of time, so normally "stim" is run once on a NeuronC program file and generates a "stimulus file" which contains stimulus events, one event per receptor at a certain time. Thus if the same stimulus and photoreceptor locations are used in many different NeuronC runs, the stimulus file need only be generated once. The "stim file" statement defines for "stim" which file to generate, and the same statement tells NeuronC which file to read for the stimulus event list. If a "stim file" statement is defined before other "stim" statements, NeuronC ignores all other light stimulus statements in a program.

To make the stimulus file, run "stim" on the simulation program that contains the "stim file" statement. "stim" will create the stimulus file automatically. Thereafter, "nc" may be run on the same simulation program, reading its stimulus from the stimulus file defined in the program. The "stim file" contains one line for each change of light intensity for each photorecptor. The "stim file" is a text file and you may view and modify it with a text editor. It is written (by "stim") by the subroutine "stimfmout()" in file "stimsub.c" and is read (by "nc") by the subroutine "readstim()" in file "ncstim.c".

Large stim files may be compressed with "gzip" which will add ".gz" onto the end of the file name. If the compressed stim file exists and the original does not, "nc" will read the .gz file and decompress it with the "zcat" command. The .gz file size is typically 10% of the original text version. For this scheme to work properly, both "gzip" and "zcat" must be avalable in your shell PATH environment variable.

Sine

The "stim sine" statement produces a sine-wave grating with the given spatial period. If the "orient" parameter is not set, the grating is oriented vertically (parallel with the Y-axis). The "sphase" parameter defines the spatial phase in degrees; if it is not defined the sine wave starts from zero at the center of the grating (see "loc" below). The "tfreq" parameter sets the temporal drift frequency, calibrated in Hz. If no "drift" parameter is given (or if it is set to zero), the stimulus is a static grating. The "drift" parameter sets the grating in motion. Positive values mean drift left -> right (drift can range from 1 to -1). Note that for a constant "tfreq", different drift rates (um/sec) are produced with different spatial periods. The spatial extent of the grating is defined by the "loc" parameters. Two numbers inside the parentheses define the mininum X and maximum X limits; note that many complete sine-wave cycles may exist within these limits. If no X limits are given, the sine-wave grating limits have default values of (-1000, 1000) microns. Y limits can also be included along with the X limits in the "loc" parameter like this:

loc (xmin,xmax,ymin,ymax) 

Gabor

The "stim gabor" statement produces a 2D Gabor function with the given spatial period. If the "orient" parameter is not set, the grating is oriented vertically (parallel with the Y-axis). The "sphase" parameter defines the spatial phase in degrees; if it is not defined the sine wave starts from the position defined by the "loc (X,Y)" parameter (note that this parameter has a different meaning in the "stim sine" statement). The "tfreq" parameter sets the temporal drift frequency, calibrated in Hz. If no "drift" parameter is given (or if it is set to zero), the stimulus is a static grating. The "drift" parameter sets the grating in motion. Positive values mean drift left -> right (drift can range from 1 to -1). Note that for a constant "tfreq", different drift rates (um/sec) are produced with different spatial periods. The spatial extent of the grating is defined by the "xenv" and "yenv" parameters, which define the radii of the X and Y dimension Gaussian envelopes for the Gabor function. Note that many complete sine-wave cycles may exist within the envelope. If no xenv and yenv values are given, the they default to 10 um spatial period.

Wavelength

The "wavel" parameter specifies the spectral properties of the stimulus. A number defines the wavelength of a monochromatic light stimulus. It is also possible to give a "white" stimulus by specifying "sun", "tungsten" or "xenon" instead of a numerical value for "wavel". Wavelengths are limited to between 380 and 800 nm. Photoreceptor sensitivities are calculated from action spectra tables at 5 nm intervals, quadratically interpolated between points. When a spectrally extended light source is selected (i.e. sun, tungsten, xenon), its intensity is normalized using the appropriate scotopic or photopic luminosity function so that responses may be compared across photoreceptors and light sources.

Center

The "stim center" statement defines for the "stim" program the location of the center of the array used for calculating the light distribution. The stimulus array is of a limited size (512 x 512), so it is sometimes necessary to move the array to preserve an offset stimulus. Normally the location for the center is (0,0) which is the default.

Background intensity

The "stim backgr" statement defines a background level for all receptors. This is normally used once for the beginning of a simulation run, but can be used several times during a run. A new background value defined by the "backgr" statement supercedes an old one. The "backgr" statement erases any stimuli currently in effect, so if you're using another stimulus and want to simultaneously change the background, use a very large spot for the background.

Note on where to place "stim" statement:

It is possible to write a "stim" statement that looks correct but does not generate the stimulus correctly. For example, if timinc=1e-4 and you give a time step of 0.01111111, the simulator will run for 0.0112 sec which is .01111111 rounded up to the next larger interval. This is usually not a problem, but if you place the "step" statement inside a "for" loop along with "stim" statements, you may find that the stimuli are not being started at the correct times because of the "roundoff" problem stated above. The way to correct this problem is to make 2 separate "for" loops, one to generate the stimuli, and one to run the "step" statement:

  timinc = 0.0001;
  steptime = 0.011111111111;       /* not integral mult of timinc */
  for (i=1; i<n; i++) {
     stim .... start=i*steptime dur=steptime;  /* correct to 0.0001 sec */
  };
  for (i=1; i<n; i++) {
     plotarr[i] = V[node1];
     step steptime;                /* step 0.0112, but maybe acceptable */
  };
When the "stim" statements are all executed before the first "step" statement, they are all run in "construction mode" before the model starts, so they are correctly synchronized with the integration time step. Another solution is to use the "time" variable which always has the correct time updated by the "step" statement:

  timinc = 0.0001;
  steptime = 0.011111111111;             /* not integral mult of timinc */
  for (i=1; i<n; i++) {
     plotarr[i] = V[node1];
     stim .... start=time dur=steptime;  /* may give blank betw.  stimuli */
     step steptime;                      /* still steps 0.0112 sec */
  };

Note on the "stim" program:

The "stim" program ignores the "stim vclamp", "stim cclamp", "stim rod" and "stim cone" statements, and therefore these stimuli will not produce an entry in the stimulus file. Instead these statements are always interpreted by the "nc" program. This allows running a neural circuit with one stimulus file but different microscopic stimuli such as voltage or current clamps, or individual photoreceptors.

Plot

The plot statement is used to plot a continuous record from a node, stimulus or variable, and has been optimized to run very fast. Plotting works only during a "run" statment (see below) and thus does not work when NeuronC is setting up a network or after a "run" statement is finished (after "endexp" time).

The printout of the "plot" statement represents the value of stimulus and record parameters at the beginning of the time step, before the simulator integrates to the end of the timestep and computes the voltage values. This means that after a "step" statement, the last plotted values are not always the most recent ones available. Normally this is OK because in a series of "step" statements the next "step" allows the "plot" statement to print out the next set of values. If you want the last plot statement to correctly reflect the ending values, set the "endexp" variable to the ending time of the simulation. When the simulation time equals the value of "endexp", the "plot" statement adds one last printout of the values of stimulus and record parameters that are valid at the end of the last time step. The plot statment has several forms. If the voltage at several nodes needs to be plotted at the same scale, a combined plot statement may be used:

plot V [<node>]
plot V [<node>] V[<node>] ...
plot V [<node>] max <expr> min <expr>
plot V [<node>] max <expr> min <expr> <options>
where:
     [<node>]             = 1-, 2- or 3-D node number; must have brackets.
     max <expr>  (volts)  = maximum voltage for vertical plot axis
     min <expr>  (volts)  = minimum voltage for vertical plot axis
     plmin, plmax are default values for max and min 
        when not specified.

     <options> =  pen <expr>           sets color of single plot. 
                  char 'x'             char labels with lines. 
                  Char 'x'             char labels without lines.
                  size <expr>          size of char point label.
                  filt <expr>          lowpass filter (tau in sec).
                  filt [<expr>,<expr>] cascade lowpass filter.
These statements plot the voltage as a function of time at the nodes specified on a single graph. If "max" and "min" are left out of the statement, the voltage scale (ordinate) is defined by the variables "plmax" and "plmin". These variables are set by default (plmax = 0.04, plmin = -0.07) to the normal physiological range of neurons, and in many cases they need not be changed. The variable "endexp" (length of the experiment) sets the time scale (abscissa), and the "ploti" variable sets the time resolution of the plot.

Several "plot V[]" statements may be used to cause several plots to be displayed on one graph, but with different scales. The first one defined determines the scale actually plotted on the vertical axis, but the rest simply use their own scale and ignore the scale numbers on the graph. The "filt" option inserts a lowpass filter in the plot to reduce the bandwidth of the recorded signal. The value given sets the time constant of the filter in seconds (1/2*PI*F). You can also set a cascade of filters: plot .... filt [ 3.2e-5, 1.6e-6, .8e-5]; This plot filter would have a cascade of filters in series with cutoff frequencies of 5KHz, 10KHz, and 20KHz.

plot I [<node>] max=<expr> min=<expr> <options>
where:
     [<node>]              = 1-, 2- or 3-D node number; must have brackets 
     max=<expr>  (amperes)  = maximum current for vertical plot axis
     min=<expr>  (amperes)  = minimum current for vertical plot axis
     <options>              = pen and char statements as in plot above. 
This statement plots the current passed through the electrode of a node which has been voltage clamped. It works exactly like the "plot V[]" statement in that several plots of current and/or voltage can be combined on the same graph with different scales. If a current clamp is connected to the node, without a voltage clamp, the "plot I[]" statement plots the current passed through the current electrode.
plot L [<node>]  max <expr> min <expr>
where:
     [<node>]                   = 1-, 2- or 3-D node; must have brackets
     max <expr>  (photons/sec)  = maximum "inten" 
     min <expr>  (photons/sec)  = minimum "inten" 
     <options>                  = pen and char statements as in plot above. 
This statement plots the number of photons absorbed by a photoreceptor at a node, can plot on the same graph as other plot statements. It is useful for determining single photon events or plotting the stimulus timing on the same graph as the voltage or current in a node. "max" and "min" determine the scale for plotting. Remember, the number of photons absorbed is related to light intensity and photoreceptor absorbing area.

plot FAx <element expr>
plot FBx <element expr>
plot FCx <element expr>
plot Gy <element expr>

plot FAx <element expr>   max=<expr> min=<expr>
plot FBx <element expr>   max=<expr> min=<expr>
plot FCx <element expr>   max=<expr> min=<expr>
plot G(s)  <element expr>   max=<expr> min=<expr>
plot G(g)  <element expr>   max=<expr> min=<expr>
plot G(hh) <element expr>   max=<expr> min=<expr>
plot nt    [<node>]     max=<expr> min=<expr>
plot Ca(z) [<node>]     max=<expr> min=<expr>

where:
     x = 0 - 4                = filter number  
     s = 0 - 12               = state number
     g = vrev, I, CA          = params for any channel type
    hh = H, M                 = params for HH channels
    nt = GLU,AMPA,NMDA,       = ligands
         CNQX,GABA,BIC, 
         STR,GLY,STR, 
         cGMP,cAMP
     z = I,IP,IE,IPE,VREV     = params at a node with Ca chans
     z = 0, 1, 2 ... n        = [Ca] in shells, 0=outside, 1=inside, 100=core

and:
     <element expr>     = number or variable describing a synapse, 
                             from "ename" clause. 
     max=<expr>         = maximum for plot, value depends on filter 
     min=<expr>         = minimum for plot, value depends on filter
This statement plots the neurotransmitter time functions inside a synapse or channel. The synapse (channel) is identified using an "ename" in its definition statement, when it is first made (see "ename" and "modify" below). Thereafter, the synapse (channel) can be referred to by a unique value (its element number) retrieved from the "element".

The FA0-FA4 values are pre-release time functions, calibrated in "volts above synaptic threshold". FA9 gives the instantaneous "trel" (transmitter released) vesicle release rate in vesicles/sec. The FB0-FB4 values are post-release functions and represent the concentration of neurotransmitter in the synaptic cleft. FB0-4 range from 0 to 1000, where a value of 1 represents the half-saturation point for the static post-synaptic saturation function. The FC0-FC4 values are post-saturation conductances. They return a value normalized to the range 0 - 1. This value is multiplied by the "maxcond" parameter to set the post- synaptic conductance. The values FA0, FB0 and FC0 return the input to their respective filter functions.

Using the "G", "G(1)-G(12)" expressions, the channel internal states may be recorded (see "plot" below). The expression "G(0) <expr> records the channel conductance in a manner similar to the "FCx" expression (calib. in S). For a "sequential-state" type of channel (type 1), the "G(x)" (x=1-12) expression records the channel state concentrations, (dimensionless fractions of 1). Each of these plot expressions has a default max and min to set the graph scale (e.g 2, 0 for states, 100e-6 for nt, etc.)

For all channel types:

    G          channel conductance (Same as G(0) or G0)
    G(I)       ionic current through channel
    G(vrev)    vrev (reversal potential)
    G(Ca)      Calcium current through channel (if Ca, NMDA, cGMP chan)
For HH channel types:

    G(M)       m (if Na chan) or n (if K chan), or c (if Ca chan), frac of 1.
    G(H)       h (if inactivating type)
For sequential-state Markov types:
    G          channel conductance (Siemens)
    G(0)       channel conductance (Siemens)
    G(1)       amplitude of state 1 (Fraction of 1, or population if "chnoise")
    G(2)       amplitude of state 2
    .
    .
    .
    G(n)       amplitude of state n.
Note that the number inside the parentheses is a numerical expression and can be a variable or a function. At a node with a calcium channel:
    Ca (0)      cao = [Ca] outside
    Ca (1)      cai = [Ca] inside at first Ca shell
    Ca (2)      [Ca] at second shell
    .
    .
    .
    Ca (n)      [Ca] at nth shell
    Ca (100)    [Ca] in core
    Ca (vrev)   local reversal potential for Ca
    Ca (I)      total Ca current through Ca channels and pumps
    Ca (IP)     Ca current through pump
    Ca (IE)     Ca current through exchanger
    Ca (IPE)    Ca current through Ca pump and exchanger
[ Note that exchanger current Ca(IE) includes Ca and Na currents, and that it is dependent on Vrev of Ca and Na.]

If the channel is a Na type 4 (Integrate-and-Fire)

    G(0)        channel conductance
    G(1)        population of state 1
    G(2)        population of state 2
    G(3)        integration state
    G(4)        state switching
To look inside a rod or cone transduction element, the G(0) - G(9) values plot:
   G(0)    conductance
   G(1)    rhodopsin
   G(2)    meta rhodopsin I
   G(3)    meta rhodopsin II (R*) activates G protein
   G(4)    G protein 
   G(5)    PDE
   G(6)    G cyclase  
   G(7)    cGMP   
   G(8)    Ca feedback for recovery and adaptation
   G(9)    Cax (protein between Ca and G cyclase)
plot S variable max <expr> min <expr> This statement plots the value of any symbol (variable) together with other plot statements.

Record and graph

V [<node>                           voltage at node
V @ cable <element expr> : <expr>    voltage along cable
I [<node>                           current
L [<node>                           light 
FAx <element expr>             pre-synaptic filters
FBx <element expr>             post-release filters
FCx <element expr>             post-saturation filters

G(s)                   populations of Markov states 
G(g)                   ionic conductance
G(hh)                  HH M and H state variables
nt    [<node>]                 concentration of ligand at node 
Ca(z) [<node>]                 concentration of Ca in shells

These functions return the values of voltage, current, or light absorbed, respectively, at any node. The node may be 1-, 2-, 3-, or 4-dimensional. For instance, the record function "V[]" can be used to find voltages at pre- and post-synaptic nodes, and these voltages may be plotted (see explanation above) or graphed (see programming example below). The "I[]" statement returns the currrent injected at a node through a voltage clamp if present. When a current clamp is present without a voltage clamp (the ususal case), the "I[]" statement returns the current clamp's current.

The synaptic filters return values between 0 and 1 representing the amount of neurotransmitter released (see "plot" above). The "FAx", "FBx", and "FCx" synaptic filter functions require an element number which has been set through the "ename" clause in the original definition of the synapse.

The value G0 returns the total channel conductance, and the values G1-G8 return the concentrations of the states 1-8 respectively, or in the case of Hodgkin-Huxley type channels, G1,G2 return "m","h" for the Na channel, and G1 returns "n" for the K channel.

graph X max=<expr> min=<expr>
graph Y max=<expr> min=<expr> <options>
     For setting X and Y scales of graph axes and initial color.
     where:
      <options> = pen <expr>     sets color of single plot.
                  char 'x'       char labels points with lines.
                  Char 'x'       char labels points without lines.
                  filt <expr>  lowpass filter (tau in sec)
                  filt [<expr>,<expr>]  cascade lowpass filter
graph init
     For drawing graph axes on screen.

graph restart
     For resetting graph so lines don't connect to 
      previous lines.

graph pen (<expr>, [<expr>]  ... )
     where <expr> is the number of color (1-16 on VGA and X screen)
     For changing pen color of lines on graph between plots,
     after the axes have been drawn. The differnt <expr>
     numbers are the colors assigned respectively to different plots.
     A color of -1 means do not display.

graph (<expr>,<expr>)  
     where:
          (<expr>,<expr>) is an (x,y) point to be graphed.
     Draws a new point by connecting it to others with line.
The graph statement allows the display of variables before or after a "run" or "step" (not while running!). Graphed points are connected by lines, in a color specified by the "graph pen" command. Both x and y axes must be initialized (with "graph X ..." and "graph Y ..." statements) to allow the graph scale to be set up and the graph axes labeled. The "graph (x,y)" statement then plots a sequence of points as connected line segments. The "restart" command allows multiple sets of points connected by lines to be drawn on the same grid. Any variable (or node voltage/current/ intensity) may be plotted. Calibrated in same units used to record.

The graph statement is useful for displaying parametric equations like I/V plots, where both are functions of time. In this case, the "step" statement can be used to set up a short simulation which can be continued to gather further graph points:

Example:

graph X max -.01 min -.08;              /* volts */
graph Y max -2e-11 min -6e-11;          /* amps  */
graph init;
graph pen (4);

for (i=0; i<10; i++) {
  stim node 1 vclamp i * -.01 start i * .02 dur .02; /* sweep voltage */
  step .02;                             /* wait for equilbration */
  graph (V[1], I[1]);                   /* graph result */
};
graph restart;                          /* this time stim node 2 */
graph pen (2,3);
for (i=0; i<10; i++) {
  stim node 2 vclamp i * -.01 start i * .02 dur .02; /* sweep voltage */
  step .02;                             /* wait for equilbration */
  graph (V[1], I[1]);                   /* graph result */
};

Graphs, plots, and frames

With the use of the "gframe", "gorigin" and "gsize" statements, it is possible to arrange several graphs on the screen (or a page on printout). By placing a "gframe" statement before "graph" or "run" statements, the graphical output is directed to a subset of the screen (called a "frame") which may be scaled smaller than, and translated with respect to, the screen. For more information about these statements, see "Graphics statements",at the end of this section.

Example:

        gframe "gr1";
        gorigin (0.2,0.2);
        gsize (0.5);

        code that generates graph or plot in smaller frame
        .       .       .
        gframe "..";
        code to draw on overall screen
        .
        .
        .
        gframe "gr2";
        gorigin (0.6,0.2);
        gsize (0.4);

        code to generate second small graph
        gframe "..";

        etc.

Display neural circuit

display matching             <node>           'parameters'
display <elemtype> matching  <node>           'parameters'
display range                <node> to <node> 'parameters'
display <elemtype> range     <node> to <node> 'parameters'
display connect              <node> to <node> 'parameters'
display <elemtype> connect   <node> to <node> 'parameters'
display element <expr>                        'parameters'
display stim at <expr>                        'parameters'
optional parameters:
    xrot = <expr>       
    yrot = <expr>
    zrot = <expr>
    color =<expr>       
    except matching <node>
    except <elemtype> 
    except <elemtype> matching <node>
    hide
    size  =<expr>
    dscale=<expr> 
    rmove  (<expr>,<expr>)ltexpr>
    center (<expr>,<expr>)
    calibline=<expr>
    calibline=<expr> loc (<expr>,<expr>)
where:
    parameter:     default:      meaning

    xrot, y, z    0 degrees     x,y,z rotation of anatomical circuit.
    color         see below     color of matching elements displayed.
    except        none          prevent display of selected elements. 
    size          200 um        size of display window.
    dscale        1.0           display object at different size.
    rmove         (0,0,0)       display object displaced by (x,y,z)
    center        1/2 of size   location of display window.
    hide          no hide       hidden-line removal.
    calibline     none          calibration line in microns
    <elemtype>     =            One of: "cable", "sphere", "synapse","gj",
                                "rod", "cone", "load", "resistor","cap",
                                "gndcap", "batt", "gndbatt", "chan","vbuf",
                                "node", "comps". 
The display statement is used to display neural circuit anatomy. The display statement only works in "nc" with the "-d 1" switch (or with "nd"), otherwise all display statements are ignored. This feature allows you to either display or run a neural circuit model without changing its descriptor file. You can display a "photographic" view of your neural circuit using "nc -d 1 -R" (or "nc -R"), in conjunction with "povray", a 3D ray-tracing program.

The selected neural elements appear on the screen with the view selected by appropriate rotation and "center" commands. Each neural element is displayed with a simple icon in a position corresponding to its location in the circuit. In order for neural elements to be displayed in their proper place, the location of each node must be defined with the "loc (x,y)" clause when a node is set up with a statement beginning with "at" or "conn". (If this is not done, the location of a node is 0,0,0). Note that rods and cones also have a location for their transduction element, which is not necessarily the same as their node's location. For example, to set up a cable connected to a sphere, you could say:

     at   [1][3]           loc (10,10) sphere dia 5;
     conn [1][3] to [2][4] loc (10,20) cable dia 1 length 10;
The "display matching <node> statement displays all the neural elements matching the "<node> value given, including elements that are located "at" the node or those that are "connected" to it. A "<node> value in the "display" statement can match a neural element with more node dimensions. In this case, the match ignores the extra node dimensions. For instance, in the example above, the statement:
    display matching [1]; 
matches a "1" in the first dimension, but ignores the second and third dimensions. In this case, it displays both the sphere at node [1][3] and the cable from [1][3] to [2][4]. Any dimension can be specifically excluded from the match by including a negative number in that dimension. For example,
    display matching [1] [-1] [5];
matches any node with 1 in its first dimension and 5 in its third dimension. The second dimension is ignored.

Meaning of dimensions

This system of matches is useful when node dimensions are given specific meanings. It is useful, for example, to use the first dimension for neuron type, the second dimension for neuron number, and the third dimension for morphology within a cell. Then it is possible to display all neurons of a given type with a simple "display [n]" statement (where n is the neuron type).

The addition of "only" to the ""display matching <node> statement displays only those neural elements "at" the "<node> given, or those elements that connect exclusively with that "<node> Given the circuit in the example above:

     display matching [1][3] only;
would display only the sphere, not the cable. This is useful to display a neuron but none of its connections to other neurons.

The "display connect <node> to <node> statement displays all the neural elements that match and connect to both "<node> values. For instance, in the example above, the statement:

    display connect [1] to [2];
would display the cable from [1][3] to [2][4]. Any dimensions not defined by the "display" statement are ignored, as described above.

The "display range to " statement displays all the elements with node numbers between node1 and node2 inclusively. This is useful for displaying nodes that have been organized in numerical order.

The display element <expr> statement displays one neural element that has been remembered with the "element <expr> statement. This is useful for displaying one specific element of several that connect to identical nodes.

Qualifying the display

The display matching, display range, and display connect statements may be qualified to an element type by inserting the element type like this:
     display matching [5][1];                  displays any element type
     display sphere matching [5][1];           displays only spheres

Displaying node numbers

To display node numbers in their proper 3D locations, insert the keyword "node" as a qualifier. You can vary the size of the displayed number with the "dscale" parameter.

     display node matching [5] dscale 2;       displays node numbers   
For multidimensional nodes, to display just one of the numbers, negate it and subtract the dscale parameter divided by 10. The example below displays the second node number with an effective "dscale" of 1.5:

     display node matching [5] dscale -2.15 ;     

Displaying compartments

To display compartments and their connections, insert the keyword "comps" as a qualifier. Then use the variable "disp" or the command line switch "-d n" (n=1-4, see Section 6, "nc") to display various combinations of neural elements, compartments or connections. The rationale for this scheme is that one often would like to change what objects are displayed without modifying the script.

     display comps matching [5][1];       
This statement displays only compartments and/or their low- level connections that have been translated from neural elements matching a node. A compartment is displayed as a sphere with a size that would have the compartment's resistance and capacitance. A connection is displayed as a yellow line between compartments. The compartment and connection display is useful for "tuning" the variable "lamcrit" which controls the minimum size of compartments.

Redefining neural element icons

To re-define the "icon" used to display a neural element, put a procedure like this in your "nc" script file, in a location in the file before it will be used:
proc phot_dr (pigm, color, dia, foreshortening, hide) {
    gpen (color);
    gcirc (dia/2,0);
};
Currently only photoreceptor ("phot_dr") and synapse ("synap_dr") icons can be re-defined. It is easy to add new procedures in the "nc" source code for other neural elements.

You can use or ignore any of the parameters to the procedure. The "pigm" and "dia" parameters are the numbers you set (or were set by default) for the photoreceptor definition. The "color" parameter is defined by the following search: if your "display" statement defines a color, then this is used, otherwise a standard color representing the pigment type is used. The "dist" parameter represents the amount of foreshortening of the object's icon by the rotation it undergoes (see below). The "hide" parameter is set to 1 whenever "hide" is set, in which case the icon should be a closed unfilled outline, i.e. a polygon.

Just before your procedure is called, the "graphics pen" is moved to the (x,y,z) location of the photoreceptor and a graphics sub-frame is initiated that is rotated with respect to the root frame. If the icon is oriented (e.g. extended vertically like a photoreceptor), you draw it horizontally to the right (i.e. horizontal is "zero" degrees rotation). The icon may be foreshortened by some 3D rotations, so to correctly take this foreshortening into account, multiply its length by the "forshortening" parameter. This parameter varies from 0 to 1. If you ignore the foreshortening, your icon will be displayed the same size no matter what rotation.

You can use any graphics commands to draw the icon. The graphics scale is in microns but this can be changed with "gsize()".

Names of user-defined icon procedures:

  photoreceptor 
    "phot_dr" (type, pigm, color, dia, foreshorten, hide)

  synapse          
    "synapse_dr" (color, vrev, length, dia, hide)

  gap junction                        
     "gapjunc_dr" (color, length, dscale, hide)

Except

The "except" clause allows you to prevent display of a selected set of elements connected to nodes. The syntax is the same as for the "matching" statement. Thus:
    display matching [1][-1][5] except sphere [-1][2];
   
This displays all the elements connected to nodes [1][-1][5] except spheres connected to [1][2][5].

Color

Each type of neural element has a default color. The neural element is displayed in this color when no color parameter is given, or when the color is zero. If a "color" parameter is used, it sets the color for all neural elements that are displayed by the statement. The color is reset between statements so that each statement uses the default color or must have its own color parameter.

Color as display of voltage

You can display the voltage of a neuron by displaying it with a color of greater than 32768 (2^15). The range of colors is distributed between the range of the voltage range variables "plmax" and "plmin". The colors range from the cool colors for "plmin" to the warm for "plmax".

dscale and rmove

The "dscale" parameter causes the icon of a neural element to be displayed in a different size than normal. This is useful when the icon would otherwise "get in the way" in a picture.

The "rmove (x,y,z)" parameters cause the objects selected to be displaced (translated) during display. This is useful for "pulling apart" a neural circuit into its separate neurons. This feature is used within one statement only.

Display stim

To display a light stimulus, use the "display stim at statement. This statement is followed by an expression for the time at which to display. It displays the light intensity at each photoreceptor at the photoreceptor's (x,y) location. The intensity is coded in color using a lookup table, with white and red the maximum and blue the minimum intensities. The stimulus may originate from a ".t" stimulus file generated by "stim" or may originate entirely from "nc" itself without any stimulus file. The stimulus may be created by the "stim spot", "stim bar", "stim sine", "stim rod", or "stim cone" statements.

Defaults

The parameters "xrot,yrot,zrot", "size", and "center" have default values, which are used when no value is given. If you are defining values for these parameters, you need only define them once for multiple display statements because their values are conserved between display statements.

Ename

The "ename" clause allows a neural element to be accessed by a unique identifier (number), either for later selection, modification, or display.
   conn <node1> to <node2> synapse <synaptic params> ename <var>
A unique identifier is assigned to the variable whose name is given after the "ename" keyword. That specific individual neural element can be referred to later by the variable's value.

Note that a channel specified as a density cannot be named in this way because a density statement can define channels in multiple locations.

Modify

The "ename" and "modify" clauses allow certain neural elements to be modified during a simulation after they have been created. The "synapse", "gj", and "receptor" neural elements can be modified (between "step" statements) with the following syntax:

In the original declaration:

   conn <node1> to <node2> synapse <synaptic params> ename <var>
where
 
      <synaptic params>    are the optional paramaters originally 
                             used for specifying the synapse;
      <var>                is a variable used for remembering
                             the synapse especially for modifying later.
In a later declaration:
   modify <expr> synapse <new synaptic params> 
   
where
      <new synaptic params>  are the new parameter value specifications;
      <expr>                 is an expression having the value of
                             the "var" in the "ename" statement
                             described above.  Ordinarily, this
                             expression is simply the variable.
With the "ename/modify" feature, one can change a synapse as a function of any other recordable or computable parameter in a neural circuit. For instance, one could vary postsynaptic conductance (or presynaptic transmitter release) as a delayed function of postsynaptic voltage to simulate long-term potentiation.

Modifying synaptic parameters during a run

In order to change synaptic parameters dynamically, i.e. during a simulation, it is necessary to stop the simulation "run" mode and return to "construction" mode. Then the appropriate modifications can be made to neural elements and the simulation can be restarted. This is usually done with a "for" loop, with the modification statements and a "step" statement inside the loop.

Example:

        /* code to make original circuit */
pre = 1;
post = 2;
soma = 3;
synstep = .01;
                /* timestep for synaptic modification */
at [pre] sphere dia 5;
conn [pre] to [post] synapse expon 2 thresh= -.045 maxcond=1e-9 ename syn1;
conn [post] to [soma] cable dia .2 length 10;
at [soma] sphere dia 10;
stim node [pre] cclamp 1e-10 start 0.2 dur 10;
for (t=0; t<100; t+= synstep) {
  newcond = modsyn (pre,post);  /* function to calc new conductance */
  modify syn1 synapse maxcond=newcond;
  step synstep;
};
This example constructs a presynaptic terminal that connects to a postsynaptic cell with a synapse. The synapse releases neurotransmitter exponentially with voltage, calculated at the standard time resolution of 0.1 msec. However, every "synstep" (10 msec) time interval, the synapse's conductance is modified according to the function "modsyn" which can be any computable or recordable function (e.g. it may be a function of voltage or conductance at any node in the network).

In the case shown here, the pre- and post-synaptic nodes are given as parameters to the function. Then the simulation continues to run with the"step" statement, which is similar to the "run" statement exceptthat it stops the simulation after the given time interval.

Run and step

The run statement causes the simulated neural circuit to be activated, and also activates any "stimulus" and "plot" statements. The simulator numerically integrates voltrages over time and also activates stimuli and plots at their proper times. The simulator stops when the "time" variable reaches the value of "endexp" (end of the experiment). "graph" and "record" statements are not activated during a run. A second "run" statement in a program is allowable but after the first "run" statement, time is reset to zero and all neural circuits are erased.
step <expr>
where:
       step <expr> (sec)  = time interval to run simulation
The "step" statement works exactly like the "run" statement (it activates the neural circuit, stimuli, and plots) but stops after a time interval, allowing the network to be restarted with where it stopped. All parameters such as node voltages and the elapsed simulation time retain their values.

Note on use of "step" with "stim" statement:

If you step a nonintegral multiple of "timinc", the actual time run by the "step" statement may be up to one extra "timinc":

  timinc = 0.0001;
  steptime = 0.011111111111;       /* not integral mult of timinc */
  for (i=1; i<n; i++) {
     plotarr[i] = V[node1];
     stim .... start=i*steptime dur=steptime;     /* off by 0.0001 each time */
     step steptime;              /* steps 0.0112 sec each time */
  };
For example, if timinc=1e-4 and you give a time step of 0.01111111, the simulator will run for 0.0112 sec which is the next larger interval. This is usually not a problem, but if you place the "step" statement inside a "for" loop along with "stim" statements, you may find that the stimuli are not being started at the correct times because of the "roundoff" problem stated above. The way to correct this problem is to make 2 separate "for" loops, one to generate the stimuli, and one to run the "step" statement:

  steptime = 0.011111111111;       /* not integral mult of timinc */
  for (i=1; i<n; i++) {
     stim .... start=i*steptime dur=steptime;  /* correct to 0.0001 sec */
  };
  for (i=1; i<n; i++) {
     plotarr[i] = V[node1];
     step steptime;                /* step 0.0112, but maybe acceptable */
  };
When the "stim" statements are all executed before the first "step" statement, they are all run in "construction mode" before the model starts, so they are correctly synchronized with the integration time step. Another solution is to use the "time" variable which always has the correct time updated by the "step" statement:

  steptime = 0.011111111111;             /* not integral mult of timinc */
  for (i=1; i<n; i++) {
     plotarr[i] = V[node1];
     stim .... start=time dur=steptime;  /* may give blank betw.  stimuli */
     step steptime;                      /* still steps 0.0112 sec */
  };

erase model

The "erase model" statement erases all arrays and neural circuits, so a simulation can be started over within one session of running "nc". Whenever "nc" runs, of course, everything is already erased, thus normally there's no reason to "erase model".

NeuronC programming statements

NeuronC contains a subset of the "C" programming language. This subset includes:
     for 
     while 
     if 
     else 
     assignment  
     define procedure, function
     call procedure, function
     return
     break
     continue
     formatted print
     arithmetic and logical operators
     increment operators
     numeric expressions
     trig, log, expon, power, sqrt functions
     predefined constants (PI, E, etc.)
 
     include file
     edit file
     run system command
     automatic variable definition
     local variables
     dynamically allocated multidimensional arrays
Features of C not supported:
     structures, unions, bit fields
     pointers, address operators
     #define, #ifdef statements
Most of the statements in NeuronC borrowed from C are familiar to most of us who have used C. There are a few significant exceptions. A semicolon must be used after every statement in NeuronC except the first statement after the "if" in an "if () ... else ... " statement. For example:
     if (i > 5) x = 0
     else       x = 1;
These two lines comprise a single statement and the semicolon (";") is missing after the first line to allow NeuronC to better sense the upcoming "else".

A statement list enclosed by curly brackets ("{}") must have a semicolon after it (except between an "if ... else" statement):

   for (i=0; i>5; i++) {
       x[i] = i; 
       y[i] = array[i];
   };          /* semicolon necessary */

NeuronC advanced programming

Node fields

node <node> -> numconn         Number of connections to elements
node <node> -> xloc            X location 
node <node> -> yloc            Y location 
node <node> -> zloc            Z location
node <node> -> <expr>          Absolute number of an element,
                                    given its sequence number at node.
Once nodes are created, they contain information about their location and connections, called "node fields". It is sometimes useful to retrieve this information directly from its storage in the node instead of referring back to the original algorithm that created the node. The concept of a "pointer" serves this purpose. To retrieve information from a node field, enter a node number, then the characters "->" and one of the "node fields". For instance:
     node [50][1] -> xloc
means the numerical x location of node [5][1]. This can be used in any expression where a number would normally be required, and can be part of arithmetic or passed to a function. A node's location is useful when a NeuronC program is determining how close two neurons are to each other when building a circuit. Remember, node numbers may be 1-, 2-, 3-, or 4-dimensional.

element fields


element <element> -> type    numerical element type: "cable","sphere", etc.
element <element> -> dia     diameter
element <element> -> length  length, given or calculated from nodes
element <element> -> n3dist  3D distance between element's nodes
element <element> -> n2dist  2D (x,y) distance between element's nodes
element <element> -> rm      membrane Rm 
element <element> -> ri      membrane Ri
element <element> -> cplam   lambda for compartments in cable
element <element> -> node1a  number of first node
element <element> -> node1b  
element <element> -> node1c  
element <element> -> node1d 
element <element> -> node2a  number of second node
element <element> -> node2b  
element <element> -> node2c  
element <element> -> node2d 
 
To retrieve information about a neural element, enter "element", then the element number, then place the characters "->" after the element number, and then place a field name. This expression can be used anywhere instead of a standard numerical expression.

type() function

x = type (<elemtype>)
The numerical "element <element> -> type" expression returns a number unique to the type of the neural element. To find out what type this number is, you can compare it with "type(<elemtype>)", where <elemtype> is one of the neural element types (see <elemtype> in "foreach" below).

Distance functions

x = n3dist (<node1>, <node2>)       3D node distance function
x = n2dist (<node1>, <node2>)       2D (x,y) node distance function
These functions compute the distance between 2 nodes. The nodes may be 1, 2, 3 or 4 dimensional, and the extra dimensions not used are assumed, for the computation, to be zero. n3dist measures 3D distance in (x,y,z), and n2dist measures distance in (x,y) only, useful for developing rules for "growing" neurons.

x = e2dist ( <node>, <element> )     2D element distance function
x = e3dist ( <node>, <element> )     3D element distance function
These functions compute the distance between a node and an element. If the closest part of the element is one of its end nodes, the distance to that node is returned. e3dist measures 3D distance in (x,y,z), and e2dist measures distance in (x,y) only, useful for developing rules for "growing" neurons.

Fractional distance along a cable

x = efrac ( <node>, <element> )     fractional distance on cable 
This function computes the fractional distance along a cable from the given node. If the closest part of the element is one of its end nodes, either 0 or 1.0 is returned.
at <node> : <element> offset <expr> put <node>
This statement puts a new node on a cable at the specified "offset". The offset is a fraction between 0 and 1 and can be computed by the "efrac()" function. The new node splits the cable element into two cables, each with a new length according to the location of the new node with respect to the existing nodes' positions.

This statement is useful when building neural circuits with "developmental rules". When an array of neurons is made, the algorithm that defines them may not include a precise location on the dendritic tree for synaptic connections. Instead, synaptic connection may be defined by a "connection rule" that specifies how to connect two cells based on distance and other factors. In this case, new nodes for connecting the synapses are needed at locations not specified by the algorithm that made the cell. Thus the "at <node> : <element>" statement allows the "connection rule" to make connections wherever it needs to.

foreach statement

foreach node <nodedim> statement              (iterate over matched nodes)
foreach <elemtype> ?var statement              (iterate over element type)
foreach <elemtype> ?var node <nodedim> statement (iterate over elem, node)
where:
      <nodedim>  =  1 to 3 node dimensions, each in the following syntax:

      [<expr>];      dimension set to a value that must match.
      ?var          dimension free to vary, not to be matched. 
                     The "?" in front of the variable means the variable
                     will be replaced with the corresponding value (from 
                     the node that matches) for that dimension while the
                     following statement is executed.

      <elemtype> =   One of: "element", "cable", "sphere", "synapse",
                             "gj", "rod", "cone", "load", "resistor",
                             "cap", "gndcap", "batt", "gndbatt", "chan",
                             "vbuf".
The "foreach" statement allows you to access neural elements and nodes with a partial specification of their range. It iterates a statement or block of statements (inside "{}") over an element type and/or set of nodes, selected by the <nodedim> value described above. You can select which nodes will match by giving expressions inside square brackets (as you normally would to define a node). For any dimension that you wish to leave free for iteration, place a "?" directly in front of a variable's name. This replaces the expression you would normally enter for the dimension's value.

When the following statement executes, the variables will contain the value from the corresponding unspecified dimensions of the node being considered by the loop. For example:

       i = 50; 
       foreach node [i] ?j ?k { print j, k; };
This statement prints the second and third dimension of all nodes that have a value of i (= 50) in their first dimension. The "foreach" statement in many cases is easier to use than its equivalent nested "for" loops (one "for" loop is normally required for each unspecified dimension).

If an element type is specfied, without a node, then all elements of that type are selected. If both element type and node are specified, then only elements of that type with nodes that match the specification are selected. For example:

     foreach sphere ?s { if (s->dia > 5) display element s };
This statement displays all spheres with a diameter greater than 5 microns. The variable "s" specifies the element number, and is given a new value (another sphere's element number) for each iteration of the loop.
     foreach cable ?x node [i][j] ?k {if (k>10) display element x};
This statement displays all cables that connect to node [i],[j] if their third dimension is greater than 10. The variable "x" specifies the cable's element number, and the third node dimension is specified by variable "k".

Procedure and function definitions

Procedures and functions have a different syntax than in "C" for their definitions, but use standard C syntax when they are called (invoked):

   proc makecell (node1, node2) {            /* procedure definition */
     at node1 sphere dia 10;
     conn node1 to node2 cable dia 1 length 10;
   };

   func rms (val1, val2) {                  /* function definition */
     return ( sqrt( val1 * val1 + val2 * val2));
   };

   for (i=0; i<100; i++) 
     val = rms (i,10);                     /* use of function */
     printf ("%g\n", val);
   };
Note that procedures and functions must be defined before they are used, and they must be "external", i.e. they cannot be defined from inside other procedures or functions. A convenient way to define procedures and functions is to make a file that contains your commonly used ones, and in any other source file that calls them, define them before the calls with an 'include "procfile.n"' statement (see below).

Exit statement

To stop a program from running, use the "exit" statement as you would in C. This immediately stops the execution of any more commands and exits, even from within a procedure or function.

Include and system commands

The "include" statement allows the inclusion of a text file into a NeuronC program, and is useful for allowing a standard neural circuit definition to be used in several different models.

The "system" command allows any standard system command such as "ls -l" (list directory) or "vi modelfile" (edit a NeuronC program) to be run. This is useful when running NeuronC in interactive mode, but can be used during a simulation to run a wide variety of commands.

NeuronC Variables

Variables and arrays are "global" unless specified to be "local" (see below), i.e. they can be accessed from anywhere in a program once defined (in the case of variables, by assigning a value to them). Variables and arrays must start with alphabetic characters, but may include numbers and the underline ("_") character. NeuronC variables are all double-precision floating point, which means that they all have at least 15 decimal digits of precision. NeuronC allocates space for a variable whenever it first appears in a program, but does not initialize the variable. You must assign a value to a variable or array before using it, or you will receive an error message.

Strings

Variables and arrays can have either numeric or string values. Once the variable has been assigned a value, you cannot change its type, i.e. it is an error to attempt to store a numeric value into a string variable and vice-versa. You can, however, assign a different value to a string variable, and you can add two strings together using the "+" and "+=" operators (other operators do not work on strings). String values are assigned to a variable like this:
   x = "Strings";
   y = " make useful labels.";

String operators

str1 +  str2                catenates two strings.
str1 =  str2                assigns string 2 to string 1.
str1 += str2                catenates string 2 to string 1.

Logical operators

str1 == str2                true if strings are same.
str1 != str2                true if strings are different.
str1 || str2                true if either string 1 or string 2 exist.
str1 || numval              true if string 1 exists or numval is non-zero.
str1 && str2                true only if string 1 and string 2 both exist.
!str                        true if string does not exist.
strlen(str)                 returns length of string.
strtok(str1,str2)           returns first substring in str1 delimited
                             by any of the chars in str2.  The str1 string
                             can be parsed further by passing a 0 instead
                             of str1; str1 is remembered by "strtok" through
                             several calls. (For further information, look
                             in the Programmer's Reference Manual under
                             "string(3x)")
The result of a logical operator is always a numeric value, either 1 (true) or 0 (zero=false).

Some examples:

   print x + y;
   Strings make useful labels.

   z = x + " often" + y;
   print z;
   Strings often make useful labels.

   x += " used wisely";
   print x + y;
   Strings used wisely make useful labels.

   x = "";
   if (x) print x
   else print "empty string";
   empty string
Of course, you can use the "print" statement to format your reports with numbers:
   cablediam = 5.6;
   print "The current diameter is:", cablediam;
   The current diameter is: 5.6

   printf ("The current diameter is %8.3g.\n",cablediam);
   The current diameter is: 5.600.

Setting variables from command line

Often it is useful to set a global variable to a default value within a nc program, but to override the variable's value from the command line. This is possible with the predefined "setvar()" function. This function may be invoked after the default values are set:
/* Program nfile1 */

    bsize = 5;
    nset = setvar();             /* nset is number of params set */

    statements that use "bsize"....

/* end of program */

    Later, when the program is run, the variable 
may be changed from the command line:

    nc -s bsize 6 nfile1
In this case "-s bsize 6" sets the variable "bsize" to a different value after it has been set to the default value of 5. This is useful doing several runs of a file with different parameter values. The "setvar()" function returns the number of parameters that were set from the command line. If the function is not assigned to a variable then "nc" will print the number to "stdout" (the output file).

Click here to return to NeuronC Statements

Local variables

Local variables and arrays may be defined inside a "proc" or "func" (or a statement block) for use within that subroutine (or block) only. This is useful when a variable of the same name is used in a main loop and also in a subroutine, so that the two instances of the variable may have different values. The values are kept separate on the subroutine's stack. It is good programming practice to use local variables whenever possible to keep a program simple and avoid programming errors. Local variables make it easier to track down where in a program they are set and used. This is how local variables are defined in NeuronC:
proc xydistance (x,y)

 {
      local x2,y2,rdist;
      local dim power[100];

      code starts here after local def...
};

Local variables can be defined at the beginning of any "{ }" block, e.g. inside a "{ }" block inside an "if" or "for" statement and within nested blocks. If a variable name has been defined in several nested blocks, and referred to by a statement enclosed in an inner block, the inner definition is used. Note that local variables defined inside a block are visible only to statements inside that block. Local variables defined outside a block are also visible inside the block (if their names are not defined more locally).

Example of nested local definitions:

{  local x1, y1;
   x1 = ...
   if (x1 > 5) {   local x2, y2;
               x2 = ...
               if (x2 > x1)  ...    /* x1 is defined outside of inner block */
   };
};

NeuronC arrays

Arrays in NeuronC are also "double" floating point, and are defined by the "dim" statement:
    dim conearray [30][30][3];
The dimension parameters need not be constants but may be variables or expressions:
    dim rodarray [xsize] [ysize] [abs(sin(theta))];
Arrays may be assigned string values, with the same rules as ordinary variables:
   x = "first string";
   dim z[10];
   z[0] = x;
   z[1] = "second string";
   z[2] = z[0] + z[1];
Arrays may be initialized when they are defined or afterwards:

    dim arr1 [20][2] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    arr1 = { 10, 9, 8, 7 };
    print newarr [1][1];
         7
The initialized values go into memory sequentially, and the right-most array indices increment most rapidly (as in standard C). Any array values not specifically initialized are set to an undefined value which will generate an error if accessed.

You can define a single-dimension array by leaving out its dimension size and specifying its length with the initialization:

   dim arr2 [] = { 1, 2, 3, 4 };
Arrays can be erased with the "erase" statement:
   erase rodarray;
Array size is limited only by the hardware and "C" compiler. Array access time is slower than simple variable access time because the array indices must be multiplied by the dimension sizes to locate a value in the array.

Click here to return to NeuronC Statements

Local arrays

Arrays may be defined inside any procedure, function, or statement block in a manner similar to local variables. They may have numeric or string values. The "dim" keyword must be used for each definition:
 {  local dim x[100], dim y[100];
    local i,j, z[100][100];
    local mcond;
    local dim cond[mcond=calcval(120)];

   z[i][j] = x[i] + y[j] * cond[i+j];

   ...

 };
The dimension of a local array must be an expression whose value is known at the time its definition is encountered by the interpreter. As in the example above, the dimension can be a constant, or can be calculated by a function or be the result of an assignment. Except for such assigments, the local definitions must be made before any other statements in the code block. Local arrays can be initialized in the "dim" statement or afterwards (see "Arrays" above").

Local arrays are accessed through the stack but their space is allocated on the heap. A new instance of a local array is defined each time control enters the block. After control exits the block in which a local array was defined the array is erased.

NeuronC Arithmetic Operators:

NeuronC has many of the unary and binary operators that are familiar to users of C. Remember, in logical expresssions, NeuronC (as other languages) considers a value of 0 to be "false" and nonzero to be "true". Logical comparison operators return 1 when true and 0 when false.
   unary operators
     -                    negative 
     !                    logical NOT  (!x true when x==0)
     x++                  post-increment (add one to value after use)
     x--                  post-decrement (subtract one after use)
     ++x                  pre-increment (add one to value before use)
     --x                  pre-decrement (subtract one before use)

   binary operators
     +                    addition
     -                    subtraction
     *                    multiplication
     /                    division
     ^                    power (A^B == A to the power of B)

     &                    bitwise AND (x&1 true when x is odd)
     |                    bitwise OR  (y&1 sets ones bit in y)
     &&                   logical AND ("x && y" true if both x and y nonzero) 
     ||                   logical OR  ("x || y" true if either x or y nonzero) 


   comparison operators   return value of 1 if true or 0 if false 

     >                    greater than
     >=                   greater than or equal to
     <                    less than
     <=                   less than or equal to
     ==                   test for equal to (no assignment of value)
     !=                   not equal to

   assignment operators  
     =                    assignment
     +=                   increment by right hand side (x+=2: add 2 to x).
     -=                   decrement by right hand side (x-=2: subtr 2 from x).
     *=                   multiply by right hand side.
     /=                   divide by right hand side.

NeuronC keywords:

Keywords have special meanings in NeuronC. You should not use any of these words as names for variables because this will cause an error. The keywords are:

abs acov all allowrev amax amin ampa area asin at atan attf
backgr bar batt bic blur break btot btoti
cAMP cGMP cable cabuf cacomp caexch cai calcnernst calibline camp
cao cap caperm capump cbound cclamp center cgain cgmp chan char
chinf chnoise chtau chtaua chtaub cinf close cm cnqx color
complam comps cone conn connect continue contrast cos cplam
crit cshell ctau ctaua ctaub
d1 d2 darknoise dash density dia dia1 dia2
dim disp display dscale dur dyad
e2dist e3dist edist edit efrac elap_time element elimit else ename
endexp erase euler except exit exp expon
fft file filt for foreach fprintf fread func fwrite
gaba gasdev gausnn gauss gcirc gcrot gcwidth gdash gdraw
gframe gj glu gly gmax gmove gndbatt gndcap gnv gorigin 
gpen graph grdraw grect grmove grot gsize gtext gwindow hcof
hgain hide hinf htau
if ifft implicit include init initrand int inten
jnoise
k1 k2 kd kex km
label lamcrit length linear load loc local log log10 matching
max maxcond mean mesgin mesgout mg min minf model modify mtau
n2dist n3dist ncomps ndensity ndist nfilt1 nfilt1h
nfilt2 nfilt3 ninf nmda node 
node1a node1b node1c node1d
node2a node2b node2c node2d
notinit ntau numconn numdyad
offset offseth offsetm
only opamp open orient
pathl pen pfft photnoise pigm plmax plmin plot ploti plsep poisdev 
pow print printf printsym prmap proc prseed ptx puff put
radius rand range read rect refr reg relax relincr
resistor resp restart restore return rev rg
rgasdev ri rightyax rm rmove rod rrand rsd rseed run
save scatter scurve sdyad setvar silent sin sine
size sphase sphere spot sprintf sqrt sscale start
stdev step stim stim_elem stimelem stiminc str strlen
strtok sun syn2 synapse synaptau system
tan tau tauc taud tauh taum taun tempcel
tfall2 tfall3 tfreq thresh 
time timec1 timec1h timec2 timec3 timinc
to trconc tungsten type
unit
vbuf vcl vclamp version vesnoise vgain vidmode
vk vmax vna vrest vrev vsize
wavel while width window
xenon xloc xrot
yloc
yrot
zloc zrot

AMPA BIC CNQX Ca Char CoV DEG E
FA0 FA1 FA2 FA3 FA4 FA9 FB0 FB1 FB2 FB3 FB4 FC0 FC1 FC2 FC3 FC4
FH0 FH1 FH2 FH3 FH4
G G0 G1 G2
GABA GAMMA GLU GLY
H I IE IP IPE K L M N NMDA Na PHI PI PTX S STR V X Y Z
To track down these keywords, look in "nc/src/init.cc" and from there look in "nc.y" to understand the details of their usage (if this manual doesn't describe them well enough for you). You can print out all the keywords into a sorted list with the command "nc -K | sort".

Read input into variable

read 
This function reads a value from the keyboard (standard input) into a variable. It returns 1 if a variable was read, or 0 if not. Typical usage:
    while (read(x)) print "Value is:",x;
 
Note that the familiar "scanf()" statement also exists in NeuronC (see "scanf function" below).

File open and close

fd = fopen (filename,mode)
fclose (fd)
The "fopen" statement opens a file, given its name and a mode ("r" = read, "w" = write, "a" = append), exactly as in standard C. It returns a file descriptor which may be used by file read and write statements to refer to the file. The file descriptor is a standard number with a special value.

The "fclose" statement closes a file given its file descriptor.

Click here to return to NeuronC Statements

Printf statements

print  <expr> <expr>
printf  ("format", <expr> ...
fprintf (file,"format", <expr> ...)
sprintf (stringvar,"format", <expr> ...)
sprintf (stringvar,"format", <expr> ...)
The "print" statement prints the value of any expression, or list of expressions. The expression may have either a number or string value. A comma-separated list of expressions is printed with spaces separating the values.

The "printf" statement is identical to the familiar library subroutine "printf". It prints a formatted string to the "standard output". It requires a "format" string, which may contain literal characters and formats of numbers or strings to be printed. A number format has a "%" followed by either "f" (floating-point), "e" (with exponent), or "g" (integer, floating point, or with exponent whichever takes fewest chars to print out).

The "fprintf" statement is identical to the "printf" statement except that it prints to a file. The file is defined by a "file descriptor" which you must define before calling "fprintf", exactly like in standard C. The file descriptor is created by a call to "fopen()" (see below). In addition, the file can be "stdout" or "stderr", which are normally the video screen (exactly like in standard C) but can be redirected with shell commands. The file descriptor can also be a filename if you don't need to keep the file open between fprintf() calls. Any message printed to "stderr" is guaranteed to appear on the screen (unless redirected), even if the program terminates prematurely. This is useful for debugging.

The "sprintf" statement is identical to the "printf" statement except that it prints its output into the first argument which is set to string type.

Click here to return to NeuronC Statements

Scanf function

n = scanf("format", <var> ...)
n = sscanf(stringvar,"format", <var> ...)
n = fscanf(,<fd>,"format", <var> ...)
n = fgets(<var>,<fd>)

The "scanf()" function is identical to the familiar library function "scanf()". It reads a formatted string from the "standard input". It requires a "format" string, which may contain literal characters and formats of numbers or strings to be printed. A number format has a "%" followed by "lg" (double), and a string has "%s". "scanf()" returns the number of arguments converted.

The "sscanf" statement is identical to the "scanf" statement except that it reads its output from the first argument which is must a character string.

The "fscanf" statement is identical to the "scanf" statement except that it reads from a file. The file is defined by a "file descriptor" which you must define before calling "fscanf", exactly like in standard C. The file descriptor is created by a call to "fopen()". In addition, the file can be "stdin" which is normally the keyboard (exactly like in standard C) but can be redirected with shell commands. The file descriptor can also be a filename if you don't need to keep it open between fscanf() calls.

The "fgets" statement reads a line from a file, exactly like in standard C. The file is defined by which is a file descriptor that has been created by a call to fopen(). If "fd" is "stdin" then the standard input is read, and if it is a filename, the file will be opened and read.

Click here to return to NeuronC Statements

Fread statement

fread ( <filename>, <arrname>, <var>, [>var<] )
where:
    <filename>   =  name of file that contains numerical array
                         (can be "string" or string variable).
    <arrname>    =  name of array (not yet defined).
    <ar>         =  variable to contain dimension size of array.
   [<var>]       =  optional variable for second dimension size.
This statement reads a file of numbers (or variables) into an array of one or two dimensions. The file contains a list of numbers separated by spaces. The array must not yet be defined, because the statement defines the array to match the dimension(s) of the list of numbers in the file. The (one or optionally 2) var's are set to the sizes of the array's dimensions. The size of the first dimension is the number of lines (with numbers on them) in the file, and the size of the second dimension is the number of numbers on the first line.

Variables in file array

The "fread" file may contain a mixture of variables along with numbers. The variables are treated in the same way as the numbers, except that after they are read, their values from the symbol table are substituted. Therefore, any variables occurring in the file must be assigned a value before the "fread" statement. The definition may be:
    1) in an assignment statement:          x = 87
 or 2) in a command line assignement:   nc -s x 87
Comment lines may be included in the "fread" file. Any line starting with the "#" character is ignored. Comments are useful for documenting data files.

Fwrite statement

fwrite ( <filename>, <arrname>)
where:
    <filename>   =  name of file (can be "string" or string variable). 
    <arrname>    =  name of array. 
This statement writes an array of one or two dimensions to a file.

Click here to return to NeuronC Statements

Access to variables from an external program

You can compile "nc" into your own C program, call it as a subroutine, and return results from the simulator back to your program as memory references. To do this, read through "src/nctest.cc" which is a template for how to access internal "nc" variables from the outside. Edit "src/ncmain.cc" and rename "main()" to "ncmain()", then use the "nctest" lines in the src/makefile as a template for compiling and linking your C own program. You can run the simulator several times with parameters set to different values and return the results in variables or multidimensional arrays.

Click here to return to NeuronC Statements

Test for undefined variable: notinit()

When variables are first declared, they have an undefined value, which is useful when debugging a script. The "notinit()" function allows one to test whether a variable has been assigned a value. It returns a 1 ("true") when its argument has not been intialized yet, and a 0 ("false") when it has been initialized. This is useful to find under what circumstances a variable is assigned a value:

if ( notinit(<var1>) ) fprintf ("Error in defining var1, %g\n", <var2>);

Run procedure at plot time

Sometimes it is useful to do something else besides directly printing out a value at plot time. For example, one might want to perform some operation on the voltages or currents recorded from a neuron before plotting them.

You can do this with the "onplot()" procedure. If the "onplot()" procedure is defined (with the "proc" statement), it is run at increments of the plot time defined by "ploti" (plot increment). You can place any commands you like in the procedure, which has access to any recorded value (voltage, current, light) or variable.


func calctau (tau) 
   /* Function to calculate "k" for digital filter,  */
   /* given time constant. */
{
  k = 1.0 - exp (-timinc/tau);
  return k;
};

kf11 = calctau(1.5e-5);		/* filter time constants */
kf12 = calctau(2e-5);

graph X max endexp min 0;
graph Y max 0 min 1e-10;
graph Y max 0 min 1e-10;
graph init;

proc onplot() 
   /* plot procedure that implements 2nd order digital filter */
{
  graph pen (2,4);		/* plots green, red */
  val = I[1]
  f11 += (val - f11) * kf11;	/* second-order filter */
  f12 += (f11 - f12) * kf12;
  graph (time, val, f12);
};

Click here to return to NeuronC Statements

Special "pen" procedure run at plot time

You can define a special "pen" function for each plot using the "vpen" option. This function receives the plot number, the X and Y values for the plot, and returns a number which is interpreted as the "pen" number (0-15 = color, -1 = no display). The advantage of this method over the "onplot" method defined above is if the plot number changes when you add more plots, the color of the plot is defined by the same function.

func spikplot (nplot, xval, yval) 
{
   local retval;

   if (yval > 25) retval = 7		/* white if > 25 */
   else           retval = 6;		/* brown otherwise */ 
   if (yval < 10) retval = -1;		/* disappear if less than 10 */
   return (retval);
};

plot V[100] max 0.01 min -0.07 vpen spikplot	/* set plot time function */
Click here to return to NeuronC Statements

Built-in functions

x = exp(a)          exponential 
x = log(a)          natural logarithm 
x = log10(a)        logarithm to base 10
x = pow(a,b)        power  (a to the b power) = a^b
x = sin(a)          sine
a = asin(x)         arcsine
x = cos(a)          cosine
x = tan(a)          tan
a = atan(x)         arctan
  
x = sqrt(a)         square root
x = int(a)          integer value of (a)
x = abs(a)          absolute value of (a)
x = amax(a,b)       maximum of (a,b)
x = amin(a,b)       minimum of (a,b)

x = strlen(s)       string length (s must have a string value)   
These mathematical functions return values in exactly the same way as they would in standard "C".
x = rand()          random function
x = rrand(n)        random function from individual random noise generator
x = gasdev()        Gaussian distribution.
x = rgasdev(n)      Gaussian distribution from individual random noise generator
x = poisdev(m)      Poisson distribution, m = mean.
initrand (n)        set up and initialize individual random noise generator.
initrand (n) rsd=x  set up random noise generator and initialize with seed.
The "rand()" function returns a number between 0 and 1. The "rseed" variable sets the seed for the random number generator, as does the "-r n" command line switch (See Section 6). The "gasdev()" function returns a Gaussian distributed set of numbers with zero mean and unit variance, and the "poisdev(m)" function returns a poisson distribution.

The "initrand" and "rrand(n)" statements allow you to create lots of individual random functions that produce different sequences. First you run the "initrand(n)" statement which sets up a different random number generator for each "n". It will automatically seed the generator, but including the "rsd=x" parameter allows you to specify the seed (see the "rsd" parameter in the "photoreceptor" statement). The "rgasdev(n)" function allows you to create an individual Gaussian distribution in the same way as "rrand(n)" above.

x = elap_time()     elapsed computation time (minutes) 
x = setvar()        set variables designated on command line,
                          returns number of variables set.
The "setvar" function is useful for running a "nc" program with different sets of parameters. Using the "-s" commaend line switch you can set the value of any variables for the script. The variables set by the "-s" switch need not be already defined in the program. Normally the values defined by the "-s" option are set at the beginning of the nc program. However the "setvar()" function also sets the values that you defined on the command line with "-s". Since you can locate the "setvar()" function anywhere, it is convenient when initializing variables for use as default parameters. You merely run "setvar()" once after the variables have been set. This allows you from the command line to override the default parameter values. (see "Nc variables"). This is especially useful when running "nc" from a shell script file.

Gausnn

n = gausnn (array, <option1,option2,...>);
where:
 

 array    =                       Name of array to hold the points.
                                   Array should not be previously defined.

<options> =  density = <expr>     Density of the array.
             reg     = <expr>     Regularity of the array: mean/stdev.
             mean    = <expr>     Mean nearest-neighbor distance ("nnd")
             stdev   = <expr>     Standard deviation of nnd.
             center  = <expr>     Location of center of array.
             size    = <expr>     Size of square array's side. 
The gausnn function is useful for creating arrays of cells that are randomly placed but have a certain amount of regularity. This function creates a set of points having a Gaussian distribution of mean nearest-neighbor distance, with a given density and degree of regularity within a specified square region. It is useful from a regularity of 3 (almost random) to a regularity of 50 (almost perfect triangular packing), although it is most accurate (better than 5%) for regularities above 5. One can also specify the mean and standard deviation or various combinations of these parameters.

The gausnn algorithm attempts to use the information specified in the most appropriate way and calculates how many points should fit in the region specified. The number of points successfully placed in the region is returned. The points are returned in the array (previously undefined). The array is defined to be a 2-dimensional array with the first dimension equal to the number of points and the second dimension 0 for X and 1 for Y. The array can be written to a file with "fwrite" or used directly by "nc" to create an array of neurons, etc.

Click here to return to NeuronC Statements

FFT

fft (array)         (amplitude, phase) spectrum
ifft (array)        inverse transform (amplitude, phase)
pfft (array)        power spectrum
acov (array)        autocovariance 

          dim array [2][arraysize];

          These functions compute the fast Fourier transform
          of the array and leave the answer in the same
          array, which must be defined with two dimensions.  The
          first subarray (array[0][arraysize]) dimension is
          amplitude, and the second is phase (array[1][arraysize]).

Constants

The following constants are defined in NeuronC:
   PI     3.141592653589793
   E      2.71828182845903523536
   DEG    57.29577951308232

Graphics statements

gmove  (x,y)
gdraw  (x,y)
grmove (dx,dy)            ( relative move )
grdraw (dx,dy)            ( relative draw )
gcirc  (rad, fill)        ( fill = 0 or 1 )
grect  (x1,y1,x2,y2,x3,y3,x4,y4, fill)   (4 (x,y) corners, fill = 0-1 )
gpen   (color)            ( color range: 1-15 )
grot   (theta)            ( rotate picture, angle in radians )
gcrot  (theta)            ( rotate text, angle in radians )
gcwidth(width)            ( character width )
gsize  (size)             ( size that square screen frame represents )
gdash  (dashcode)         ( code range 1->8 )
gorigin (x,y)             ( origin of new frame in parent's coords )
gframe "<name>"           ( make new sub-frame )
grframe "<name>"           ( remove sub-frame )
gtext  ("<char string>")
These graphics primitives allow NeuronC to draw to the graphics screen, defined as by coordinates (0,0) to (1.0, 1.0). gmove and gdraw together with gpen allow you to draw a line anywhere in any color (16 colors for VGA). gtext writes text on the graphics screen, in a manner similar to "printf". gcsize sets the character size as a fraction of the frame, i.e. .02 sets the char size to 1/50th of the frame size. grmove and grdraw are relative move and draw. grot (calib in degrees) rotates the graphics frame defined by gframe so graphics and text can be written at any angle. gorigin translates the current frame.

A frame is a name for a subregion of a window that can be rotated, translated, and scaled separately from its parent. The frame statement causes the named frame to be the current one. If the named frame doesn't exist, then it is created new. If it does already exist as a parent or descendent of the current frame, the current frame is moved appropriately. gsize sets the size of a frame as a fraction of the current frame. This is useful to allow the other graphics statements to scale to the same size as the "display" statements in "nc".

gcrot (calib in radians) rotates only text (not graphics) about the current location. gdash causes a line to be dashed with a certain pattern (0 - 8 are different patterns).

Arranging graphs

It is possible to combine these graphics primitives with the standard "graph" and "plot" statements to arrange several graphs on a page. For instance, you can create a subframe with frame, translate it with gorigin, shrink it with gsize and then draw a graph in it. After the graph is done, you can go back to the parent frame with gframe ".." and make another subframe for a second graph.

Example:

     gframe "graph1";
     gorigin (.2,.2);
     gsize (.4);

     code to draw points on graph
     .
     .
     .
     gframe "..";
     gframe "graph2";
     gorigin (.2 .6);
     . . .
     gframe "..";

     (at this point, you can go back to either "graph1"
        or "graph2" and draw more in them.)