Previous Next Table of Contents

26. GENESIS Object Reference

26.1 Ca_concen

Object Type:    Ca_concen

Description:    Single pool model for Ca concentration.

Author:         M. Wilson, Caltech (2/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  Ca_concen_type  [in src/segment/seg_struct.h]

Size:           112 bytes

Fields:         tau             time constant of decay
                Ca_base         resting (base level) concentration
                B               equals 1/(ion_charge * Faraday * volume)
                Ca              Resulting concentraton of Ca++ ions
                C               Intermediate result, Ca - Ca_base
                thick           Holds thickness of shell (used by readcell)

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       CaConcen  [in src/segment/Ca_concen.c]

Classes:        concentration segment

Actions:        INIT
                PROCESS
                RESET
                CHECK
                SAVE2
                RESTORE2

Messages:       I_Ca  Ik              Receives ionic current Ik from a channel
                BASE  Ca_base         Sets Ca_base with a message
                fI_Ca Ik fraction     Receives fractional current Ik*fraction
                INCREASE  delta_Ik    Add delta_Ik to incoming current
                DECREASE  delta_Ik    Subtract delta_Ik from incoming current

------------------------------------------------------------------------------

Notes:          Single shell model for Ca concentration.
                Solves  dC/dt = B*Ik - C/tau.
                Ca = Ca_base + C.

                In SI units, where concentration is moles/m^3
                (milli-moles/liter) and current is in amperes, theory gives B
                = 5.2e-6/(shell volume).  In practice, B is a parameter to be
                fitted or estimated from experiment, as buffering, non-uniform
                distribution of Ca, etc., will modify this value.  If thick =
                0, the readcell routine calculates B by dividing the "density"
                parameter in the cell parameter file by the volume of the
                compartment.  Otherwise, it scales as a true shell, with the
                volume of a shell having thickness thick.  A negative value of
                the "density" parameter may be used to indicate that it should
                be taken as an absolute value of B, without scaling.  

Example:        see Scripts/burster
See also: readcell

26.2 Kpores

OBJECT                          KPORES                  3/14/92 (AS)

DESCRIPTION:
    Simulates a population of potassium ion channel proteins (pores)
    embedded in a patch of membrane over an isopotential region.  Each
    individual pore undergoes standard Markov kinetics through a five state
    scheme:

              4an->        3an->        2an->         an->
        [n0]---------[n1]---------[n2]---------[n3]---------[n4]
              <-bn         <-2bn        <-3bn        <-4bn

        where [n4] = Open State and an and bn have voltage dependencies 
        given by:

        an = (alpha_A + alpha_B*Vk)/(alpha_C + exp((alpha_D+Vk)/alpha_F))

        bn = (beta_A + beta_B*Vk)/(beta_C + exp((beta_D+Vk)/beta_F))

        The total population of pores is given by Nt.
        The total number of pores within each of the five stable states
        at any given iteration is given by n0, n1, n2, n3, n4, respectively.
        The total number of pores in the open stable state is given
        by No = n4.
        The open state conductance of a pore is given by Gmax.
        The effective conductance for the population of pores at any
        given iteration is then Gk = Gmax*No.

SPECIFICATIONS:
    FUNCTION            KPorePop()
    DATA STRUCTURE      K_pore_type
    CLASS               segment membrane
    SIZE                ?? bytes
    AUTHOR              A. Strassberg Caltech 3/92

ACTIONS:
    CHECK       null
    RESET       sets initial distribution of pores into the various stable
                states based upon the equilibrium solutions to the Markov
                matrix for given Vk.
    PROCESS     updates the distribution of the stable states of the
                population based upon the rate constants an and bn, derived
                from the current transmembrane voltage Vk.
    INIT        null

MESSAGES:
    VOLTAGE     sends transmembrane voltage Vk to the population of pores.
                This Vk is used to update the state distribution after each
                iteration.

FIELDS:
    See DESCRIPTION

RELATED COMMANDS/TOPICS:
    Napores

ERROR MESSAGES:

BUGS:

NOTES:
    See Strassberg and DeFelice, 1993, Neural Computation 5:6
    and the demonstration scripts in Scripts/examples/pore

26.3 Mg_block

Object Type:    Mg_block

Description:    Implementation of voltage- and [Mg]-dependent
                blocking of a channel.

Author:         E. De Schutter, Caltech (11/90)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  Mg_block_type  [in src/segment/seg_struct.h]

Size:           120 bytes

Fields:         Ik              blocked value of current
                Gk              blocked value of current
                Ek              blocked value of current k
                Zk              charge; may also be used as
                                {charge / relative fraction of I},
                                e.g. 2/(Ica/Itot) -> msg to difpool
                KMg_A           A-factor K(v) in eq'n for Mg block reaction
                KMg_B           B-factor K(v) in eq'n for Mg block reaction
                CMg             [Mg] in mM

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       MgBlock  [in src/segment/Mg_block.c]

Classes:        segment channel

Actions:        INIT            [INIT does nothing]
                PROCESS
                RESET
                CHECK

Messages:       VOLTAGE Vm              voltage from the compartment
                CHANNEL Gk Ek           unblocked Gk and Ek from compartment
                CHANNEL1 Gk
                CHANNEL2 Gk Ek
                CHARGE Zk

------------------------------------------------------------------------------

Notes:          An Mg_block element may be interposed between a synaptically
                activated channel (a synchan or hebsynchan) and a compartment. 
                This calculates a blocked value of Gk that is reduced from
                the incoming Gk by a factor of A/(A + [Mg]*exp(-Vm/B)).

                The example below puts this in the form of the Zador, Koch,
                and Brown equation [Proc. Natl. Acad. Sci. USA 10:6718-6722
                (1990)], with A = 1/eta and B = 1/gamma.

Example:

    float CMg = 2                       // [Mg] in mM
    float eta = 0.33                    // per mM
    float gamma = 60                    // per Volt
    create      synchan               {compartment}/{channel}
    setfield         ^ \
                Ek                      {Ek} \
                tau1                    {tau1} \
                tau2                    {tau2} \
                gmax                    {gmax}
    create Mg_block {compartment}/{channel}/block
        setfield         ^ \
                CMg                     {CMg} \
                KMg_A                   {1.0/eta} \
                KMg_B                   {1.0/gamma}
    addmsg   {compartment}/{channel} {compartment}/{channel}/block \
                CHANNEL Gk Ek
    addmsg   {compartment}/{channel}/block {compartment} CHANNEL Gk Ek
    addmsg   {compartment}   {compartment}/{channel}/block VOLTAGE Vm
    // Even though the channel current isn't used, CHECK expects this message
    addmsg   {compartment}   {compartment}/{channel} VOLTAGE Vm
See also: synchan

26.4 Napores

OBJECT                          NAPORES                 3/14/92 (AS)

DESCRIPTION:
    Simulates a population of sodium ion channels proteins (pores) embedded
    in a patch of membrane over an isopotential region.  Each individual pore
    undergoes standard Markov kinetics through an eight state scheme:

                  3am->                 2am->                 am->
        [m0h1]---------------[m1h1]---------------[m2h1]---------------[m3h1]
          |       <-bm         |       <-2bm        |        <-3bm       |
          |                    |                    |                    |
       /\ |                 /\ |                 /\ |                 /\ |
       ah | bh              ah | bh              ah | bh              ah | bh
          | \/                 | \/                 | \/                 | \/
          |                    |                    |                    |
          |       3am->        |        2am->       |         am->       |
        [m0h0]---------------[m1h0]---------------[m2h0]---------------[m3h0]
                  <-bm                 <-2bm                 <-3bm

    where [m3h1] = Open State and am, bm, ah and bh have voltage
    dependencies given by:

    am = (malpha_A + malpha_B*Vk)/(malpha_C + exp((malpha_D+Vk)/malpha_F))

    bm = (mbeta_A + mbeta_B*Vk)/(mbeta_C + exp((mbeta_D+Vk)/mbeta_F))

    ah = (halpha_A + halpha_B*Vk)/(halpha_C + exp((halpha_D+Vk)/halpha_F))

    bh = (hbeta_A + hbeta_B*Vk)/(hbeta_C + exp((hbeta_D+Vk)/hbeta_F))

    The total population of pores is given by Nt.  The total number of pores
    within each of the eight stable states at any given iteration is given by
    m0h0, m1h0, m2h0, m3h0, m0h1, m1h1, m2h1, and m3h1, respectively.  The
    total number of pores in the open stable state is given by No = m3h1.
    The open state conductance of a pore is given by Gmax.  The effective
    conductance for the population of pores at any given iteration is then
    Gk = Gmax*No.

SPECIFICATIONS:
    FUNCTION            NaPorePop()
    DATA STRUCTURE      Na_pore_type
    CLASS               segment membrane
    SIZE                ?? bytes
    AUTHOR              A. Strassberg Caltech 3/92

ACTIONS:
    CHECK       null
    RESET       sets initial distribution of pores into the various stable
                states based upon the equilibrium solutions to the Markov
                matrix for given Vk.
    PROCESS     updates the distribution of the stable states of the
                population based upon the rate constants an and bn, derived
                from the current transmembrane voltage Vk.
    INIT        null

MESSAGES:
    VOLTAGE     sends transmembrane voltage Vk to the population of pores.
                This Vk is used to update the state distribution after each
                iteration.

FIELDS:
    See DESCRIPTION

RELATED COMMANDS/TOPICS:
    Kpores

ERROR MESSAGES:

BUGS:

NOTES:
    See Strassberg and DeFelice, 1993, Neural Computation 5:6
    and the demonstration scripts in Scripts/examples/pore

26.5 PID

Object Type:    PID

Description:    PID (proportional, integral, derivative) feedback controller

Author:         M. Nelson, Caltech (4/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  PID_type  [in src/user/user_struct.h]

Size:           144 bytes

Fields:         cmd          inputs the command (desired) value of sns
                sns          inputs the sensed (measured) value
                output       = gain*(e + tau_d*de/dt + 1/tau_i * e_integral)
                gain         determines the sensitivity of the controller
                tau_i        integration time constant, typically = dt
                tau_d        derivative time constant, typically = dt/4
                saturation   sets permissible range of output
                e            internal variable (error = cmd-sns)
                e_integral   internal variable (integral of e dt)
                e_deriv      internal variable
                e_previous   internal variable

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       PIDcontroller  [in src/user/PID.c]

Classes:        device

Actions:        INIT
                PROCESS 
                RESET

Messages:       CMD command
                SNS sense
                GAIN gain

------------------------------------------------------------------------------

Notes:

The PID is used for feedback control of dynamical systems.  For example, in
a voltage clamp circuit it is used with a pulsegen, RC, and diffamp device
to provide the required injection current to maintain the membrane voltage
at the desired level.  The RC-filtered command voltage is scaled by the
diffamp and then presented to the PID with a CMD message.  The output is
sent to a compartment with an INJECT message, and the resulting Vm in the
compartment is fed back to the PID with a SNS message.  A higher gain gives
a better clamp, but requires a smaller integration time step to avoid
numerical instability.

For more information on PID controllers see: Franklin, Powel, Emami-Naeini
(1986) "Feedback Control of Dynamic Systems", Addison-Wesley, pp. 99-106.

Example:        Scripts/squid/squid_electronics.g

See also:       

26.6 RC

Object Type:    RC

Description:    A series resistance R, shunted by a capacitance C.

Author:         M. Wilson, Caltech (6/88)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  RCunit_type  [in /usr/genesis/src/segment/seg_struct.h]

Size:           96 bytes

Fields:         V0      initial value of "state" (set on RESET)
                R       series resistance
                C       shunting capacitance
                state   output value
                inject  input value

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       RC_Unit  [in src/segment/rcunit.c]

Classes:        segment

Actions:        CHECK  PROCESS  RESET

Messages:       INJECT inject (input-value)

------------------------------------------------------------------------------

Notes:          

An RC element is often used as a low-pass filter, as with a voltage clamp
circuit, in order to prevent a step change in the command voltage from
causing numerical instabilities.

Example:        Scripts/squid/squid_electronics.g

See also:       

26.7 asc_file

Object Type:    asc_file

Description:    

The asc_file object is used to write data to a file in ASCII format.  A new
line is written at every time step of the clock which is assigned.  Unless
the notime flag is set, the first item on each line is the simulation time.
Each SAVE message which is received adds another item to the line.

Author:         M. Wilson, Caltech (4/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  ascfile_type  [in src/out/out_struct.h]

Size:           88 bytes

Fields:
                filename        data file name to be written
                fp              data file pointer
                is_open         flag: is file currently open?
                initialize      flag: has file been initialized?
                leave_open      flag: leave file open? 1 leaves the file open
                                all the time so you can write on it whenever
                                you want (a good idea if the file is used
                                frequently, but there is a limit to number of
                                files that can be left open at any time);
                                0 closes the file after every write to it
                                (only useful if you have more than 30 files;
                                this is slow)
                append          flag: append data after resetting?
                flush           flag: flush data to disk at each interval?
                                1 forces program to send data to the disk at
                                once and not store it in a buffer (slow but
                                secure); 0 (default) writes data in a buffer
                                (fast)
                notime          flag: if non-zero, don't output the time
                float_format    format specifier for output (default is %g)

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       AscFileOutput  [in src/out/out_ascfile.c]

Classes:        output

Actions:        RESET  PROCESS  DELETE  SAVE  FLUSH  OUT_OPEN  OUT_WRITE

Messages:       SAVE data

------------------------------------------------------------------------------

Notes:

If the filename field is not set, the output file will be given the same
name as the element which is created from the asc_file object.

When the append flag is zero, a reset will close and reopen the file,
setting the file pointer at the begining, effectively creating a new file
if the simulation is stepped again.  When the append flag is set to a
non-zero value, additional steps after a reset will be appended to the
file.  The OUT_WRITE action may be called to write any string to the file.
The OUT_OPEN command is used to manually initialize the file for writing,
and must be called before calling OUT_WRITE.  In append mode, it must be
called after changing the filename to a new output file name, or renaming
an existing one.

The float_format field specifies the format of the data written to the
file, using the notation of the floatformat command, similar to that
used in C.  The default is "%g".  By setting this to a string with
a different value, for example "%0.12g", the data and the simulation time
that are written to the file can be given to to a higher precision.

There are two variations of asc_file that are not documented elsewhere:

res_asc_file has two additional fields, time_res and value_res, with
default values of 0.  The data is output at intervals that are separated
by at least time_res (X-axis) OR value_res (Y-axis).  With the default
values, this means that the interval will be determined by the simulation
clock that is used.  To increase the interval, both time_res and value_res
should be set to appropriate larger values.

par_asc_file is a modified version of asc_file to be used with parallel
GENESIS (PGENESIS), in order to guarantee that SAVE messages coming from
various nodes provide outputs in a fixed order.  For more information on
the use of par_asc_file, see the section on Parallel I/O Issues in the
PGENESIS hypertext documentation.


For binary data, use disk_out.

Example:        

    create asc_file /out
    setfield /out    flush 1  leave_open 1 append 1  float_format %0.9g
    setclock 1 0.0005
    useclock /out 1
    // Assume the existence of /cell/soma to provide output
    addmsg       /cell/soma     /out       SAVE Vm
    setfield /cell/soma inject 0
    step 0.1 -t
    // append the results of a new run with different injection
    setfield /cell/soma inject 0.1e-9
    reset
    step 0.1 -t
    // now do yet another injection with output to a different file
    setfield /out filename out2
    call /out OUT_OPEN
    call /out OUT_WRITE "Run #2"        // Write a header
    setfield /cell/soma inject 0.2e-9
    reset
    step 0.1 -t
See also: disk_out , disk_in , floatformat

26.8 autocorr

Object Type:    autocorr

Description:    Computes the auto-correlation of a spike train
                A histogram containing the count of
                events for each bin is constructed.

Author:         D. Jaeger, Caltech (9/92)
                revised for Genesis v2.2 11/99

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  doac_type  [in genesis/src/device/spike_struct.h]

Size:           100 bytes

Fields:         num_bins        (int) number of bins in histogram
                binwidth        (float) binwidth in sec
                reset_mode      (int) 0 or 1    
                threshold       (float) input amplitude triggering spike event
                *acarray        (int)   histogram array containing data
                nospks          (int) number of spikes from source
                *sptimes        (float) array of spike times from source
                curridx         (int) internal indexing
                calcidx         (int) internal indexing
                maxspikes       (int) internal boundary condition
                wintime         (float) internal boundary condition
                dont            (int) internal condition
                allocated       (int) internal condition

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Doac  [in genesis/src/device/acxc.c]
Classes:        datanal

Actions:        PROCESS         update *sptimes, *acarray, nospks
                RESET           if reset_mode = 0, empties *sptimes but not
                                        *acarray
                                if reset_mode = 1, empties *sptimes and
                                        recreates *acarray

Messages:       SPIKE : signal amplitude from source 

------------------------------------------------------------------------------

Notes:
                User must setfield num_bins and binwidth (in sec) so
        that a data array is created on RESET. The input is assumed to
        cross the amplitude given in the threshold field only for one 
        timestep to generate a spike. Vm is not to be used as an input field.
        Valid inputs may be derived from random, neutral or spike objects.
                An internal spike time buffer is set up for a maximal
        spike rate of 1000 events / second. A greater density of spikes
        will lead missed events in the histogram. 
                The auto-corrlation histogram is updated with each timestep.
        However, the first results will only be available after the
        simulation time has reached the value of num_bins * binwidth.
        This is due to the fact that any spike needs to be correlated
        with other spikes across a time window of this duration.
                The data are stored in *acarray and can be accessed with
        a getfield command (see example). 

Example:        

create autocorr /ac
setfield ^ binwidth 0.002 num_bins 200 threshold 0.5

/* this example uses random object for input */
create random /input
setfield ^ min_amp 1 max_amp 1 rate {in1_rate} reset 1 reset_value 0
addmsg /input1 /ac SPIKE state

/* To display data on a graph, use this function after creating the graph */
function plotac(source, dest, pname, color)
    str source,dest,color
    int maxbin
 
    int i,barval
 
    maxbin = {getfield {source}, num_bins}
    setfield {dest} xmax {maxbin}
    call {dest} RESET
 
    for(i=0; i < maxbin; i = i + 1)
        barval = {getfield {source}, acarray[{i}]}
        addpts {dest} -plotname {pname} -color {color} {i} 0
        addpts {dest} -plotname {pname} -color {color} {i} {barval}
        addpts {dest} -plotname {pname} -color {color} {{i}+1} 0
    end
end
See also: crosscorr , interspike , peristim , Scripts/examples/spike/spikes.g

26.9 calculator

Object Type:    calculator

Description:    Adds, subtracts, multiplies, and divides using messages.

Author:         Erik De Schutter, BBF-UIA 6/98

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  calc_type [in src/device/dev_struct.h]

Size:           100 bytes

Fields:         output          computed value
                resetclock      clock # used to reset output value (default 0)
                output_init     value of output after reset (default 0)
                
------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       CalculatorFunc [in src/device/calculator.c]

Classes:        device

Actions:        RESET  PROCESS  DELETE  CREATE

Messages:       SUM         number
                SUBTRACT    number
                MULTIPLY    number
                DIVIDE      number

------------------------------------------------------------------------------

Notes:

The calculator is often used to sum multiple inputs.  For example, the
total channel current in a cell could be calculated with:

    foreach s ({el /cell/##[CLASS=channel]})
        addmsg {s} /calculator_element SUM Ik
    end

With the resetclock default of clock 0, the calculator is reinitialized to
output_init (default 0) at every time step, so that it may calculate a new
value of the sum from incoming messages at each time step.  If resetclock is
set to a clock with a longer time step, then operations are performed on
the previous output, until it is time to reset the output to output_init.
The example below uses a resetclock with a longer time step in order to
generate a periodic ramp output.

Example:

create xform /data
create xgraph /data/calculator
create xbutton /data/RESET -script reset
create xbutton /data/RUN -script "step 100"
create xbutton /data/QUIT -script quit
xshow /data

// Create a ramp generator by summing a constant input
// The length of the ramp is given by the resetclock

setclock 0 1.0
setclock 1 25.0
create neutral /source
setfield /source x 4
create calculator /source/ramp
setfield /source/ramp resetclock 1

addmsg /source /source/ramp SUM x
addmsg /source/ramp /data/calculator PLOT output *output *red
addmsg /source /data/calculator PLOT x *input *blue
reset

See also:       

26.10 compartment

Object Type:    compartment

Description:    Axially asymmetric compartment. Ra is located on
                one side of the compartment. This is slightly more
                computationally efficient than the symmetric counterpart.

Author:         M. Wilson, Caltech (6/88)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  compartment_type  [in src/segment/seg_struct.h]

Size:           124 bytes

Fields:         Rm              total membrane resistance
                Cm              total membrane capacitance
                Em              membrane resting potential
                Ra              axial resistance
                inject          injected current in membrane
                dia             compartment diameter
                len             compartment length              
                Vm              voltage across the membrane
                previous_state  Vm at previous time step
                Im              approximation to the total membrane current
                initVm          initial value to set Vm on reset

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Compartment  [in src/segment/compartment.c]

Classes:        segment
                membrane

Actions:        INIT            assign previous_state = Vm
                PROCESS         update Vm, calculate Im
                RESET           assign Vm = Em
                CHECK           make sure Rm>0, Cm>0, 
                                Ra'>0 (if RAXIAL message is present), 
                                Ra>0 (if AXIAL message is present)
                SAVE2
                RESTORE2

Messages:       CHANNEL Gk Ek   delivers the conductance and equilibrium
                                potential of channel within the compartment
                RAXIAL Ra Vm    delivers the Ra and Vm of a compartment
                AXIAL Vm        delivers the Vm of a compartment
                INJECT inject   sets the inject field to the message value
                EREST Em        sets the Em  field to the message value

------------------------------------------------------------------------------

Notes:          Simulates a section of passive membrane or cable. The
                potential across the membrane is given by Vm. There is a
                leakage path for current through the resistance Rm. This
                resistance is in series with a leakage battery Em. This
                compartment can be coupled to other compartments with an axial
                resistance Ra.  The compartment is not symmetrical, with Ra
                lumped to one side of the compartment.  Any number of ionic
                channels can be introduced into the membrane (Gk, Ek in the
                circuit diagram).  The membrane also allows current
                injection.

                The compartment Im is the sum of axial currents and injected
                current only.  The (transmembrane) channel currents or the
                leakage current are not included.  For a multicompartment
                cell, under a quasistatic approximation (C*dV/dt is small), Im
                is approximately equal to the sum of the channel and leakage
                currents, due to charge conservation.  This approximation is
                used in the efield object (see efield.txt) to allow Im to be
                used to calculate external field potentials.  The exception to
                this is when Im is calculated with hsolve in chanmode 4.  In
                that case, Im is directly calculated as the sum of the channel
                currents and leakage current though Rm.

                When a compartment performs its RESET action (usually
                invoked by the reset command), Vm is set to the value of the
                initVm field.  Normally, initVm follows any changes to Em,
                so Vm will be initialized to Em upon reset.  If, as in the
                Hodgkin-Huxley model, Em is a leakage potential that is
                different from the rest potential, initVm may be set to the
                rest potential.  It will then no longer follow Em, and Vm
                will be set to the rest potential upon reset.
                
                Calculates Vm using:
                
                    dVm/dt = {(Em - Vm)/Rm + SUM[(Ek - Vm)*Gk] + 
                        (Vm' - Vm)/Ra' + (Vm'' - Vm)/Ra + inject}/Cm

                In the diagram, the compartment shown in the middle
                receives the Vm' and Ra' of the upper compartment with
                an RAXIAL message, and the Vm'' of the lower compartment
                with an AXIAL message.  Channels deliver their Gk and Ek
                with a CHANNEL message.

                    Vm'
                   o_________________________________________________
                   |                |             |        |        |
                   \
                   /  Ra'
                   \
                   | 
                   |
                   | Vm
                   o_________________________________________________
                   |                |             |        |        |
                   \                |             |        |        |
                   /  Ra            \             \        |        |
                   \              --/-->          /        |     ___|___
                   |             Gk \        Rm   \       / \    _______ Cm
                   |                |             |      / A \      |
                   |                |             |      \ | /      |
                   |         Ek    ---       Em  ---      \ /       |
                   |             -------       -------     | Iinject|
                   |                |             |        |        |
                   |                |_____________|________|________|
                   |
                   | Vm''
                   o_________________________________________________
                   |                |             |        |        |

Example:        
See also: symcompartment

26.11 concchan

Object Type:    concchan

Description:    Concentration-driven membrane channel. Equivalent
                to 1-D diffusion of molecules across a membrane. The
                concchan, like the enzyme, is a property of a pool and so
                each concchan should be attached to a pool which specifies
                the number of concchans.

Author:         U. S. Bhalla MSSM Aug/93

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  [in src/kinetics/kin_struct.h]

Size:           124 bytes

Fields:
                A, B            Internal state variables, used to
                                communicate with pools. A represents
                                increase in the pool n, B is the decrease.
                perm            Permeability
                gmax            conductance (not currently used)
                n               number of concchans
                Vm              potential across channel (not currently used)
                use_nernst      flag (not currently used)

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       [in src/kinetics/concchan.c]

Classes:        segment

Actions:        SET  PROCESS  RESET

Messages:
                SUBSTRATE   n vol  Number of molecules in substrate pool
                PRODUCT     n vol  Number of molecules in product pool
                NUMCHAN     n      Number of concchans specified by pool
                Vm          Vm     Sets the Vm field (not currently used)

------------------------------------------------------------------------------

Notes:          The concchan allows the substrate and product pools to diffuse

                back and forth.  The state variables A and B are used in the
                return messages to the substrates and products.  (However the
                roles of A and B are reversed for the product pools).

                If there are both substrate and product pools (as evidenced by
                having both a SUBSTRATE and a PRODUCT message to the
                concchan), the SUBSTRATE message calculates conc1 = n/vol, and
                PRODUCT calculates conc2 = n/vol.  Here, n/vol represents the
                density of molecules in the pool, not the density of conchans.
                Then A and B are set to

                        A = conc2 * perm * n
                        B = conc1 * perm * n

                where n is the number of concchans.

Example:        // numerically attach the chan to the pool
                addmsg {pool} {chan} NUMCHAN n
                // Attaches the pool to the chan as a substrate
                addmsg {chan} {pool} REAC A B
                addmsg {pool} {chan} SUBSTRATE n vol

                // Attaches the pool to the chan as a product
                addmsg {chan} {pool} REAC B A
                addmsg {pool} {chan} PRODUCT n vol
See also: pool

26.12 concpool

Object Type:    concpool

Description:    A "well-mixed" concentration pool without diffusion that can
                have miscellaneous in/out flows (when coupled to other
                objects).  It has better controls over size/volume than
                Ca_concen and does not include its own equilibration
                mechanisms.

Author:         E. De Schutter BBF-UIA 4/94 - 3/99

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  concpool_type [in src/concen/conc_struct.h]

Size:           132 bytes

Fields:         C               concentration (calculated by concpool) in mM
                prev_C          concentration at previous time step
                Ceq             equilibrium concentration in mM
                val             ionic valence
                leak            constant in/outflow in mM/sec
                shape_mode      Set to one of the predefined global variables
                                SHELL=0, SLICE=SLAB=1, TUBE=2, USERDEF=3.

                    SHELL: onion shell. Set len for cylindrical shell (zero
                    length for spherical shell), dia (outer diameter of shell)
                    and thick (thickness of shell); vol, is computed on RESET.

                    SLICE (or SLAB): salami slices of cylinder.  Set dia
                    (diameter of cylinder) and thick (thickness of slab), len
                    is not used; vol is computed on RESET.

                    TUBE: a cylinder with diameter dia and length len.  For
                    concpools inside a difshell: make dia negative in the
                    prototype; readcell will scale len so as to obtain an
                    appropriate change in vol relative to the difshell.

                    USERDEF: len, dia, thick are not used. Set vol field
                    to desired pool volume.

                len             shell length
                dia             shell diameter
                thick           shell thickness
                vol             shell volume

-----------------------------------------------------------------------
SIMULATION PARAMETERS

Function:       ConcPool [in src/concen/concpool.c]

Classes:        concentration segment

Actions:        RESTORE2  SAVE2  CHECK  RECALC  RESET  PROCESS  INIT

Messages:       CONCEN      C             (sets C with a message)
                STOREINFLUX flux          (flux into store in moles/sec;
                                          increases C)
                STOREOUTFLUX flux         (flux out of store in moles/sec;
                                          decreases C)
                BUFFER kBf kBb Bfree Bbound (fields sent from a buffer,
                                                    e.g. a fixbuffer)
                HILLPUMP    vmax Kd Hill  (sent from a hillpump; setting
                                           Hill=1 is equivalent to an
                                           MMMPUMP message from an mmpump)

------------------------------------------------------------------------------

Notes:

Unlike the difshell, the concpool provides a single shell model of a
"well-mixed" concentration pool without diffusion between shells.  As it can
also couple to buffers and pumps, it provides for multiple mechanisms for
calcium removal and has better controls over size/volume than the Ca_concen.

The buffers (e.g, fixbuffer) interact with a difshell or concpool to model the
binding of calcium to buffer molecules and to calculate the concentrations of
free and bound ions using a kinetic scheme with forward and backward rate
constants for the binding and release of calcium.  The BUFFER message from a
buffer passes on the rate constants and the calculated free and bound
concentrations so that the concpool may calculate the resulting ion
concentration C.  Details of the fields that are passed to the concpool with
messages from buffers and the hillpump are provided in the documentation for
these objects.

For a general description of buffered calcium diffusion see:  De Schutter E.,
and Smolen P., "Calcium dynamics in large neuronal models", in Methods in
neuronal modeling: From ions to networks (2nd edition), C. Koch and I. Segev
editors, pp. 211-250 (1998).

Example:
See also: difshell , fixbuffer , hillpump

26.13 crosscorr

Object Type:    crosscorr

Description:    Computes the cross-correlation between two trains of
                spike events. A histogram containing the count of
                events for each bin is constructed.

Author:         D. Jaeger, Caltech (9/92)
                revised for Genesis v2.2 11/99

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  doxc_type  [in genesis/src/device/spike_struct.h]

Size:           116 bytes

Fields:         num_bins        (int) number of bins in histogram
                binwidth        (float) binwidth in sec
                reset_mode      (int) 0 or 1    
                threshold       (float) input amplitude triggering spike event
                *xcarray        (int)   histogram array containing data
                no1spks         (int) number of spikes from source 1
                no2spks         (int) number of spikes from source 2
                *sp1times       (float) array of spike times from source 1
                *sp2times       (float) array of spike times from source 2
                curr1idx        (int) internal indexing
                curr2idx        (int) internal indexing
                calc1idx        (int) internal indexing
                calc2idx        (int) internal indexing
                maxspikes       (int) internal boundary condition
                wintime         (float) internal boundary condition
                dontnow         (int) internal condition
                allocated       (int) internal condition

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Doxc  [in genesis/src/device/acxc.c]
Classes:        device

Actions:        PROCESS         update *spktimes, *xcarray, nospks
                RESET           if reset_mode = 0, empties *spktimes but not
                                        *xcarray
                                if reset_mode = 1, empties *spktimes and
                                        recreates *xcarray

Messages:       XSPIKE : signal amplitude from source 1 
                YSPIKE : signal amplitdue from source 2 

------------------------------------------------------------------------------

Notes:
                User must setfield num_bins (only even number of bins
        are allowed) and binwidth (in sec) so that a data array
        is created on RESET. The input is assumed to cross the amplitude
        given in the threshold field only for one timestep to generate
        a spike. Vm is not to be used as an input field. Valid inputs
        may be derived from random, neutral or spike objects.
                An internal spike time buffer is set up for a maximal
        spike rate of 1000 events / second. A greater density of spikes
        will lead to missing events in the histogram. 
                The cross-corrlation table is updated with each timestep.
        However, the first results will only be available after the
        simulation time has reached the value of num_bins * binwidth.
                The data are stored in *xcarray and can be accessed with
        a getfield command (see example). The 0 delay time bin is stored in
        the center of the histogram, i.e. for num_bins = 100, xcarray[49]
        contains the 0 delay time bin.

Example:        

create autocorr /xc12
setfield ^ binwidth 0.002 num_bins 200 threshold 0.5

/* this example uses random object for input */
create random /input1
setfield ^ min_amp 1 max_amp 1 rate {in1_rate} reset 1 reset_value 0     
create random /input2
setfield ^ min_amp 1 max_amp 1 rate {in1_rate} reset 1 reset_value 0

addmsg /input1 /xc12 XSPIKE state
addmsg /input2 /xc12 YSPIKE state

/* To display data on a graph, use this function after creating the graph */
function plotxc(source, dest, color)
    str source, dest, color
    int bins, minbin, maxbin, barval
                
    /*  display *xcarray of doxc element {source} on graph {dest}
         The display could be made nicer than this.  */

    bins = getfield {source}, num_bins
    minbin = -({bins} / 2)
    maxbin = {bins} / 2
    setfield {dest} xmin {minbin} xmax {maxbin}
    call {dest} RESET
    for(i=minbin; i < maxbin; i = i + 1)
         barval = {getfield {source}, xcarray[{{i}+{maxbin}}]}
         addpts {dest} -plotname xcor -color {color} {i} 0
         addpts {dest} -plotname xcor -color {color} {i} {barval}
         addpts {dest} -plotname xcor -color {color} {i} 0
    end
end

------------------------------------------------------------------------------

Notes:
        User must setfield num_bins and binwidth (in sec) so
    that a data array is created on RESET. The input is assumed to
    cross the amplitude given in the threshold field only for one 
    timestep to generate a spike. Vm is not to be used as an input field.
    Valid inputs may be derived from random, neutral or spike objects.
        An internal spike time buffer is set up for a maximal
    spike rate of 1000 events / second. A greater density of spikes
    will lead missed events in the histogram. 
        The cross-corrlation histogram ought to be used with clock 0.
    The first results will only be available after the
    simulation time has reached the value of num_bins * binwidth.
    This is due to the fact that any spike needs to be correlated
    with other spikes across a time window of this duration.
        The data are stored in *xcarray and can be accessed with
    a getfield command (see example). 
See also: autocorr , interspike , peristim , Scripts/examples/spike/spikes.g

26.14 ddsyn

Object Type:    ddsyn

Description:    modified synchan with table front end to transform voltage
                to activation, for dendro-dendritic synapses.  Calculates
                channel current therefore needs membrane state.

Author:         U. S. Bhalla, Caltech (5/91)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  dd_syn_type  [in src/olf/olf_struct.h]

Size:           164 bytes

Fields:         Gk              channel conductance
                Ik              channel current
                Ek              channel reversal potential
                gmax            maximum conductance
                tau1            open time constant of channel activation
                tau2            close time constant of channel activation
                transf          table for transform from Vm to activation;
                                usual interpolation element with the normal
                                set of fields; set up using TABCREATE, filled
                                by indexing as usual, and interpolated using
                                TABFILL
                activation      channel activation; set either by a table
                                lookup of the transform of the incoming
                                VOLTAGE message or by synaptic input
                transf_alloced  flag for allocation of transform
                X               state variable for time response
                Y               state variable for time response

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       DDSyn  [in src/olf/dd_syn.c]

Classes:        segment, channel

Actions:        INIT
                PROCESS
                RESET
                CHECK
                SET
                DUMP
                SAVE2
                RESTORE2
                TABCREATE
                TABFILL

Messages:       VOLTAGE voltage                 [tells channel what membrane
                                                potential is]

                ACTIVATION activation           [sends activation directly to
                                                channel; sums linearly with
                                                other ACTIVATION input and
                                                transformed V_PRESYN input]

                V_PRESYN presynaptic-voltage    [sends presynaptic voltage to
                                                transform table; sums linearly
                                                at output of table, so
                                                multiple V_PRESYN inputs are
                                                first transformed, then their
                                                activations are summed]

                RAND_ACTIVATION                 [rather than sending direct
                  probability  amplitude        activation signal, specifies
                                                probability (from 0 to 1) that
                                                activation of size amplitude
                                                will occur at synapse (useful
                                                for sending random synaptic
                                                input to synapse)]

------------------------------------------------------------------------------

Notes:          Dendrodendritic synapse with tabulated transform
                from presyn potential to postsyn activation.
                The table for the transform is created using tabcreate
                and is shared with all copies of the element

                The ddsyn element is the equivalent of a synchan element
                with a tabulated transform from input voltage to channel
                activation. This serves as a way of representing
                dendro-dendritic synapses.  The usual fields and messages for
                the synchan element remain available. The table entries are
                filled in the usual ways from the script interface, and can be
                shared between ddsyn elements.

Example:        Here we create a ddsyn channel to act as the synaptic input
                for granule cells in an olfactory bulb model.

                    // for dd, ax, and centrif inputs
                    create      ddsyn   glu_gran_usb
                    call glu_gran_usb TABCREATE 10 -0.070   0.05
                    setfield  glu_gran_usb \
                        Ek          {EGlu} \
                        tau1        4.0e-3 \   // sec
                        tau2        6.0e-3 \   // sec
                        gmax        {GGlu} \   // Siemens
                    // Setting up the table for transforming
                    // from presyn Vm to activation
                        transf->table[0] 0 \
                        transf->table[1] 0.05 \
                        transf->table[2] 0.1 \
                        transf->table[3] 0.2 \
                        transf->table[4] 0.5 \
                        transf->table[5] 0.7 \
                        transf->table[6] 0.8 \
                        transf->table[7] 0.9 \
                        transf->table[8] 0.95 \
                        transf->table[9] 0.98 \
                        transf->table[10] 1
                    call glu_gran_usb TABFILL 1000 0
                                
See also:  Scripts/examples/ddsyn

26.15 dif2buffer

Object Type:    dif2buffer

Description:    Implementation of a first-order diffusible (mobile) buffer
                with variable total buffer concentration.  Should be coupled
                to a difshell, where the change in the concentration of the
                buffered ion is computed.

Author:         E. De Schutter BBF-UIA 8/94 - 4/96

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  dif2buffer_type [in src/concen/conc_struct.h]

Size:           172 bytes

Fields:         activation     ion concentration from incoming CONCEN message
                Bfree          free buffer concentration (calculated) in mM
                Bbound         bound buffer concentration (calculated) in mM
                prev_free      Bfree at previous time step
                prev_bound     Bbound at previous time step
                Btot           total buffer concentration in mM (used on reset)
                kBf            forward rate constant in 1/(mM*sec)
                kBb            backward rate constant in 1/sec
                Dfree          diffusion constant for Bfree in m^2/sec
                Dbound         diffusion constant for Bbound in m^2/sec
                shape_mode     Set to one of the predefined global
                               variables SHELL=0, SLICE=SLAB=1, USERDEF=3.

                    SHELL: onion shell, for radial diffusion. Set len for
                    cylindrical shell (zero length for spherical shell), dia
                    (outer diameter of shell) and thick (thickness of shell);
                    vol, surf_up, and surf_down are computed on RESET.

                    SLICE (or SLAB): salami slices of cylinder, for axial
                    diffusion. Set dia (diameter of cylinder) and thick
                    (thickness of slab), len is not used; vol, surf_up, and
                    surf_down are computed on RESET.

                    USERDEF: len, dia, thick are not used. Set vol, surf_up
                    and surf_down.

                len             shell length
                dia             shell diameter
                thick           shell thickness
                vol             shell volume
                surf_up         area of upper (outer) shell surface
                surf_down       area of lower (inner) shell surface

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Dif2Buffer [in src/concen/dif2buffer.c]

Classes:        concbuffer segment

Actions:        RESTORE2  SAVE2  CHECK  RECALC  RESET  PROCESS  INIT  

Messages:       CONCEN  C                  (buffered ion concentration, sent
                                           from a difshell or concpool)
                BDIFF_DOWN prev_free prev_bound thick (diffusion to inner shell,
                                           sent from an outer shell)
                BDIFF_UP prev_free prev_bound thick   (diffusion to outer shell,
                                           sent from an inner shell)

------------------------------------------------------------------------------

Notes:

The buffers (e.g, fixbuffer) interact with a difshell to model the binding of
calcium to buffer molecules and to calculate the concentrations of free and
bound buffer molecules, using a kinetic scheme with forward and backward rate
constants for the binding and release of calcium.  Intracellular buffers are
often mobile, and the diffusion of buffer molecules can carry calcium with
them.  This can often make a significant contribution to the transport of
calcium, in addition to the diffusion of free Ca++ ions that is modeled by the
difshell object.  These diffusible buffers can be modeled with the difbuffer
and dif2buffer objects, instead of using the non-mobile fixbuffer.

Like the fixbuffer, the dif2buffer interacts with a difshell to model the
binding of calcium to buffer molecules and to calculate the concentrations of
free and bound buffer molecules using a kinetic scheme with forward and
backward rate constants for the binding and release of calcium.  The rate
constants kBf and kBb are set by the user, and the concentration C is sent
with a CONCEN message from the difshell.  The BUFFER message to a difshell
from a buffer passes on the rate constants and the calculated free and bound
buffer concentrations.

In addition, the dif2buffer acts like a difshell, in the sense that it allows
diffusion between adjacent buffer shells.  However, it is the free and bound
buffer molecules, rather than free ions that are diffusing.  Adjacent buffer
shells are coupled by BDIFF_DOWN and BDIFF_UP messages that are analogous to
the DIFF_DOWN and DIFF_UP messages that link adjacent difshells.  Note that a
dif2buffer should have the same dimensions and shape_mode as the difshell to
which it is coupled.

For the difbuffer, the assumption is made that the diffusion rate for bound
and free buffer molecules is the same (as they are much larger than the Ca
atoms), so there is a single diffusion constant D, and they diffuse together,
with dBbound/dt = -dBfree/dt.  The dif2buffer does not make this assumption,
and treats the diffusion of free and bound molecules separately.  Thus, there
are separate diffusion constants Dfree and Dbound, and the BDIFF_DOWN and
BDIFF_UP messages pass both the previous step Bfree and Bbound values along
with the buffer shell thickness.

NOTE: When using difshell, difbuffer, or dif2buffer elements without hsolve
(or in chanmodes 0 or 1), it will be necessary to issue two reset commands
after setting up the simulation.

For a general description of buffered calcium diffusion see:
De Schutter E., and Smolen P., "Calcium dynamics in large neuronal
models", in Methods in neuronal modeling: From ions to networks
(2nd edition), C. Koch and I. Segev editors, pp. 211-250 (1998).

Example:
See also: difshell , difbuffer , fixbuffer

26.16 difbuffer

Object Type:    difbuffer

Description:    Implementation of a first-order diffusible (mobile) buffer
                with constant total buffer concentration.  Should be coupled
                to a difshell, where the change in the concentration of the
                buffered ion is computed.

Author:         E. De Schutter BBF-UIA 8/94 - 6/96

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  difbuffer_type [in src/concen/conc_struct.h]

Size:           168 bytes

Fields:         activation     ion concentration from incoming CONCEN message
                Bfree          free buffer concentration (calculated) in mM
                Bbound         bound buffer concentration (calculated) in mM
                prev_free      Bfree at previous time step
                prev_bound     Bbound at previous time step
                Btot           total buffer concentration in mM (free + bound)
                kBf            forward rate constant in 1/(mM*sec)
                kBb            backward rate constant in 1/sec
                D              diffusion constant of buffer molecules, m^2/sec
                shape_mode     Set to one of the predefined global
                               variables SHELL=0, SLICE=SLAB=1, USERDEF=3.

                    SHELL: onion shell, for radial diffusion. Set len for
                    cylindrical shell (zero length for spherical shell), dia
                    (outer diameter of shell) and thick (thickness of shell);
                    vol, surf_up, and surf_down are computed on RESET.

                    SLICE (or SLAB): salami slices of cylinder, for axial
                    diffusion. Set dia (diameter of cylinder) and thick
                    (thickness of slab), len is not used; vol, surf_up, and
                    surf_down are computed on RESET.

                    USERDEF: len, dia, thick are not used. Set vol, surf_up
                    and surf_down.

                len             shell length
                dia             shell diameter
                thick           shell thickness
                vol             shell volume
                surf_up         area of upper (outer) shell surface
                surf_down       area of lower (inner) shell surface

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       DifBuffer [in src/concen/difbuffer.c]

Classes:        concbuffer segment

Actions:        RESTORE2  SAVE2  CHECK  RECALC  RESET  PROCESS  INIT  

Messages:       CONCEN  C                  (buffered ion concentration, sent
                                           from a difshell or concpool)
                BDIFF_DOWN prev_free thick (diffusion to inner shell, sent from
                                           an outer shell)
                BDIFF_UP prev_free thick   (diffusion to outer shell, sent from
                                           an inner shell)
                DIFF_DOWN prev_free thick  (alias for BDIFF_DOWN)
                DIFF_UP prev_free thick    (alias for BDIFF_UP)
------------------------------------------------------------------------------

Notes:

The buffers (e.g, fixbuffer) interact with a difshell to model the binding of
calcium to buffer molecules and to calculate the concentrations of free and
bound buffer molecules, using a kinetic scheme with forward and backward rate
constants for the binding and release of calcium.  Intracellular buffers are
often mobile, and the diffusion of buffer molecules can carry calcium with
them.  This can often make a significant contribution to the transport of
calcium, in addition to the diffusion of free Ca++ ions that is modeled by the
difshell object.  These diffusible buffers can be modeled with the difbuffer
and dif2buffer objects, instead of using the non-mobile fixbuffer.

Like the fixbuffer, the difbuffer interacts with a difshell to model the
binding of calcium to buffer molecules and to calculate the concentrations of
free and bound buffer molecules using a kinetic scheme with forward and
backward rate constants for the binding and release of calcium.  The rate
constants kBf and kBb are set by the user, and the concentration C is sent
with a CONCEN message from the difshell.  The BUFFER message to a difshell
from a buffer passes on the rate constants and the calculated free and bound
buffer concentrations.

In addition, the difbuffer acts like a difshell, in the sense that it allows
diffusion between adjacent buffer shells.  However, it is the free and bound
buffer molecules, rather than free ions that are diffusing.  Adjacent buffer
shells are coupled by BDIFF_DOWN and BDIFF_UP messages that are analogous to
the DIFF_DOWN and DIFF_UP messages that link adjacent difshells.  Note that a
difbuffer should have the same dimensions and shape_mode as the difshell to
which it is coupled.

For the difbuffer, the assumption is made that the diffusion rate for bound
and free buffer molecules is the same (as they are much larger than the Ca
atoms), so there is a single diffusion constant D, and they diffuse together,
with dBbound/dt = -dBfree/dt.  The dif2buffer does not make this assumption,
and treats the diffusion of free and bound molecules separately.

NOTE: When using difshell, difbuffer, or dif2buffer elements without hsolve
(or in chanmodes 0 or 1), it will be necessary to issue two reset commands
after setting up the simulation.

For a general description of buffered calcium diffusion see:
De Schutter E., and Smolen P., "Calcium dynamics in large neuronal
models", in Methods in neuronal modeling: From ions to networks
(2nd edition), C. Koch and I. Segev editors, pp. 211-250 (1998).

Example:
See also: difshell , fixbuffer , dif2buffer

26.17 diffamp

Object Type:    diffamp

Description:    Difference amplifier, takes two inputs and produces an
                output proportional to their difference.

Author:         M. Wilson, Caltech (2/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  diffamp_type  [in src/device/dev_struct.h]

Size:           96 bytes

Fields:         gain
                saturation
                plus
                minus
                output

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       DifferenceAmp  [in src/device/diffamp.c]

Classes:        device

Actions:        RESET           sets the output to zero
                PROCESS         calculates and sets the output from the inputs

Messages:       PLUS +input 
                MINUS -input 
                GAIN gain

------------------------------------------------------------------------------

Notes:

Adds inputs from PLUS messages and subtracts those received with MINUS
messages.  The output is this total, multiplied by gain, but limited to the
range -saturation to +saturatation.  If there are no MINUS messages, the
minus input is taken as zero.  Normally, the gain field is set using
"setfield", but it may also be varied with a GAIN message.  This object also
provides a convenient way to sum or scale quantities which are to be plotted
by sending a PLOT message to an xgraph.

Example:        

See also:       

26.18 difshell

Object Type:    difshell

Description:    Implementation of a concentration shell that can have
                miscellaneous in/out flows (when coupled to other objects),
                and one-dimensional diffusion between other difshells.

Author:         E. De Schutter BBF-UIA 4/94 - 3/99

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  difshell_type [in src/concen/conc_struct.h]

Size:           152 bytes

Fields:         C               concentration (calculated by difshell) in mM
                prev_C          concentration at previous time step
                Ceq             equilibrium concentration in mM
                D               diffusion constant in m^2/sec
                val             ionic valence
                leak            constant in/outflow in mM/sec
                shape_mode      Set to one of the predefined global
                                variables SHELL=0, SLICE=SLAB=1, USERDEF=3.

                    SHELL: onion shell, for radial diffusion. Set len for
                    cylindrical shell (zero length for spherical shell), dia
                    (outer diameter of shell) and thick (thickness of shell);
                    vol, surf_up, and surf_down are computed on RESET.

                    SLICE (or SLAB): salami slices of cylinder, for axial
                    diffusion. Set dia (diameter of cylinder) and thick
                    (thickness of slab), len is not used; vol, surf_up, and
                    surf_down are computed on RESET.

                    USERDEF: len, dia, thick are not used. Set vol, surf_up
                    and surf_down.

                len             shell length
                dia             shell diameter
                thick           shell thickness
                vol             shell volume
                surf_up         area of upper (outer) shell surface
                surf_down       area of lower (inner) shell surface

------------------------------------------------------------------------------
SIMULATION PARAMETERS

Function:       DifShell [in src/concen/difshell.c]

Classes:        concentration segment

Actions:        RESTORE2  SAVE2  CHECK  RECALC  RESET  PROCESS  INIT

Messages:       INFLUX      I_Ca          (current flow in A; increases C)
                OUTFLUX     I_Ca          (current flow in A; decreases C)
                FINFLUX     I_Ca fraction (current flow, scaled by fraction)
                FOUTFLUX    I_Ca fraction (current flow, scaled by fraction)
                STOREINFLUX flux          (flux into store in moles/sec;
                                          increases C)
                STOREOUTFLUX flux         (flux out of store in moles/sec;
                                          decreases C)
                DIFF_DOWN   prev_C thick  (diffusion to inner shell, sent from
                                           an outer shell)
                DIFF_UP     prev_C thick  (diffusion to outer shell, sent from
                                           an inner shell)
                BUFFER      kBf kBb Bfree Bbound    (fields sent from a buffer,
                                                    e.g. a fixbuffer)
                TAUPUMP     kP Ceq        (sent from a taupump)
                EQTAUPUMP   kP            (sent from a taupump; uses Ceq from
                                          the difshell)
                MMPUMP      vmax Km       (sent from a mmpump)
                HILLPUMP    vmax Kd Hill  (sent from a hillpump)

------------------------------------------------------------------------------

Notes:

The concentration of intracellular calcium close to the cell membrane surface
can have a significant influence on the conductance of calcium dependent
potassium channels and on mechanisms for synaptic plasticity.  Unless the
neural compartment is very small and the calcium is "well-mixed", the calcium
concentration may vary considerably within the compartment.  It may then be
necessary to model diffusion within the compartment by dividing it into a
number of shells.  The difshell object is used for modeling these shells and
diffusion between them.  It may also be used for modeling axial diffusion
between compartments.  Just as the length of a neural compartment should be
chosen to give small differences in membrane potential between adjacent
compartments, the thickness of diffusion shells should be chosen to give small
differences in concentration between adjacent shells.

A difshell is typically coupled to buffers and/or pumps, in order to provide
for multiple mechanisms for calcium removal.

The buffers (e.g, fixbuffer) interact with a difshell or concpool to model the
binding of calcium to buffer molecules and to calculate the concentrations of
free and bound ions using a kinetic scheme with forward and backward rate
constants for the binding and release of calcium.  The BUFFER message from a
buffer passes on the rate constants and the calculated free and bound
concentrations so that the difshell may calculate the resulting ion
concentration C in the shell.

The ionic pumps provide various mechanisms to remove ions from the shell.
Details of the fields that are passed to the difshell with messages from
the pumps are provided in the documentation for the various pump objects.

The various FLUX messages assume SI units for the Faraday constant, currents
and dimensions.  If other units are used, scale the val parameter to account
for this.

NOTE: When using difshell, difbuffer, or dif2buffer elements without hsolve
(or in chanmodes 0 or 1), it will be necessary to issue two reset commands
after setting up the simulation.

For a general description of buffered calcium diffusion see:
De Schutter E., and Smolen P., "Calcium dynamics in large neuronal
models", in Methods in neuronal modeling: From ions to networks
(2nd edition), C. Koch and I. Segev editors, pp. 211-250 (1998).  The
spinedemo simulation gives a detailed example of the use of the difshell,
taupump, and fixbuffer objects for modeling calcium diffusion in dendritic
spines.

Example:

  /* based on spinedemo, for spine head initial shell (headshell0) */

  create difshell headshell0
  setfield headshell0 C 0.000020 Ceq 0.000020 D 6.0e-10 val 2.0  leak 0.0
  setfield headshell0 shape_mode {SLAB} len 0.0 dia 0.5e-6 thick 0.1e-6

  /* Ca fraction of NMDA current is influx into outer shell */
  addmsg Mg_block headshell0 FINFLUX  Ik 0.128

  /* attach fast immobile buffer */  headbuf0
  create fixbuffer headbuf0
  setfield headbuf0 Btot 0.2 kBf 5.0e5 kBb 500 // mM, 1/(mM*sec), 1/sec
  addmsg headbuf0 headshell0 BUFFER kBf kBb Bfree Bbound
  addmsg headshell0 headbuf0 CONCEN C

  /* attach the pump */
  create taupump headpump0
  setfield headpump0 Ceq 0.000020
  /* The pump rate is proportional to the surface-to-volume ratio
     spine head initial shell is end of cylinder, so stv=1/thick */
  setfield headpump0 T_C {thick/Pump_kP} // pump rate Pump_kP = 1.4e-5
  addmsg headpump0 headshell0 TAUPUMP kP Ceq

  /* set up diffusion messages, assuming the existence of headshell1 */
  addmsg headshell0 headshell1 DIFF_DOWN prev_C  thick
  addmsg headshell1 headshell0 DIFF_UP   prev_C thick

  // similar statements for the other shells ...
See also: taupump , fixbuffer , Scripts/examples/spinedemo

26.19 disk_in

Object Type:    disk_in

Description:    Reads in a 2-d array of data from an ascii or binary file.

Author:         U. S. Bhalla, Caltech (1/90)
                Coordinate read-in added by U. S. Bhalla, Mt. Sinai, 5/95.

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  disk_in_type  [in src/olf/olf_struct.h]

Size:           148 bytes + allocation for arrays and interpols

Fields:         filename        name of data file
                leave_open      flag: leave file open between steps [cycles]
                nx              x dimension of input val array
                ny              y dimension of input val array
                loop            flag: return to start of file on EOF
                val             2D array of input values
                fp              pointer to file
                fileformat      flag: 0 (default) for ASCII, 1 for FMT1
                time_offset     offset from sim time for FMT1 files
                is_open         internal flag : is file open yet?
                allocated       internal flag: Is array allocated yet?
                tempdata        data array used for FMT1 reading
                start_time      field used for FMT1 handling
                dt              field used for FMT1 handling
                datatype        field used for FMT1 handling
                header_size     field used for FMT1 handling
                lastpos         field used for FMT1 handling
                xpts,ypts,zpts  Interpols used for storing coordinate
                                information when FMT1 files are read.

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       DiskIn  [in src/olf/disk_in.c]

Classes:        segment

Actions:
        RECALC  CHECK  SET  RESET  PROCESS  INIT

Messages:       
        none
------------------------------------------------------------------------------

Notes:  
                The disk_in element reads in data from a file to the val
                array in the element every clock tick.  This is a 2-d array
                with dimensions set by the nx and ny fields.

                The source file can be either in ASCII or FMT1 formats.  FMT1
                is the GENESIS-specific format used by disk_out.  Data in
                FMT1 files is time-stamped, and accessed according to the
                current simulation clock.

                At RESET, disk_in automatically figures out if the file
                is FMT1. If not it assumes it is ASCII. The fileformat
                flag is set accordingly. 

                FMT1 files contain information on the number of data items, 
                and the 3-d coordinate information for each item. On RESET,
                the 'val' array is automatically allocated for the data values.
                nx is set to 1, and ny is set to the number of data items.
                Also on RESET, the coordinate information is loaded into the
                xpts,ypts,zpts interpol-structs, which are automatically
                allocated as needed. These interpols can be accessed in
                the usual ways. See the interpol documentation.

                ASCII files do not have coordinate information. The nx and ny
                fields must be set prior to reading in an ASCII file, so
                that the disk_in can figure out how many data points to
                read per time-step. Changing nx and ny causes
                automatic reallocation of the 'val' array, with dire
                results for any messages that had been linked to earlier
                incarnations of the val array.  In other words, never set
                the nx or ny unless you are sure that no messages
                are being sent from the input array. Typically one sets
                nx and ny as soon as one creates the disk_in, and
                later adds messages.

                The leave_open flag should normally be set to 1 to avoid
                closing and reopening the file every clock tick.

                The time_offset field allows one to specify the difference
                between the simulation time and the FMT1 internal time stamp.

                The format of the ascii file is simply a sequence of numbers,
                separated by spaces, tabs or newlines, with a maximum of 16
                numbers per line.  They are read in sequentially to fill the
                val[x][y] array, the x index being incremented more rapidly .
                Every time a new clock tick is read in, the reading starts
                from a new line, discarding any unread data on the previous
                line.

                The format of the FMT1 file is highly condensed. See the
                source (in src/out/out_view.c) and the documentation for
                disk_out for more details. In general, it includes information
                on the size of the file, the coordinates of all elements
                whose values are stored, and the time-step at which successive
                data values are stored.

Example:        

    create disk_in /in
    // read a single line with 2 variables at each time step
    // from the file Vm1 (in Scripts/MultiCell)
    setfield  /in nx 2 ny 1 filename Vm1 dt 1 leave_open 1
    create xform /form
    create xgraph /form/graph
    setfield /form/graph xmax 500 ymin -100 ymax 50
    // The Vm value is the second one on each line
    addmsg /in /form/graph PLOT val[1][0] *Vm *red
    xshow /form
    reset
    step 500
Alternatively, the message from the disk_in element could have been an INPUT
message to a spikegen element.  The spikegen element could then send a SPIKE
message to a synchan element, as in Scripts/tutorials/tutorial4.g.

If we had 100 cells, each containing a spikegen element, with names
``cell[0]/spike'' through ``cell[99]/spike'' and a data file containing
multiple groups of 10 lines with 10 Vm values each, to represent 100
simultaneous inputs, we could use statements like this:

    // send a message for each spike generator
    for (i=0;i<=9; i = i + 1)
        for (j=0;j<=9; j = j + 1)
             addmsg /in /cell[{j + 10*i}]/spike INPUT val[{i}][{j}]
        end
     end

Normally, you will want to use a clock with a much larger step for reading
in the data than that used for the integration of the equations for
calculating membrane potentials, etc.  Otherwise, the data file would have
to be very large.  The example in Scripts/examples/XODUS/fileview also
illustrates the use of arrays and the binary format.

See also: asc_file , disk_out , floatformat,

26.20 disk_out

Object Type:    disk_out

Description:    

The disk_out object is used to write data to a file in a special binary
format.  This is done at every time step of the clock which is assigned.
These files are usually used with a disk_in object and the xview widget or
the xgraph widget to "replay" the results of a simulation.  An external
program (or your own compiled GENESIS function) can write files in this
format in order to provide a convenient interface to the display
capabilities of XODUS.

Author:         M. Wilson, Caltech (6/88)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  file_type  [in src/out/out_struct.h]

Size:           88 bytes

Fields:         filename        data file name to be written
                fp              data file pointer
                is_open         flag: is file currently open?
                initialize      flag: has file been initialized?
                leave_open      flag: leave file open? 1 leaves the file open
                                all the time so you can write on it whenever
                                you want (a good idea if the file is used
                                frequently, but there is a limit to number of
                                files which can be left open any any time);
                                0 closes the file after every write to it
                                (only useful if you have more than 30 files;
                                this is slow)
                append          flag: append data after resetting?
                flush           flag: flush data to disk at each interval?
                                1 forces program to send data to the disk at
                                once and not store it in a buffer (slow but
                                secure); 0 (default) writes data in a buffer
                                (fast)

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       FileOutput  [in src/out/out_file.c]

Classes:        output

Actions:
        SAVE  DELETE  PROCESS  RESET

Messages:       SAVE data

------------------------------------------------------------------------------

Notes:

If the filename field is not set, the output file will be given the same
name as the element which is created from the disk_out object.  Use asc_file
for writing the data in ASCII format.

Example:

(from Scripts/orient_tut/V1_output.g)

function do_disk_out(diskpath,srcpath,field)
  str name
  create disk_out /output/{diskpath}
  setfield /output/{diskpath} leave_open 1  flush 1
  addmsg {srcpath} /output/{diskpath} SAVE {field}
end

do_disk_out vert_disk /lgn/vert/soma[] Vm
do_disk_out horiz_disk /lgn/horiz/soma[] Vm

Also see the example in Scripts/examples/XODUS/fileview/generate.g.

Normally, you need not be concerned with the format of the files produced
by a disk_out element.  However, you may wish to write either a GENESIS
function or an external program which produces an output file which can
be displayed with an xview widget.  The code which writes a disk_out
file can be found in /usr/genesis/src/out/out_file.c, and the code which
reads the data from the file can be found in /usr/genesis/src/out/out_view.c.

The following two C programs describe this format and show how to write and
read these data files.

------------------------------------------------------------------------------

/* diskwrt.c - a demo program to write a sample file "test_disk" in the
GENESIS "disk_out" format, to be viewed with the xfileview widget.  */

#include <stdio.h>
#include <math.h>

main()
{
FILE *fpr;
int width = 5;
int height = 5;
float start = 0.0;
float dt = 1.0;
float x, y, data;
int ntimes;

fpr = fopen("test_disk", "w");
headerwrt(start, dt, width, height, fpr);

data = 0.0;     /* make some bogus data */
for (ntimes = 0; ntimes < 20; ntimes++)
    for (y = 0.0; y < height; y++) {
        for (x = 0.0; x < width; x++) {
            data = x*x + y*y + height*ntimes;
            fwrite (&data, sizeof (float),1, fpr);
        }
}
fclose(fpr);
} /* end main */

headerwrt(start, deltat, width, height, fp)
/* Header for files compatible with GENESIS disk_out
"FMT1" - 80 byte null terminated character string as identifying label
start - starting time - float
dt - time step - float
ndata - number of data points per time step - int
datatype - int code for data type - disk_out uses only FLOAT = 4, but
        display routines can use DOUBLE = 5, INT = 3, SHORT = 2.
x1,y1,z1,x2,y2,z2,....,xndata,yndata,zndata - x,y,z coordinates for icon
        representing each data point - float
The header is then followed by data -  ndata values for each time step,
        with the data type specified by "datatype".
*/

float start, deltat;
int   width, height;
FILE *fp;
{
char label[80];
float strt, dt;
int ndata, datatype;
float x, y, z;
float dx = 2.0;         /* horiz spacing between icons */
float dy = 2.0;         /* vert spacing between icons */
int i, j;

    strt = start;       /* use local variables so addresses are correct */
    dt = deltat;        /* otherwise fwrite gets wrong start and deltat  */

    strcpy(label,"FMT1");
    fwrite (label, sizeof (char),80, fp);
    fwrite (&strt, sizeof (float),1, fp);
    fwrite (&dt, sizeof (float),1, fp);
    ndata = width*height;
    fwrite (&ndata, sizeof (int),1, fp);
    datatype = 4;       /* use float data */
    fwrite (&datatype, sizeof (int),1, fp);
    z = 0.0;            /* 2-D display */
    for (j=0, y = 0.0; j < height; j++) {
        for (i=0, x = 0.0; i < width; i++) {
            fwrite (&x, sizeof (float),1, fp);
            fwrite (&y, sizeof (float),1, fp);
            fwrite (&z, sizeof (float),1, fp);
            x = x + dx;
        }
        y = y + dy;
    }
}
------------------------------------------------------------------------------

/* diskrd.c - Reads and displays the header information of files produced by
the GENESIS disk_out widget */

#include <stdio.h>

main(argc,argv)
int     argc;
char    **argv;
{
char    label[100];
float   fval;
int     i;
int ndata;
int datatype;
FILE    *fp;

    if(argc < 2){
        printf("usage: %s filename\n",argv[0]);
        exit();
    }
    if((fp = fopen(argv[1],"r")) == NULL){
        printf("unable to find file '%s'\n",argv[1]);
        exit();
    }
    /*    read in the file header    */
    fread(label,sizeof(char),80,fp);
    /*    check the label    */
    if(strncmp("FMT1",label,4) != 0){
        printf("file '%s' is not a valid FMT1 data file\n",argv[1]);
        fclose(fp);
        exit();
    }

    /*    starting time    */
    fread (&fval, sizeof (float),1,fp);
    printf("%-20s = %e\n","start time",fval);
    /*   time step    */
    fread (&fval, sizeof (float),1,fp);
    printf("%-20s = %e\n","time step",fval);
    /*    number of data points    */
    fread (&ndata, sizeof (int),1,fp);
    printf("%-20s = %d\n","ndata points",ndata);
    /** data type    */
    fread (&datatype, sizeof (int),1,fp);
    printf("%-20s = %d\n","data type",datatype);
    fclose(fp);
}

----------------------------------------------------------------------------
See also: disk_in , asc_file

26.21 diskio

Object Type:    diskio

Description:

The diskio object can be used to open/create a binary format file on disk
(specified with -fileformat option) that can be then used to read/write
data or metadata from/to it with child objects, 'variable' or 'metadata'
respectively in this same library.  Unlike disk_out/disk_in, the reading
and writing actions are combined into this one new object. 

For purposes of backwards compatibility (BC), diskio responds to the 
set of messages that disk_out and disk_in respond to at a minimum, and 
allows the user to read/write files directly from/to the disk at every
time-step of the clock which is assigned. It also allows the "replay" of 
the results of a simulation through the xview and xgraph widgets in XODUS
by message passing as well as the "xsimplot" command added in genesis 2.2.

As of GENESIS 2.2, diskio supports files in the FMT1 and Netcdf formats.
Netcdf is a portable, network transparent, public domain binary format.
Netcdf interfaces to various popular analysis/signal-processing tools
including MATLAB are available in the public domain. Specifically,

        * MEXCDF 
                WEB: http://crusty.er.usgs.gov/mexcdf.html 
                FTP: crusty.er.usgs.gov (128.128.19.19) or contact
                         Rich Signell at rsignell@crusty.er.usgs.gov. 
        
        * MexEPS 
                WEB: http://www.pmel.noaa.gov/epic/mexeps.html 
                FTP: ftp.pmel.noaa.gov/epic/mexeps/

        * fanmat 
                WEB: http://www.unidata.ucar.edu/packages/netcdf/contrib.html
                FTP: ftp.unidata.ucar.edu/pub/netcdf/contrib/fanmat.taz

are freely available packages that allow MATLAB to read/write/visualize
netcdf data.

The implementation of the diskio library and the diskio, metadata, and
variable objects makes use of netcdf, which is Copyright
1993-1997 by University Corporation for Atmospheric Research/Unidata.  the
netcdf library is provided as per the terms of the UCAR/Unidata license,
described in the copyright notice found in the src/diskio/interface/netcdf
directory tree.

Author:         V.Jagadish, Caltech (9/96)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure: Gen_Diskio_Type  [in src/diskio/diskio_struct.h]

Size:           172 bytes + allocation for arrays and interpols

Fields:         accessmode      Mode with which the file is accessed
                                - 'r', 'w' or 'a' (Read/Write/Append)

                                - Read-only field specifiable on the
                                  command line using the -accessmode option
                                  but cannot be set/unset subsequently
                                  using setfield

                                - Defaults to 'r' (Read mode) as this is the
                                  most non-destructive
                                - Append 'a' mode is not supported currently

                                - BC NOTE: Due to the default mode being
                                  readonly 'r', it is not sufficient to
                                  merely replace creation-lines of disk_out
                                  with diskio but to add the option
                                  "-accessmode w" as well.  cf. See Examples.

                filename        Data file name to read from or write into
                                - Defaults to name of object if not specified
                                - Can be set/unset as required : The old file
                                  will have data and metadata written into it 
                                  till that point in time, if the accessmode 
                                  was 'w' (write). 

                fileformat      Format of the data file
                                - Unlike disk_out it is a character string 
                                  field but allows numerical setting for BC. 
                                  ("1" => FMT1, "2" => netcdf)
                                - Defaults to FMT1 if not specified
                                - Subsequent setting/unsetting of this
                                  field is allowed only to preserve BC with
                                  disk_out/disk_in. This is effectively a
                                  NOP as far as the physical file is
                                  concerned. Only the the value of the
                                  field changes to reflect the setting and
                                  is not recommended.

                append          Flag: 1 => data should be appended to file
                                after RESET. This has certain implications
                                from the point of view of interpreting the
                                'variable' object value[], input and output
                                fields.  If the append flag is on, there
                                could be more than 1 value associated with
                                a single time instance. The output field
                                will always reflect the first value for the
                                time instant set for the input field. All
                                values however can be retrieved from the
                                value[] field and the size field of the
                                variable will show the total number of
                                values stored. The user needs to keep track
                                of when the reset was done and the time
                                step rate (dt) to interpret the values
                                stored in the value[] field.

                is_open         Read-only flag: is file currently open?

                is_writable     Read-only flag: is file writable?

                val             2D array of input values        
        
                nx              x dimension of input val array 

                ny              y dimension of input val array

                xpts,ypts,zpts  Interpols used for storing coordinate
                                information when the binary file is read

                flush           Same functionality as in disk_out       

                leave_open      Same functionality as in disk_out       

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Gen_Diskio  [in src/diskio/gen_diskio.c]

Classes:        output

Actions:        CREATE PROCESS SET ADDMSGIN DELETEMSGIN SHOW

                RESET:
                        It is essential that the RESET action be called 
                        on the diskio object for allocating and filling the 
                        "xpts ypts zpts" interpol arrays before using 
                        them to render/replay data graphically on the   
                        xview objects. 
                        cf. Example: Scripts/examples/diskiolib/diskio
                                                        /replayview.g

                QUIT:
                FLUSH:
                UPDATE: when called on the diskio object, allows the user 
                        to commit any changes done interactively 
                        or in the process of running a simulation or script, 
                        to the file on disk. This allows another diskio 
                        object to simultaneously access updated data from the 
                        same file.

                DELETE: also commits changes but with the usual effect of 
                        deleting the object and all its children. Please note 
                        that this action does not delete the physical file on 
                        disk. 

                GENERAL NOTE:   The process of committing changes to disk is 
                                time-consuming for netcdf files. This is
                                inherent in the implementation of the
                                netcdf library. So please expect high
                                latency after you quit or do a delete or
                                call one of the above 4 actions on the
                                diskio object, when supporting the netcdf
                                fileformat. In general, the netcdf library
                                provides its portability across
                                architectures at the cost of efficiency in
                                speed. Therefore, performance-wise one will
                                notice diskio is slower than
                                disk_out/disk_in, in this situation. The
                                same is however not true for FMT1 file
                                support.

Messages:       SAVE data

                IMPORTANT BACKWARDS COMPATIBILITY (BC) NOTES:
                ---------------------------------------------

                As previously mentioned, diskio responds to the same set of 
        messages that disk_out and disk_in respond to as a minimum, for
        purposes of BC. 
        
        Since the actual data is encapsulated within the variable object
        and the design eventually envisages the exclusive use of this child
        object to manipulate data, any incoming SAVE messages to the diskio
        object (thro the addmsg command) will result in the automatic
        creation of child variables and the forwarding of the message to
        them. So the data will be stored and manipulated via these child
        variables, while letting the user transparently deal only with the
        diskio object as was done previously with disk_out/disk_in.

        For every SAVE message there will be a specially named child 
        variable object - 'autoSAVE_diskio[i]', where i is the index of 
        the element and that corresponds to the number of the message.   
        The indices will be reused if any messages are deleted and added 
        later. 

        Also, for every SAVE message, the 3-D position coords of the source
        element needs to be stored for possible future replay via graphical
        objects like xview. This is done through the automatic creation of
        specially named indexed metadata children -
        'auto3-DPosSAVE_diskio[i]'.

        So in applications where diskio is intended to be used as a
        replacement for disk_out/disk_in, these variables & metadata will
        be automatically created in the hierarchy for every SAVE message to
        the object. Directly manipulating these child objects should be
        avoided, since it would essentially change the contents of the
        file, if committed.  

        Example: 
                * Run Scripts/examples/diskiolib/diskio/generate.g
                * genesis> le /diskio

------------------------------------------------------------------------------

Notes:

As a departure from the disk_out/disk_in objects, this object internally 
just serves to interface (open/create/close) with a binary file on disk.  

The actual data in the file can be more flexibly managed using the child
'variable' objects in this library.  For purposes of backwards
compatibility, however, the diskio object will respond to the same messages
as the disk_out and disk_in objects at a minimum to actively write/read
data to/from the file during a simulation run. 

Some binary file formats notably netcdf (which this library supports) allow
descripive data (metadata) to be stored in them along with the actual data.
Child 'metadata' objects in this library allow the user to manipulate the 
metadata content in these files.

Use asc_file for writing data in ASCII format. 

Examples:

0. create diskio /dout -filename testfile.nc -fileformat netcdf -accessmode w

        // Not specifiying a fileformat while creating a file defaults to FMT1 
1. create diskio /dout_FMT1 -filename testfile.fmt1 -accessmode w

2. call /dout UPDATE

3. delete /dout 

4. Also, please see Scripts/examples/diskiolib/diskio/
                                        - generate.g
                                        - generate_netcdf.g
                                        - replayview.g
                                        - replaygraph.g
                                        - simplot.g
______________________________________________________________________________
See also: variable , metadata , disk_out , disk_in , asc_file

26.22 efield

Object Type:    efield

Description:    An extracellular field potential recording electrode that uses
                current sources and their distance from the electrode site to
                calculate the field.            

Author:         M. Wilson, Caltech (2/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  efield_type  [in src/device/dev_struct.h]

Size:           64 bytes

Fields:         scale
                field
                x
                y
                z

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       ExtracellularRecordingElectrode  [in src/device/efield.c]

Classes:        device

Actions:        PROCESS
                RESET
                RECALC

Messages:       CURRENT current 0.0

------------------------------------------------------------------------------

Notes:          If one assumes that the medium surrounding neurons is
                of homogeneous resistivity and has no capacitance,
                then the field potential generated by a compartmental
                model can be calculated from the following equation:

                                          Im
                              1      n      i   
                        F = ------  SUM  -----  (see Nunez, 1981)
                            4*pi*s  i=1    R
                                            i

                where F is the field potential in volts, s is
                conductivity in 1/(Ohms*m), Im_i is the transmembrane
                current (Amperes) accoss the ith  neural compartment,
                and R_i is the distance from the ith neural
                compartment to the recording electrode (i.e. the
                efield object).  

                This equation is most accurate in the case of elongated
                neurons oriented with the axis perpendicular to the scalp, as
                is the case with cortical pyramidal cells.  It is probably not
                very good for a small cell.  See the documentation of
                compartment and symcompartment for details of the calculation
                of the compartment Im.

                In the case of the efield object, the term 1/(4*pi*s) 
                is replaced by the scale field, otherwise the same
                equation is used to calculate field potentials.
                The RECALC action must be called in order for efield 
                to calculate the distances to neural compartments.

                For more information about field potentials and how
                they are used in GENESIS simulations, see Chapter 9 in
                The Book of GENESIS.  For a derivation of the above
                equation, see:

                Nunez, P.L. (1981) Electric Fields of the Brain: The
                Neurophysics of EEG, Oxford University Press, Oxford.
                                                        
Example:        create efield electrode
                setfield electrode scale -1e3 x 0.00 y 0.00 x 0.00
                addmsg some_compartment electrode CURRENT Im 0.0
                call electrode RECALC
See also: Scripts/piriform/field.g, compartment , symcompartment

26.23 enz

Object Type:    enz

Description:    Enzyme activity for a pre-existing pool. An enz does two
                things: it handles the reactions in the Michaelis-Menten (MM)
                scheme below, and it also acts as a pool to represent the
                enzyme-substrate complex. It can only be
                created on a pool, it is not an independent object.

                The MM scheme is modeled as:
                                        k1              k3
                Substrate + Enzyme  <-----> EnzComplex ----> Enz + Prd
                                        k2

                The enz is really a utility object, as it replaces
                two reacs and a pool, but does not add anything extra.
                
Author:         U. S. Bhalla, National Centre for Biological Sciences,
                Bangalore, India. (1993).

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  enz_type  [in src/kinetics/kin_struct.h]

Size:           bytes

Fields:         CoComplex               Concentration of enz-substrate complex.
                                        CoComplex = nComplex/vol
                CoComplexInit           Initial concentration of enz-substrate
                                        complex.
                                        CoComplex gets set to this value on
                                        RESET.
                nComplex                Number of molecules of complex.
                nComplexInit            Initial number of molecules of complex.
                                        'nComplex'gets set to this value on
                                        RESET.
                vol                     Volume occupied by enzyme. Often
                                        involves scale factor so as to have
                                        direct conversion from 'n' to some
                                        sensible units of Co, such as
                                        micromolar.
                sA                      A state variable to pass to substrate
                                        in messages.
                pA                      A state variable to pass to products
                                        in messages.
                eA                      A state variable to pass to parent
                                        enzyme pool in messages.
                B                       B state variable to pass to substrate
                                        and parent enzyme pool in messages
                k1,k2,k3                Michaelis-Menten parameters. 

                keepconc                Flag determining whether to change
                                        concs or n when volume changes
                usecomplex              Flag. Determines whether the enzyme
                                        complex is used when the parent enzyme
                                        is involved in other reactions.
                                        Consider:

                                        E + A <----> E.A
                                        
                                        where E is a pool reacting with A.
                                        Suppose E has an enzyme site. Then,
                                        whenever some of the enzyme is complexed
                                        with a substrate, the conc of E
                                        decreases unless 'usecomplex' is true.
                ksum                    Internal variable. ksum = k2 + k3.
                
------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       EnzFunc  [in src/kinetics/enz.c]

Classes:        segment

Actions:        PROCESS
                RESET
                SET

Messages:       ENZYME          n       [n is number of molecules of enzyme
                                        pool to which this site is attached]
                SUBSTRATE       n       [Number of molecules of substrate]
                VOL             vol     [volume of enzyme pool]
                INTRAMOL        n       [Total number of molecules in an
                                        intramolecular reaction]

------------------------------------------------------------------------------

Notes: See pool documentation for example of use.

------------------------------------------------------------------------------

26.24 event_tofile

Object Type:    event_tofile

Description:    A gizmo that collects an INPUT message. When value
                in message exceeds threshold, current simulation
                time is written to asci file.
                
                Designed to allow ascii output from a range of
                objects, like channelC3, synchan, timetable.

Author:         D. Jaeger, Caltech (3/95)

---------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  event_tofile_type [in genesis/src/device/spike_struct.h]

Size:           64 bytes

Fields:         fname           File name of asci output
                fp              file pointer
                open            flag
                threshold       threshold above which time is written to file

-----------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       Event_tofileFunc  [in genesis/src/device/event_tofile.c]

Classes:        device

Actions:        PROCESS
                SET
                OPEN
                CLOSE
                FLUSH

Messages:       INPUT compared against threshold

-----------------------------------------------------------------------

Notes:  An ascii file containing simulation times at which an event
        occurred is generated. The event arrives via an INPUT
        message, and is generated when the input value exceeds
        threshold. Only positive thresholds are implemented.

        Before activation the file needs to be opened with a reset or call
        OPEN statement.  The generic openfile, writefile, and closfile
        commands can NOT be used with the same file.

Example: 

create synchan syn
create event_tofile etf
set etf fname test.asc
sendmsg syn etf INPUT activation
reset
... // run simulation
call etf CLOSE
See also: openfile , writefile , closefile (for general asci file control), timetable , spikegen , randomspike (for good source elements to feed into event_tofile), Scripts/examples/spike/spikes.g.

26.25 facsynchan

Object Type:  facsynchan
 
Description:    Synaptically activated channel with synaptic facilitation 
                and/or synaptic depression.

Author:         Mike Vanier
 
------------------------------------------------------------------------------
 
ELEMENT PARAMETERS
 
DataStructure:  fac_synchan_type  [in src/newconn/newconn_struct.h]
 
Size:           252 bytes
 
Fields:         activation         driving force ("transmitter") for channel
                                   conductance
                Ik                 channel current
                Gk                 time varying channel conductance
                Ek                 reversal potential of channel
                tau1               first time constant of channel activation
                tau2               second time constant of channel activation
                gmax               peak channel conductance (but see Notes below)
                nsynapses          number of incoming spike messages
                                   (readonly)
                event_buffer_size  size of event buffer (readonly)
                pending_events     number of pending spike events in event 
                                   buffer (readonly)
                nodes_per_synapse  number of event nodes to allocate per 
                                   synapse (default 1)
                synapse            synapse buffer
                fac_depr_on        flag: no fac/depr if 0
                max_fac            upper limit on facilitation
                fac_per_spike      synaptic facilitation per spike
                fac_tau            time constant of synaptic facilitation
                depr_per_spike     synaptic depression per spike
                depr_tau           time constant of synaptic depression

------------------------------------------------------------------------------

SIMULATION PARAMETERS
 
Function:       FacSynchan  [in src/newconn/facsynchan.c]
 
Classes:        segment channel synchannel

Actions:        CREATE          Set default values and initialize object.
                PROCESS         Update Gk, calculate Ik, update facilitation/
                                depression state of synaptic weights.
                RESET           Assign activation = 0, Gk = 0; calculate
                                time-step-dependent coefficients; remove
                                all pending SPIKE events; reset facilitation/
                                depression state of synaptic weights.
                RECALC          Recalculate time-step-dependent coefficients.
                CHECK           Make sure tau1>0, tau2>0, gmax>0; make sure a 
                                VOLTAGE message is present (in order to
                                calculate Ik); make sure facilitation/ 
                                depression parameters are reasonable.
                SAVE2           Called by the save command.
                RESTORE2        Called by the restore command
                EVENT           Put a spike event into the event buffer.
                ADDMSGIN        Add a new message.
                DELETEMSGIN     Delete a message.
                MSGINDELETED    Do cleanup after message is deleted.
                RESETBUFFER     Reset size of event buffer to 
                                (nodes_per_synapse * nsynapses) nodes.
                DELETE          Delete the element.
                COPY            Copies the element.
 
Messages:       VOLTAGE         Vm
                SPIKE
 
------------------------------------------------------------------------------
 
Notes:          The `facsynchan' object is a version of the synchan object
                that can exhibit synaptic facilitation, synaptic depression,
                or some combination of the two.

                1) General information about synchans.

                The `facsynchan' object, like all synchan objects, simulates a
                time dependent synaptically activated ionic channel.  A
                variable channel conductance `Gk' is activated by the
                application of transmitter. This conductance then changes with
                damped second-order characteristics with a time course given
                by two time constants `tau1' and `tau2'.  This gives rise to
                an alpha function/dual exponential conductance waveform for an
                impulse spike input.  The channel also calculates channel
                current (`Ik') and therefore needs the membrane state (`Vm').

                Each SPIKE message to a synchan establishes a synaptic
                connection and increments `nsynapses'.  The synapses are
                numbered starting with 0, and each contains a field for a
                synaptic weight and a propagation delay.  For example, the
                weight of the first synaptic connection is held in the field
                `synapse[0].weight' while the delay is `synapse[0].delay'.
                `Gk' reaches a value (`gmax' * `weight') for a single event
                delivered with a SPIKE message.  Note that even though
                synapses are not elements, they do have fields that can be
                accessed individually.  They can be thought of as
                "sub-elements" or substructures of the element.  Note also
                that `gmax' is not the absolute maximum conductance of the
                synapse; it is just the maximum conductance given a single
                synaptic connection with a weight of 1.0 only.  Multiple
                synapses onto a particular synchan, weights higher than 1.0,
                and/or synaptic facilitation can all give rise to total
                conductances that are greater than `gmax'.

                Any number of spike events can be pending per synapse.  The
                `facsynchan' object stores all spike events in a buffer until
                they are scheduled to occur.  If enough events come in to
                overload the buffer, the buffer will dynamically expand to
                enable storage of all events.  The size of the buffer in
                events is stored in the `event_buffer_size' field which is
                readonly.  The number of actual spikes in the buffer which
                have not yet hit the channel are stored in the
                `pending_events' field (also readonly).  The
                `nodes_per_synapse' field controls how many large the event
                buffer is initially.  The default is to have one node per
                synapse, but if you expect a lot of events or very few events
                you can change this number to be greater or less than the
                default (1), respectively.  This will speed up the simulation
                slightly in the first case and save memory in the second.  If
                you leave this field alone the object will still work fine.
                The "resetsynchanbuffers" command will cause all the buffers
                in all synchan and derived objects to be reset to a size of
                `nodes_per_synapse' * `nsynapses' (which will also cause all
                pending events to be flushed).

                The "copy" command will fail for any synchan type which is
                receiving SPIKE messages.  The correct way to set up
                simulations is to set up prototype cells which do not receive
                any SPIKE messages on their synchans, copy these cells, and
                then add the appropriate SPIKE messages (by hand or by using
                planarconnect or volumeconnect).  We may eventually build a
                more intelligent copy command which will permit copying of
                synchans with SPIKE messages, but for now, don't do it.

                2) Specific information about implementing synaptic
                   facilitation and depression.

                Each synapse, in addition to its `weight' and `delay' fields,
                has two other fields called `fac' and `depr' which represent
                the current level of synaptic facilitation and depression,
                respectively.  Each time a spike hits, the facilitation and
                depression values are incremented by a fixed amount
                (`fac_per_spike' and `depr_per_spike', respectively) which can
                be zero but not negative.  The facilitation and depression
                values decay away with a time constant equal to `fac_tau' and
                `depr_tau', respectively.  The effective synaptic weight when
                a spike hits is calculated from these equations:

                    wt_multiplier = max((1 + fac) / (1 + depr), max_fac)
                    wt_effective  = wt * wt_multiplier

                Thus, a `fac' value of 1.0 and a `depr' value of 0.0 will give
                rise to a wt_multiplier value of 2.0 (assuming that `max_fac'
                > 2.0), so the effective weight at that point in time will be
                twice the listed synaptic weight.  The `max_fac' field allows
                you to limit the amount that a particular synaptic weight can
                grow; however, there is no limit to how low a weight can
                shrink due to depression.  If `max_fac' is negative, there is
                no maximum facilitation level.  This is the default (`max_fac'
                = -1, to be precise).

                You can switch facilitation/depression off by setting
                `fac_dep_on' to 0.  The default is 1 (facilitation on).

Example:        Scripts/examples/facsynchan/facdemo.g

Bugs:           The SAVE2/RESTORE2 actions have not been tested and may 
                contain bugs.  Please report any bugs you find.

Caveats:        The facsynchan object is not supported by the cell reader
                (readcell), so if it is to be used in a model described
                by a cell parameter (.p) file, you will need to use it in
                a prototype compartment that is included with the readcell
                "*compt" option.
See also: synchan , resetsynchanbuffers , Connections , NewSynapticObjects , readcell

26.26 fixbuffer

Object Type:    fixbuffer

Description:    Implementation of a first-order fixed (non-mobile) buffer.
                Should be coupled to a difshell or concpool, where the change
                in the concentration of the buffered ion is computed.

Author:         E. De Schutter BBF-UIA 8/94 - 9/95

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  fixbuffer_type [in src/concen/conc_struct.h]

Size:           124 bytes

Fields:         activation     ion concentration from incoming CONCEN message
                Bfree          free buffer concentration (calculated) in mM
                Bbound         bound buffer concentration (calculated) in mM
                prev_free      Bfree at previous time step
                prev_bound     Bbound at previous time step
                Btot           total buffer concentration in mM (free + bound)
                kBf            forward rate constant in 1/(mM*sec)
                kBb            backward rate constant in 1/sec

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       FixBuffer [in src/concen/fixbuffer.c]

Classes:        concbuffer segment

Actions:        RESTORE2  SAVE2  CHECK  RESET  PROCESS  INIT

Messages:       CONCEN  C   (buffered ion concentration, sent from a
                            difshell or concpool)

------------------------------------------------------------------------------

Notes:

The fixbuffer interacts with a difshell or concpool to model the binding of
calcium to buffer molecules and to calculate the concentrations of free and
bound buffer molecules using a kinetic scheme with forward and backward rate
constants for the binding and release of calcium:

    dBfree/dt = kBb*Bbound - kBf*Bfree*C
    Bbound = Btot - Bfree, where Btot == constant

The rate constants kBf and kBb are set by the user, and the concentration C is
sent with a CONCEN message from the difshell or concpool.  The BUFFER message
to a difshell or concpool from a buffer passes on the rate constants and the
calculated free and bound buffer concentrations.

For a general description of buffered calcium diffusion see:  De Schutter E.,
and Smolen P., "Calcium dynamics in large neuronal models", in Methods in
neuronal modeling: From ions to networks (2nd edition), C. Koch and I. Segev
editors, pp. 211-250 (1998).  The spinedemo simulation gives a detailed
example of the use of the difshell, taupump, and fixbuffer objects for
modeling calcium diffusion in dendritic spines.

Example:        create fixbuffer headbuf0
                setfield headbuf0 Btot 0.2 \ // Total buffer conc in mM
                                  kBf 5.0e5 \// Forward binding rate 1/(mM*sec)
                                  kBb 500    // Backward rate, 1/sec
                addmsg headbuf0 headshell0 BUFFER kBf kBb Bfree Bbound
                addmsg headshell0 headbuf0 CONCEN C
See also: difshell , taupump , Scripts/examples/spinedemo

26.27 freq_monitor

Object Type:    freq_monitor

Description:    Calculates running event (spike) frequency over a given time
                window using exponential weighting.

Author:         M. Wilson, Caltech (2/89), modified by D. Jaeger

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  freq_mon_type  [in src/device/dev_struct.h]

Size:           84 bytes

Fields:         tmin            minimum time interval which must be held by
                                  the buffer
                size            buffer size, in number of events
                current         current buffer location
                start           starting buffer location - 1
                end             last occupied buffer location
                event_size      size of each event data structure
                event           circular event buffer
                exponent        power by which to weight
                frequency       curent calculated value of the frequency
                                (set to zero on reset)

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       FrequencyMonitor  [in src/device/new_frequency.c]

Classes:        device

Actions:        PROCESS  RESET  CREATE

Messages:       NONZERO_TRIG    input   trigger on nonzero input
                ZERO_TRIG       input   trigger only when input is zero
                POSITIVE_TRIG   input   trigger on positive input
                NEGATIVE_TRIG   input   trigger on negtive input
                WINDOW          tmin    sets the window size tmin
                CONTINUOUS      input   triggers every time

------------------------------------------------------------------------------

Notes:          This is a frequency measuring device which computes the
                running event frequency over a time interval using exponential
                weighting.  The field "tmin" should be set in order to specify
                the interval or "window" for averaging.  Larger values give a
                smoother result.  If "exponent" is unequal to the default
                value of zero, inputs are weighted by exp(exponent*time).  The
                frequency field may be examined or sent to a graph.

                The first four messages are used to give it an input, and the
                counting of input events is triggered by one of the four
                conditions.  The most common way to use the frequency monitor
                is to set the "tmin" field to an appropriate timing window,
                send it a POSITIVE_TRIG message with the state of a spiking
                element, and send a "PLOT frequency" message from the monitor
                to a graph.

Example:        See the demonstration script Scripts/examples/spike/freqmon.g.

See also:       

26.28 funcgen

Object Type:    funcgen

Description:

This is a function generator which produces periodic output with a waveform
set by the mode field.

Author:         M. Wilson, Caltech (4/89)

------------------------------------------------------------------------------

ELEMENT PARAMETERS

DataStructure:  funcgen_type  [in src/device/dev_struct.h]

Size:           96 bytes

Fields:         mode            flag: 0=sine; 1=square; 2=triangle; 3=constant
                amplitude       peak-to-peak amplitude
                dc_offset       constant to be added to output
                phase           phase in degrees
                frequency       frequency
                output          output waveform

------------------------------------------------------------------------------

SIMULATION PARAMETERS

Function:       FunctionGenerator  [in src/device/funcgen.c]

Classes:        device

Actions:        CHECK  PROCESS  RESET

Messages:       AMPLITUDE amplitude
                DC_OFFSET dc_offset
                PHASE phase
                FREQUENCY frequency

------------------------------------------------------------------------------

Notes:

In a simulation, you would set up messages between the funcgen element
(in our example it is called "funky") and other elements which are to
receive its output.  For example:

  addmsg funky funcplot PLOT output *function *red  // funcplot is an xgraph
  addmsg funky Exc_channel ACTIVATION output  // Exc_channel is a synchan

Example: