|
"Retsim" is a set of scripts that construct a simple model of a retinal neuron and its presynaptic circuit. A light stimulus is transduced by an array of photoreceptors (rods and/or cones), and the resulting signals are synaptically transmitted to an array of bipolar cells, which in turn transmit their signals to one or more ganglion cells. The arrays of different neuron types are generated as semi-random arrays, given a cell density and a regularity (mean/s.d) or by array size or number. Synaptic contacts are automatically set based on a connection algorithm specified in a paramater table.
The main script is "retsim1.n" or "retsim.cc" which defines a set of parameters to control the construction of the stimulus, calls construction subroutines to make the different cell arrays, calls connection subroutines to connect the cell arrays, and defines a procedure to display the model, and run an experiment on it. The "makcel" script constructs the neurons, and the "synfuncs" script makes the connections.
Script Function retsim main script, oversees construction, connection, display, and run. retsim_var variable definitions, set pointers for command-line values. makcel makes arrays of neurons, either realistic or artificial. synfuncs connects arrays and individual neurons with synapses based on algorithm. celseg makes spheres and cables with biophysical properties. celfuncs functions to help make cells. stimfuncs stimulus functions. plot_funcs plotting functions. sb_makfuncs starburst cell make functions. sb_recfuncs starburst cell recording functions. setexpt sets dynamic loaded experiment files onplot_movie movie frame functions onplot_dsgc_movie DS ganglion cell movie functions (includes "onplot_movie") maknval script to create table of parameters "nval.n". expt_gc_cbp_flash experiment file: defines and sets parameters, sets up and runs experiment. nval.n parameter table runconf/dens.n channel density table (subdir runconf is configurable) runconf/chanparams channel param table (voffset, tau)
Retsim starts by constructing the largest and most downstream neuron. Typically this is a ganglion cell, but it can also be another neuron such as an amacrine cell (e.g. the starburst amacrine) or a bipolar or horizontal cell. The size of this cell determines how large the model and its arrays of presynaptic cells will be. Next, the presynaptic array is generated, given a cell density and regularity (mean/s.d.). Typically the regularity is set to 5-10, but very realistic arrays can be generated with regularities from 3 (almost random), to 50 (triangular/hexagonal array as in foveal cones). The extent of this array determines the size of the next higher presynaptic array (typically photoreceptors). The neuron types included in the simulation are defined by the user in the "experiment file".
If a smaller array is required, a large cell and array of presynaptic neurons can be trimmed using the "arrsiz" parameter, which sets the maximum size in microns for the array. Any neurons or parts of a neuron outside this limit are trimmed away before the simulation is run.
1) A cell can be digitized from a photograph or a confocal stack of images. The information is placed into a text file, organized by points, called "nodes", that describe the locations of soma, axon, and dendrites and their branch-points. Each node connects with a cable to its "parent" node, and this information is listed in the file, along with the cable diameter, (x,y,z) location, and the "region", used for supplying biophysical properties:
-----------------------start of morphology file---------------------
#
# beta cell anatomy file, 2006 Oct 4
#
# node parent dia xbio ybio zbio region dendr
#
0 0 21 0 0 -25 SOMA 0
1 0 2.17 21 -2.47 -8 DEND_PROX 1
2 1 0.833 22.8 0.0287 -5 DEND_DIST 1
3 2 1.33 23.3 0.776 0 DEND_DIST 1
4 0 0.5 13.9 -6.32 0 DEND_DIST 2
5 0 1.5 -3.25 -33.6 -30 HILLOCK 0
6 5 0.5 -6.81 -37.6 -30 AXON_THIN 0
7 6 0.5 -25.5 -66.4 -30 AXON_THIN 0
8 7 0.5 -121.2 -160.2 -30 AXON_PROX 0
The variables "SOMA", "DEND_PROX", "DEND_DIST", etc. are labels
for the region. These labels are variables that are defined in
retsim_var.cc. You may change the values of these variables, and
you may add your own additional ones in the morphology file. You
may also use another set of labels, "R1", "R2", "R3", etc. that
are predefined in retsim_var.cc. These regions are for use in
the "dens_xxx.n" file (see below), where each column defines the
density of channels and other values such as Rm, Ri, complam, and
color for that cell region.The "dendr" column defines dendrite numbers to be utilized for selectively constructing dendrites. If any of the command-line variables "sbac_dend1,sbac_dend2 ... sbac_dend5" are set, the dendrites with these numbers will be constructed from the morphology file, and other dendrites will not be constructed. If in addition the "sbac_dend_cplam" variable is set, the other dendrites (not set in sbac_dend1-5) that would have not been constructed are now constructed with compartment size set by sbac_dend_cplam. This arrangement is useful for constructing a model with just one or a few dendrites included with small compartments for high resolution, and all the other with large compartments, to minimize the number of total compartments. Other variables gc_dend1-5 and aii_dend1-5 are also defined for use with these cell types.
There are several methods available for digitizing neural morphologies:
To set the node number and font display for a cell type, set the variable "cell_nscale" (cell = cell name) with the display number as described above. You can set this variable on the command line, or in the experiment file in the "setparams()" procedure. To set the node displays for all the cell types, use the variable "node_scale". If set, the "cell_nscale" variable overrides the "node_scale" variable.
retsim --expt gc_cbp_flash --node_scale -2.1 -d 9 -v | vid retsim --expt gc_cbp_flash --node_scale -2.1 --gcb_nscale -3.05 -d 9 -v | vid
"maknval.n > nval.n".To add new parameters to nval.n, you can edit "maknval.cc", compile it with "make maknval", and run "maknval > nval.n" as shown above, then copy nval.n to "nval.h":
cp nval.n nval.hThen remove the numerical parameter definitions from the end of nval.n using an editor such as vi or kwrite. Next, remove the nval.n table at the beginning of nval.h. Next, copy nval.h to "nval_var.h", "nval_var.cc", and "nval_var_set.cc" and edit these files to leave only their correct contents, shown in comments in the file. Then remove this content from nval.h. Last, "make clean" and "make retsim". This description is included in the beginning of "nval.n".
You can simplify the nval.n file to remove the columns and rows that are not required for your experiment. This does not require any changes to nval.h, nval_var.h, nval_var.cc, or nval_var_set.cc. The rows and columns can be in any order (except for the first row and the last column, which contain the labels). This works because the rows and colums are described by labels, and when retsim reads in the nval.n file, the data from the file is placed in the correct row and column by referring to the labels.
The first block of the nval.n parameters describes how a neuron is to be constructed, some of its biophysical parameters, and also the density and maximum number of cells in an array. The second block, starting with CELPRE1, sets the input synaptic connections for a neuron. The third, fourth, and all the other blocks of parameters starting with CELPOST(1,2,3...) define the output synaptic connections. Note that the default values are set by the "maknval.cc" (maknval.n) file that generates the nval.n file.
First block of parameters in nval.n, for constructing cells:
_MAKE # whether to make this cell type _MAKE_DEND # whether to make dendrites _MAKE_AXON # whether to make axon _MAKE_DIST # whether to make axon distal _NMADE # number of cells made _MAXNUM # maximum number of cells of this type _NCOLOR # color of this cell type for display _MAXCOV # max coverage factor (for arrays) _MAXSYNI # max number of syn input cells per celltype _MAXSYNO # max number of syn output cells per celltyp _DENS # density of this type (per mm2) _REGU # regularity (mean/stdev) of spacing _MORPH # morphology (=0 -> file, or >0 -> artificial) _COMPLAM # compartment size (default=complam) _BIOPHYS # add biophys properties (use channel density file dens_xxx.n) _CHNOISE # add membrane channel noise properties _RATIOK # set K density values as ratio from Na _VSTART # initial resting potential, when BIOPHYS==0 _VREV # membrane potential for Rm (VCl), when BIOPHYS==0 _NRM # the cell's Rm when BIOPHYS==0 _SOMADIA # Soma diameter for artificial morphology _SOMAZ # Z location (x,y loc determined by array) _DENDARB # type of dendritic tree, non-branched, branched, etc (retsim.h). _DENDARBZ # dendritic arborization level for artificial morphology (synfuncs.cc) _DENZDIST # dendritic arborization z tolerance for synaptic input. (synfuncs.cc) _STRATDIA # stratif. annulus dia (fract of treedia) for artificial morphology. (synfuncs.cc) _DTIPDIA # diameter of dendritic tips for artificial morphology (makcel.cc,synfuncs.cc) _DTREEDIA # diameter of dendritic tree (for artificial and real morphology, allows synaptic connection). _AXARBT # type of axonal tree _AXARBZ # axonal arborization level for artificial morphology _AXTIPDIA # diameter of axonal tips for artificial morphology _AXARBDIA # diameter of axonal arbor (for synaptic connections, synfuncs.cc) _MAXSDIST # maximum synaptic distance (for synaptic connections, synfuncs.cc) _TAPERSPC # space constant of diameter taper for artificial morphology. _TAPERABS # abs diameter for taper for artificial morphology. _NDENDR # number of first-order dendrites for artificial morphology. _GROWTHR # distance thresh for growth of dendrites for artificial morphology.Second block of parameters in nval.n, describing synaptic inputs to a cell type. Each of these ends in a number which is the "synaptic input number" for a cell type. There are 8 possible inputs.
_CELPRE1 # cell type to connect to (negative -> no connection) _CONPRE1 # connection number of presyn cell _CELCONV1 # number of presyn cells to connect to _GROWPOST1 # grow when making conn from presyn cellBlocks for synaptic output parameters, note that each block ends with the same number which is the "synaptic output number". There are a maximum of 7 possible outputs:
_CELPOST1 # cell type to connect to (negative, no connection) _CONPOST1 # connection number for postsyn cell (its synaptic input number from above) _CELDIV1 # number of postsyn cells to connect to (maximum) _GROWPRE1 # grow when making conn to postsyn cell _SYNSPAC1 # synaptic spacing in dendritic tree (if positive, this enables many synaptic outputs per cell) _SYNANN1 # inner dia of annulus in dendritic tree (allows synapses outside this radius) _SYNANG1 # angle for postsynaptic cell (sets allowable angle in degrees) _SYNRNG1 # range of angles for postsynaptic cell (if positive, sets allowable range, if neg, set angle from somas) _USEDYAD1 # synapse is dyad using preexisting type _DYADTYP1 # type of dyad synapse to connect with(sets which type of presynaptic cell for dyad 1->2 cells ) _AUTAPSE1 # synapse back to presynaptic node (allows cell to connect to itself) _SYNNUM1 # number of synapses per connection (sets more than 1 synapse per connection, typical for bipolar cells) _SENSCA1 # synaptic release sensitivity calcium (use [Ca]i for driving release instead of expon function) _SRRPOOL1 # synaptic readily releasable pool (sets size of pool) _SMAXRATE1 # maximum synaptic release rate (sets maximum release rate) _SGAIN1 # synaptic gain (sets exponential gain, mV/efold increase, when not using [Ca] sensitivity) _SVGAIN1 # synaptic vgain (sets additional linear gain factor) _SDURH1 # synaptic high pass time const. (sets high pass filter for release) _SNFILTH1 # synaptic high pass nfilt (sets number of high-pass filters for release) _SHGAIN1 # synaptic high pass gain (sets high pass filter gain relative to unfiltered release) _SHOFFS1 # synaptic high pass offset (sets offset in mV for high pass func for release) _SVSIZ1 # synaptic vesicle size (sets vesicle size without changing overall release, i.e. changes release rate) _SCOND1 # synaptic conductance (maximum conductance when potsynaptic receptor is saturated) _STHRESH1 # synaptic threshold (threshold for exponential release in mV). _SVNOISE1 # 1->allow vesicle noise, override, vnoise=0 _SCOV1 # 1=Poisson, <1->more regular, gamma dist (sets properties of noise distribution for release) _SDUR1 # synaptic event time const. (sets time constant for lowpass filter of vesicle release: mini shape) _SFALL1 # synaptic event fall time const. (sets separate first order fall time for mini PSPs) _SNFILT1 # synaptic vesicle nfilt (sets number of lowpass filters for mini waveshape) _STRCONC1 # synaptic transmitter concentration. (multiplier for neurotrans conc with ligand-gated channel) _SRESP1 # synaptic response (ampa,gaba,gj,etc). (sets which Markov state diagram to use) _SCNFILT1 # second mesng. nfilt (number of lowp filters in postsynaptic cascade) _SCDUR1 # second mesng. time const.(time const of filter in postsynaptic cascade) _SCGAIN1 # synaptic second messenger gain (gain of second messenger) _SCOFF1 # synaptic second messenger offset (offset of second messenger) _SCNOISE1 # 1->allow channel noise, override, cnoise=0 (sets noise of postsynaptic channel) _SNCHAN1 # number of channels (sets number of postsyn channels) _SUNIT1 # synaptic channel unitary conductace (sets conductance of unitary channel) _SVREV1 # synaptic reversal potential (usually either 0 for excitatoryh, or -0.065 for inhibitory)
Note that when the "biophys" parameter in the nval.n file is set to 0, then retsim does not read the dens_xxx.n file, and takes the "vstart", "vrev", "Rm", and "Cm" parameters from nval.n instead of a density file.
You can customize the density file using variables instead of numbers in the columns, for example, in the listing below, "drm" means use the default value of Rm preset by retsim. When retsim reads the numbers from the density file, it looks up any variables in the symbol table and replaces the variable with its numeric value. This means that you can use any variable, either predefined internally in the simulator (in retsim_var.cc), or defined in your experiment file, as long as the variable's value is defined before the density file is read. You can define the variable in the "defparams()" procedure, and you can set its value in the "setparams()" procedure or in the command line. The density file is read after this.
A typical dens.n file for retsim is:
# Default membrane properties (density) file # # Densities of currents for the cell's different regions (S/cm2). # # DEND_DIST DEND_PROX SOMA HILLOCK AXON_THIN AXON AXON_DIST VARICOS R9 R10 # 0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 # _NA 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 50e-3 0e-3 0e-3 0e-3 # Na2 _NA5 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # Na5 _NA6 35e-3 0e-3 0e-3 4e-3 4e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # Na6 _NA8 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # Na8 _KDR 15e-3 0e-3 0e-3 15e-3 15e-3 20e-3 10e-3 0e-3 0e-3 0e-3 # K1 _KA 35e-3 0e-3 0e-3 35e-3 35e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # K3 _KH 0e-3 0e-3 0e-3 0.09e-3 0e-3 0.8e-3 0e-3 0e-3 0e-3 0e-3 # K4 _SKCA1 0.12e-3 0e-3 0e-3 0.12e-3 0.00e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # KCA4 _SKCA2 0.01e-3 0e-3 0e-3 0.04e-3 0.02e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # KCA5 _BKCA 0e-3 0e-6 0e-3 0e-3 0e-6 0e-6 0e-6 0e-6 0e-3 0e-3 # KCA3 _CA_L 0.014e-3 0e-3 0e-3 0.014e-3 0.014e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # Ca1 _CA_T 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 0e-3 # Ca5 _CAP 2e-7 0e-3 0e-3 1e-7 1e-7 0e-12 0e-3 0e-3 0e-3 0e-3 # CAPUMP _CAE 0e-7 0e-3 0e-3 0e-7 0e-7 0e-12 0e-3 0e-3 0e-3 0e-3 # Caexch _VST dvs dvs dvs dvs dvs dvs dvs dvs dvs dvs # vstart _VRV vk vk vk vk vk vk vk vk vk vk # vrev _RM drm drm drm drm drm drm drm drm drm drm # Rm _CM dcm dcm dcm dcm dcm dcm dcm dcm dcm dcm # Cm _CPL cplam cplam cplam cplam cplam cplam cplam cplam cplam cplam # cplam _COL green blue red blue blue magenta yellow gray ltred brown # color
The "density file" (retsim/runconf/dens_xxx.n) defines the biophysical properties of a cell, region by region. Each column defines the biophysical properties of one region. The first (left) column of the density file is the name of the biophysical parameter, such as NA, KDR, or RM. These labels are the names of variables that have been set by default to have a value to index into the internal list of channel types. Some of the names, for instance, NA, KDR, KA, SKCA1, are aliases for other internal variables that contain the correct index number. The alternative internal values are in the last column, the comments to the right of the "#". The other columns (2-11) of the density file define conductance density values for each membrane channel type to be inserted into the cables and spheres of the model in the appropriate region.
The rows and columns of the density file can be in any order, and unused rows or columns can be deleted, because each column and row is indexed by the label at the top or left column, respectively. Any rows or columns undefined in the density file are set to zero.
You can tell the simulator to temporarily remove a row, for example, to remove a channel type from all regions in the cell, by redefining the variable to a value outside the allowable range of values. Or you can temporarily remove a region by redefining the variable to a value outside the number of regions. For example:
retsim --expt cell_vclamp --celltype dbp1 --dbp1_densfile dens_dbp1.n --KDR 99 or, retsim --expt cell_vclamp --celltype dbp1 --dbp1_densfile dens_dbp1.n --R4 99The first example runs expt_cell_vclamp.cc with the density file dens_dbp1.n file, except with the density of KDR set to 0 everywhere in the cell. The second example runs expt_cell_vclamp.cc with values in region R4 set to zero. Some of the rows, the values that are not conductances (RM, RI, VST, VRV, CPL, COL) are set to non-zero default values when the indexes are set out of range in this way. In "celseg.cc" look for zerodens (default densities).
Temperature dependence
The channel conductances vary with temperature, but are defined by convention in the dens_xxx.n file at 22 deg C. you must be careful to define them correctly for the temperature at which you are running the model ("tempcel"). At run-time (see "celseg.cc"), the conductance densities specified in the dens_xxx.n file are converted to number densities (n/um2) by dividing by the channel's unitary conductance (dxxxu). If channel noise is set, this number density affects the amount of noise generated by the channels. If you set the unitary conductance to 1e-8, then the conductance density specified in the dens_xxx.n file (S/cm2) directly defines the channel number density (n/um2). The unitary contuctance is modulated by temperature (controlled by a Q10 "dqxxx" value, see "Channel statement" in ncman2.html), but its value is specified at 22deg C.
An entry in "chanparams" for the Na 1.2 channel type:
columns: gca gcb gcaoff gcboff sb dsgc aii #Na 1.2 channel parameters Na2.offm: 0.001 0.001 0.001 0.001 0.005 0.0025 0.002 Na2.offh: 0.001 0.001 0.001 0.001 0.005 0.0025 0.002 Na2.taua: 1 1 1 1 1 1 24 Na2.taub: 1 1 1 1 1 1 24 Na2.tauc: 1 1 1 1 1 1 24 Na2.taud: 1 1 1 1 1 1 24
After the presynaptic arrays of neurons are generated, they are synaptically connected with an algorithm that for each presynaptic neuron connects it to a nearby postsynaptic neuron(s), and extends the presynaptic axon or the postsynaptic dendritic tree, if appropriate, to create a realistic anatomy. Realistic numbers of connections are generated, so that a postsynaptic neuron can receive synaptic connections from several presynaptic neurons, with multiple contacts if appropriate, and a presynaptic neuron can connect to several postsynaptic neurons if appropriate. For example, a bipolar cell receives synaptic contacts from several photoreceptors, but the nearest ones are most likely to make contacts.
One connection algorithm available in retsim calculates a Gaussian probability for making connections, so that each connection is made at random, yet the closest presynaptic neurons are more likely to connect. This allows two random arrays of neurons to be connected with Gaussian weighting functions relatively smoothly. The exact number of connections between a presynaptic and a postsynaptic cell can vary, but the average is closely controlled.
The type of connection algorithm used is specified by the type of presynaptic arbor and the the type of postsynaptic arbor. These properties are specified in the nval.n file as DENDARB and AXARBT. A value of 0 means non-branched, 1 means branched, and 2 means highly branched. When connecting a synapse to an unbranched postsynaptic dendritic tree, the postsynaptic tree is extended to generate more branches from the soma if the GROWPOST parameter for that synapse is set. A branched postsynaptic cell will extend new branches from its proximal dendrites. A highly branched postsynaptic cell will not grow branches but will allow synaptic contacts to be made if the presynaptic cell is within a criterion distance (MAXSDIST).
After the neural arrays are generated and interconnected according to a connection algorithm, the neurons that didn't get connected are removed. This is necessary because the presynaptic circuit of a ganglion cell only extends typically 20-50 um beyond the ganglion cell's dendritic tips, yet precisely which presynaptic neurons are connected depends on the connection algorithm, as well as the original placement of the neurons in the presynaptic arrays.
During the synaptic connection procedure, for each neuron the numbers of presynaptic and postsynaptic neurons it connects to are totaled and saved in a table. Any neurons that don't connect to a postsynaptic cell are removed. The process is started by first checking the layer immediately presynaptic to the ganglion cell, i.e. the bipolar cells, and afterwards checking the more distal neurons, i.e. the photoreceptors.
To see all the neurons, even those that didn't get connected, you can set the parameter "remove_nconns" to 0, either on the command line or in the setparams() procedure.
Stimuli can include voltage clamp, current clamp, and a variety of light stimuli such as spots, bars, sine wave gratings, etc. A special transduction element is available that voltage clamps the cell to which it is attached at a voltage specified by the stimulus intensity. When the stimulus procedure is called, the stimulus is added to a list that is run at the correct time during the simulation (i.e. during the "step()" procedure). To generate complex stimuli, for example a bar moving to/fro, a set of stimulus functions is available in "stimfuncs".
A variety of recording methods are available. An experiment can define a list of nodes to record from, either current or voltage. Light flux into a photoreceptor can be recorded, as well as the concentration of calcium or a neurotransmitter or second messenger. The recorded values can be stored into an array or file or plotted onto the video screen.
Several plotting functions are available to generate plots. Plots can include several traces, e.g. several recording points, and several of these plots can be displayed simultaneously on the screen. Each trace can have its own color and a label and units. Plotting functions are available for "voltage at a node", "synaptic release rate", or for displaying the voltage or some other parameter of a neuron as a color applied to the display of morphology.
An "onplot" procedure can be defined which runs automatically at plot time, i.e. when the plot traces are updated, controlled by the "ploti" variable. Although this procedure is not necessary (because the simulation can be run incrementally), it allows the simulation to run faster. For example, the onplot procedure allows a special procedure to compute some function of the neural circuit's responses. It also can be used to plot more complex functions, such as the color-coded voltage superimposed on the morphology. For the compiled version, the onplot procedure is defined by the "setonplot()" procedure.
To make a movie, include "onplot_movie" in your experiment file, and call it at plot time, i.e. inside the "onplot()" procedure. At each plot step, it displays the voltage (or other parameter such as inactivation) of the membrane as a color code superimposed on the morphology.
You can look at the movie using the "vid" display, or you can generate separate frames using the "-P name" command line switch. This creates an individual PostScript file for each frame, which you can convert to another appropriate file format. Typically you will need to convert all the frames to a ppm format, then use "mpeg_encode" to create a movie.
You create the movie with a shell script like this:
#! /bin/tcsh -f # # make_movie script # ps2ppm100 $argv*.ps movconvert -f "$argv"_ -n 2000 cp xxx_paramfile2 "$argv"_paramfile2 replace xxx "$argv" "$argv"_paramfile2 mpeg_encode "$argv"_paramfile2 rm "$argv"*.ppm
Since the vid display integrates the graphics input from the simulator, the frames it generates after the first do not contain static objects (calibration bars, etc) that should remain throughout the movie. The "movconvert" program accomplishes this integration in the movie for the frames in .ppm format. These are then read and converted to a standard movie format by "mpeg_encode". To view the movie in you can use "mplayer".
|
The NeuronC API is defined in "nc/src/ncfuncs.h" and described in the NeuronC User's Manual. Each function call in "ncfuncs.h" replaces a statement in the interpreted version of NeuronC. The retsim script defines an array of neurons and connects them using these function calls. To see an example of source code for this compiled version, see the "retsim.cc" model in nc/models/retsim". The command-line switches for "retsim" are identical to those listed by "nc -h", but note that running "retsim" without arguments displays a list of simulation experiments and parameters. In addition simulation variables can be set from the command line.
The NeuronC API is incorporated into a static library called "libnc.a". This file is created in "nc/src" and must be linked with a neural circuit program such as "nc/models/retsim/retsim.cc". To link this library correctly you may need to set the "NC_HOME" variable in nc/models/retsim/makefile, either by setting it as an environment variable or by changing the makefile. The libnc.a library is created as a static library because as a dynamic library it reduces run-time speed.
The experiments defined for "nc/models/retsim" such as "expt_gc_cbp_flash.cc" are compiled to be dynamically linked to the "retsim" program at runtime, i.e. each experiment is compiled into a dynamic library, e.g. "expt_gc_cbp_flash.so". To allow this process of dynamic runtime linking, you must set the environment variable LD_LIBRARY_PATH or include the directory where the experiment ".so" file is located in (for Linux) "/etc/ld.so.conf". That will allow the runtime linker to find "expt_gc_cbp_flash.so"
(tcsh) setenv LD_LIBRARY_PATH . (bash) export LD_LIBRARY_PATH="."
Another way to direct the dynamic linking process is to make a symbolic link from a file in /usr/local/lib to the experiment .so file in nc/models/retsim. The dynamic linker will identify the file because it starts with "lib_": ln -s /usr/local/lib/lib_expt_gc_cbp_flash.so expt_gc_cbp_flash.so
At the top of the "retsim.cc" script, there are several files included:
#include "ncio.h" // defines "ncfprintf()" for I/O to a C++ stream #include "ncfuncs.h" // defines the C++ functions for the simulator #include "retcolors.h" // defines the standard colors 0-15 #include "retsim.h" // defines constants and functions for retsim.cc #include "retsim_var.cc" // defines parameters and "setptrs()" which initializes them #include "ncinit.h" // defines a null "setptrs()" in case it is not already defined #include "setexpt.h" // defines "defparams()", "setparams()", "setdens()" and "runexpt()" for the experiment fileMost of these header files are in the retsim directory, but some are in the nc/src directory. If you are compiling retsim in a different location than nc/models/retsim, you need to set the NC_HOME environment variable in "retsim/makefile":
# NC_HOME = ~/nc
# OSFLAGS = -DMACOSXThen enter "make" on the command line. This will compile and link all the source code correctly on the Mac.
The retsim script is controlled by a set of variables that tell it which neurons to create and how to connect them. The variables are read from the default neuron parameter table, "nval.n", but are also set by an "experiment file", and from the command line.
Typically an experiment file defines the general form of the experiment. It directs retsim which cells to include in the model, what synaptic connections and biophysical properties they should have. Then the retsim script constructs the neural circuit model, and returns control back to the experiment file, which runs the experiment. The retsim script, either the interpreted ("retsim1.n") or compiled ("retsim.cc") version, is designed to be run with many different experiments. It is typically run with several script files which define the details of how to construct all the neurons and how to connect them. Many experiment files can be created to define different circuits or different experiment protocols.
Usually the experiment file allows parameters to change the details, i.e. the exact details of the neurons or their spacing, the size, frequency, or timing of a stimulus, or the exact form of the output plots. The idea is to minimize the number of different experiment files by selecting appropriate parameters to control their behavior.
An interpreted experiment file is written in the nc script language, and should contain the "setparams()" procedure, (and optionally the "setdens()" procedure), and "runexpt()" procedure, as explained below. The setparams() procedure sets the values of parameters, for example to control how the circuit is constructed. The "runexpt()" procedure sets up stimuli and plots, and runs the experiment using a "step" or "run" statement. A good way to start would be to take an existing experiment, e.g. "expt_gc_cbp_flash.n", and modify it to make a different circuit and/or experiment.
A compiled experiment file is written as a standard .cc file, then compiled and linked as a dynamically-linked library (in linux, ".so"). This allows the retsim script to select an experiment file at runtime instead of requiring that retsim be linked separately with each experiment file. A good way to accomplish this is to look in the "makefile" and modify an existing entry for compiling and linking an experment file.
The experiment file typically contains 3 procedures which are automatically run by the "retsim" script (see "setexpt.cc"):
defparams() Defines the experiment and its parameters for command line.
This is called before the nval.n parameter file is read,
so you can set a different nval file name here, or on
the command line. Also called before the "setvar()"
procedure sets variables from the command line.
setparams() Sets variables controlling construction of the circuit
after the neuron parameter (nval) file has been read.
Called after defparams(), but before the density files
are read, and before construction of the neural circuit.
setdens() Sets neuron parameters and variables modifying the
channel densities after they have been read from the
density files. Optional, called after densities have been
read in, but before construction.
runexpt() Runs the experiment. Fine tunes neurons, sets stimuli and plots.
Called after circuit is constructed.
The "runexpt()" procedure can include a "for" statement to run an
experiment iteratively. Typically, a stimulus is generated, and the
"step()" procedure is called to run the simulation forward in time. Then
the loop runs the stimulus again, possibly with a small variation, e.g. a
different clamp voltage for a voltage clamp, and the step procedure is run
again.
// The defparams procedure defines parameters needed by the experiment.
// It is run before "setvar()" (which defines the parameters from the command line).
void defparams(void)
{
setptr("temp_freq", &temp_freq);
setptr("ntrials", &ntrials);
setptr("dstim", &dstim);
setptr("sdia", &sdia);
setptr("stimtime", &stimtime);
setptr("minten", &minten);
setptr("scontrast", &scontrast);
}
// The setparams procedure sets parameters needed for construction of the circuit.
void setparams(void)
{
make_rods = 0;
make_cones= 1; /* make cones, cbp, gc */
make_ha = 0;
make_hb = 0;
make_cbp = 1;
make_gc = 1;
if (notinit(bg_inten)) bg_inten = 2.0e4; /* background light intensity */
}
// The setdens procedure allows the user to modify channel densities read from the
// density files.
void setdens(void)
{
if (!notinit(cone_cond)) setval(xcone,SCOND5,cone_cond); // override synaptic val
if (!notinit(ca_cond)) celdens[cone][_CA][R_AXON] bg_inten = ca_cond; // override Ca density, S/m2
}
// The runexpt() procedure sets up the experiment stimuli and plots, and
// runs the experiment using "step()" or "run()".
void runexpt(void)
{
double temp_freq;
if (notinit(stimtime)) stimtime = .10; /* stimulus time */
if (notinit(minten)) minten = bg_inten; /* background intensity (for make cone)*/
if (notinit(scontrast)) scontrast = .5; /* intensity increment */
if (notinit(temp_freq)) temp_freq = 2;
dtrial = 1 / temp_freq;
exptdur = dtrial * ntrials;
plot_v_nod(ct=xcone,cn=midcone,n=soma,Vmin=-.037,Vmax =-.027,colr=cyan,"", -1, -1); /* plot Vcones*/
stim_spot(sdia, 0, 0, minten*scontrast, start=t+stimtime,dur=dstim);
step(dtrial);
}
Examples of how to run retsim
nc --expt gc_cbp_flash --ninfo 2 -d 1 -v retsim1.n | vid display the model
retsim --expt gc_cbp_flash --ninfo 2 -d 1 -v | vid
nc --expt gc_cbp_flash --ninfo 2 -d 9 -v retsim1.n | vid display the nodes
retsim --expt gc_cbp_flash --ninfo 2 --node_scale -3.05 -d 9 -v | vid
retsim --expt gc_cbp_flash --ninfo 2 -d 9 -v | vid -c > file.ps make .ps file.
nc --expt gc_cbp_flash -d 1 -R retsim1.n > file.pov display into povray format
retsim --expt gc_cbp_flash -d 1 -R > file.pov
povray +h1000 +w1000 +ifile.pov +dx generate image with povray
nc --expt gc_cbp_flash --mxrot 90 -d 1 -v retsim1.n | vid rotate, display the model
retsim --expt gc_cbp_flash --mxrot 90 -d 1 -v | vid
nc --expt gc_cbp_flash --ninfo 2 --arrsiz 100 -d 1 -v retsim1.n | vid limit model to 100 um
retsim --expt gc_cbp_flash --ninfo 2 --arrsiz 100 -d 1 -v | vid
nc --expt gc_cbp_flash --ninfo 2 --n_cbp 1 --n_gc 0 -d 1 -v retsim1.n | vid limit model to 1 bipolar
retsim --expt gc_cbp_flash --ninfo 2 --n_cbp 1 --n_gc 0 -d 1 -v | vid
nc --expt gc_cbp_flash --ninfo 2 -v retsim1.n | vid run model, display plots
retsim --expt gc_cbp_flash --ninfo 2 -v | vid
nc --expt gc_cbp_flash retsim1.n > file.r run model into data file
retsim --expt gc_cbp_flash > file.r
plotmod file.r | vid display plots from data file