Tutorial #7 ------------------------------------------------------------------------------- Building a Network of Interconnected Neurons ------------------------------------------------------------------------------- GENESIS has a number of built-in commands for creating, connecting and displaying networks of interconnected neurons. Although the demonstration "orient_tut" in the ../Scripts directory provides illustrations of the use of these commands in an elaborate simulations, the purpose of this tutorial is to guide the student through the basic steps of building a network simulation from scratch. More detailed descriptions of the commands for building networks is provided in Chapter 17 of the Book of GENESIS (BoG) and in the GENESIS reference manual. The goal of this tutorial is to set up a two-dimensional array of model neurons with local excitatory and long-range inhibitory connections. This is easily accomplished using GENESIS by creating prototype elements with cell bodies, ion channels, and spike-generating elements which are duplicated, assigned positions in a two-dimensional grid, and graphically displayed. The network will consist (at first) of electrophysiologically identical cells in a two-dimensional array. Each cell will be reproduced from a /library template cell which is based on the two-compartment model constructed in Tutorial 5. Input to the network will be provided by injecting pulses of current into selected cells or by using an array of randomspike objects like those used in Tutorials 4 and 5 to provide random synaptic inputs to all the cells. Although the reader can successfully run the tutorial7 simulation by changing directories to the "official" .../Scripts/tutorials/tutorial7 directory and typing "genesis tutorial7", the purpose of this exercise to to guide the reader through the process of writing the various script files for the network simulation, tutorial7.g, net_cell.p, net_cells.g, net_out.g, net_conn.g, and net_inputs.g on their own. -------------------------------------------------------------------------------- Step 1: Creating Prototype Elements for the Cells in the Network (tutorial7.g) -------------------------------------------------------------------------------- The first step in any network simulation is to write a GENESIS script creating prototypes of the basic components of the model cell, the soma compartment, the Hodgkin-Huxley channels, the synaptic channels, and the spike detector, which can be simply copied over and over again for each cell in the network. Although the reader could always create their own prototype scripts from scratch by modifying the scripts from previous tutorials, here we will simply reuse the cell.p, protodefs.g, compartments.g, hhchan.g, synchans.g, and protospike.g files from tutorial5. At this point the reader should create a separate directory for the the script files used in this tutorial using the unix command: mkdir network and then copy the cell.p, protodefs.g, compartments.g, hhchan.g, synchans.g, and protospike.g files from the tutorial5 directory (.../Scripts/tutorials). Now cd to this network directory and we'll start to put a network simulation together. First, we need a master simulation script to provide GENESIS with all of these prototype script files. So begin writing a new tutorial7.g script with the lines: //genesis include protodefs.g and end the file with: check reset (the reset command at the end of the file is particularly important to make sure that GENESIS initializes the full simulation properly). -------------------------------------------------------------------------------- Step 2: Making Multiple Copies of Model Neurons for the Network and Assigning Spatial Locations to the Network Cells (net_cell.p and net_cells.g) -------------------------------------------------------------------------------- Before building and replicating cells for the network, we will modify the tutorial5 cell.p file to allow for both excitatory and inhibitory synapses. So rename the tutorial5 cell.p file to net_cell.p and simply modify the last line for prescribing the synapses in the dendritic compartment to read: dend soma 100 0 0 2 Ex_channel 1.0 Inh_channel 1.0 In addition, we have to remember to make_Inh_channel in protodefs.g, so be sure to add: make_Inh_channel after the "make_Ex_channel" command at the end of the protodefs.g scripts Now, using the readcell utility we can create a multicompartment /library/cell with all of the appropriate messages between compartments, channels, and spike generator using the single command in a new net_cells.g script: //genesis readcell net_cell.p /library/cell Once the model cell is constructed from the /library/.. prototype elements, multiple copies can be easily created and assigned spatial locations in a retangular grid by using the createmap command in the net_cells.g script. First create a neutral object for the network in net_cells.g: create neutral /network And then copy the /library/cell model neurons and all of their associated elements (compartments, channels, and spike generators) to their assigned locations in a rectangular array with the single command: createmap /library/cell /network 8 8 -delta 0.1 0.1 -origin 0.15 0.15 This command will generate an 8 by 8 array of 64 model neurons (/network/cell[0] to /network/cell[63]) in a rectangular grid with equal spacings in x and y of 0.1 (in arbitrary units with the lower left hand corner (xmin and ymin) located at (0.15,0.15) in the x y plane. Although the spatial locations are in arbitrary units, these coordinates are very useful both for graphical display of the network neurons and for calculating spatially dependent synaptic connection strengths and delays. At this point the reader should add the line: include net_cells.g to the master tutorial7.g script and execute the network simulation by typing: genesis tutorial7 Now the reader should check that 64 /network/cell elements are created and assigned values for their x y fields. For example, you can try to determine the spatial location for the /network/cell[10]/soma and its dendrite. (eg. type showfield /network/cell[10]/soma x y) -------------------------------------------------------------------------------- Step 3: Graphical Display of the Network (net_out.g) -------------------------------------------------------------------------------- The two-dimensional network can be conveniently displayed as a two-dimensional array of colored squares on the screen. The color of each of the squares can be be varied to represent the time-dependent magnitude of any cellular variable in the simulation (like the membrane potential - Vm) to provide a dramatic two-dimensional display of the time-dependent behavior of the network. GENESIS has a built-in XODUS object to display the temporal and spatial behavior of the network called "xview". To utilize this command the reader should start a new GENESIS script called net_out.g to keep all the output commands for the simulation in a single script. The net_out.g script should begin with commands to create and display an "xform" window on the screen called /xout with specified location and dimensions, along with a label "Network": //genesis create xform /xout [700,0,450,450] xshow /xout create xlabel /xout/"Network" [5%,5%,90%,30] Then a plot for displaying the squares representing the cells is generated by creating an "xdraw" element (analogous to the xgraph elements used for displaying graphs) with a specified display size and location within the xform /xout representing a specified spatial width and height ("wx" and "wy"). For displaying the 8 by 8 square of neurons created in Step 2, a plot with width 1.0 and height 1.0 should be sufficiently large to display all of the squares in /xout/drawsquare: create xdraw /xout/drawsquare [5%,15%,90%,80%] setfield ^ wx 1.0 wy 1.0 Finally, to generate a colorful spatial display of the network activity, the xview element is created to translate messages from the cellular elements to the color coded squares. For example, the 8 by 8 square array of neurons can be easily displayed using the default icon (a solid-square) to display the soma Vm: create xview /xout/drawsquare/cells [5%,15%.90%,80%] setfield ^ path /network/cell[]/soma \ field Vm \ autoscale 0 \ value_min[0] -0.1 \ value_max[0] 0.05 \ viewmode colorview \ sizescale 0.07 where the "path" indicates the source of the "field" that is color-coded by the squares for values of Vm between -0.1 and 0.05. Finally, to display this beautiful array don't forget to type: xshow /xout At this point the reader should add these commands to the net_out.g script, add the line "include net_out.g" to the master tutorial7.g script. In addition, it is very inportant to add the command xcolorscale hot to the tutorial7.g script after the "include net_out.g" command to set the colorscale properly. Then execute "genesis tutorial7" to verify that the array of colored neurons are correctly displayed. Finally, since we will be using several displays for different layers in the network model, the reader should try to write a function make_xview to generate each display along the lines indicated at the beginning of the "official" net_out.g script in the /Scripts/tutorials/tutorial7. Then we can construct the previous planar display with the single command: make_xview /network/cell[]/soma Vm \ /xout "Network" \ 700 0 \ -0.100 0.050 ------------------------------------------------------------------------------- Step 4: Running a Simulation ------------------------------------------------------------------------------- Although there are still no connections between the network neurons (see Step 5), the impatient reader can test the simulation by injecting current into one of the neurons and watching it change color on the screen. To run this test simulation some simulation parameters must be set in the master tutorial7.g script by adding the following commands (before "check" and "reset" commands) in the tutorial7.g script to set the time-step and the simulation clock: float dt = 1.0e-4 // sec setclock 0 {dt} // sec As usual the clock 0 is the simulation clock with fixed time-step "dt". Now the simulation is ready to run. If the reader types "genesis tutorial7" at the UNIX prompt, a colorful two-dimensional display of neurons should appear on the screen. A constant current can be injected into any of the cells by typing for example: genesis> setfield /network/cell[10]/soma inject 0.3e-9 Then the simulation can be run by simply typing: genesis> reset genesis> step 1000 // (or step 0.100 -time) which advances the simulation 1000 time steps (100 ms for dt = 1.0e-4). If everything is working properly then cell[10] in the display should change color reflecting the change in Vm (blue is low, yellow is high). ------------------------------------------------------------------------------- Step 5: Connecting Neurons with Excitatory and Inhibitory Synapses (net_conn.g) ------------------------------------------------------------------------------- For more interesting simulations of network behavior, excitatory and inhibitory synaptic connections must be added to the neurons. For the purposes of modular organization the connections should be set in yet another script file called for example net_conn.g. Although the neurons in the network can always be connected by specifying addmsg commands from the spikegen of each presynaptic neuron to the synchans of each postsynaptic neuron, this immense bookkeeping task can be greatly simplified using built-in commands in GENESIS for connecting large groups of neurons with weights and delays which depend on distance in the two-dimensional display. The command to connect one planar region of cells region of cells to another, "planarconnect", to set synaptic weights that decay exponentially with distance, "planarweight", and to set transmission delays that depend on distance, "planardelay", are described in detail in the Chapter 17 of the BoG. Here we will simply note that all of the neurons in the 8x8 network can be connected to neighboring cells with local excitatory synapses using a single command at in the net_conn.g script: //genesis planarconnect /network/cell[]/soma/spike \ /network/cell[]/dend/Ex_channel \ -relative \ -sourcemask box -10 -10 10 10 \ // all cells -destmask box -0.3 -0.3 0.3 0.3 // narrow excitatory range This command connects the spikegen of every cell with x position between -10 and +10 and y position from -10 to +10 to the excitatory synapse of neighboring cells in a (relative) 0.6 x 0.6 region of the x-y plane. Remember that the cells are located 0.1 distance units apart. Similarly, synaptic connections to distant cells can be given long-range inhibitory synaptic connections using the command: planarconnect /network/cell[]/soma/spike \ /network/cell[]/dend/Inh_channel \ -relative \ -sourcemask box -10 -10 10 10 \ // all cells -destmask box -0.6 -0.6 0.6 0.6 \ // wide inhibitory range -desthole box -0.3 -0.3 0.3 0.3 // don't connect to cells // in excitatory range which establishes inhibitory connections from every cell to a wider (1.2x1.2) surrounding region of cells with a "hole" in the center. Then the weights of all of these connections can be set to an exponential function of the radial distance between the presynaptic and postsynaptic cell using the single command: planarweight /network/cell[]/soma/spike -decay 2.0 1.0 0.1 where the weights of the synaptic connections are determined by an exponential function of "radial_distance" between the presynaptic and postsynaptic sites ranging between a maximum value of "Max_weight" 1.0 and a "Min_weight" 0.1 with a "decay_rate" of 2.0 according to the formula (Max_weight - Min_weight)*exp(-radial_distance*decay_rate) + Min_weight. A similar command "planardelay" can be used to set a transmission delay that is proportional to "radial_distance" between the elements in the x-y plane. The usage of this command is described in Chapter 17 of BoG. Here we will simply set all the synaptic delays to 0.0 using: planardelay /network/cell[]/soma/spike -fixed 0.0 where 0.0 is the scale factor that multiplies the "radial_distance" to determine the axonal delays. In this case the delays are all zero, which is not very biological, but suitable for our purposes. At this point the reader should include the "planarconnect", "planarweight", and "planardelay" commands in a net_conn.g script and add the line: include net_conn.g to the master tutorial7.g script. When "genesis tutorial7.g" is executed, the reader should verify that the cells are now connected with weights that diminish with distance by typing, for example: genesis> showmsg /network/cell[10]/soma/spike | more This command should then give a list of all the post-synaptic sites connected to cell[10]/soma/spike along with the weights and delays. Similarly, genesis> showmsg /network/cell[10]/dend/Ex_channel | more should list all of the excitatory presynaptic connections onto the dendrite of cell[10]. Now, when current is injected in any two adjacent cells using for example: genesis> setfield /network/cell[10]/soma inject 0.3e-9 genesis> setfield /network/cell[11]/soma inject 0.3e-9 the spiking activity of cell[10] and cell[11] should excite neighboring cells leading to a spreading wave of activity in the network. At this point The reader might try experimenting with changing the strengths of the excitatory or inhibitory synapses in the net_cell.p file or varying the "Max_weight" or the "decay_rate" in the "planarweight" command to explore the different kinds of behavior in the network. For example, with only excitatory connections, the mutual excitation of all the neurons should eventually lead to a dynamic "fixed-point" of this network, where all the neurons are firing (assuming that the synaptic connections are not too weak to let the activity die out between spikes or too strong causing "depolarizing block" of the spiking activity). -------------------------------------------------------------------------------- Step 6: Providing Input to the Network (net_inputs.g) -------------------------------------------------------------------------------- There are a variety of different ways of providing inputs to the network. Constant currents can be injected into specified cells as described earlier, the "pulsegen" object can be used to inject a pulse of current into different cells, the "randomspike" object can be used to send random spike trains to the synapses of particular cells as described in Tutorial 4, or another network of input cells can be used to stimulate this network as in the orient_tut demonstration. Here, we will use an 8x8 array of randomly spiking "neurons" (actually, just randomspike objects) to provide input to the 8x8 array of neurons that we have already generated. This array of input neurons is simply generated using a net_inputs.g script with the commands: //genesis create randomspike /library/input setfield ^ rate 200.0 abs_refract 0.001 create neutral /in createmap /library/input /in 8 8 -delta 0.1 0.1 -origin 0.15 0.15 which creates a /library/input "neuron" with an average spike rate of 200 Hz and a refractory delay of 1 ms and duplicates 64 copies in a regularly spaced rectangular array called /in/input[0] to /in/input[63] as in Step 2. To display this input array on the screen, we then use the make_xview function defined (hopefully by now) in the net_out.g script, and add the single command: make_xview /in/input[] state \ /xin "Inputs" \ 300 0 \ 0.0 1.6 to the net_out.g script which creates a separate two dimensional display that color codes (between 0 and 1.6) the spike activity (1 or 0) of the input neurons. (Don't forget to add xshow /xin to show the display.) Finally, to connect these input neurons to the network cells we add a planarconnect command to the net_conn.g script: planarconnect /in/input[] /network/cell[]/dend/Ex_channel \ -relative \ -sourcemask box -1 -1 1 1 \ // all cells -destmask box -0.01 -0.01 0.01 0.01 // single target cell which only connects each of the randomly-spiking input cells to the excitatory synapse of a single network cell with x and y coordinates that lie in a very small "-destmask" around the coordinates of the input cell. In addition we need planarweight and planardelay commands which are simply fixed at 0.8 and 0.0, respectively: planarweight /in/input[] -fixed 0.8 planardelay /in/input[] -fixed 0.0 Finally, we must add: include net_inputs.g to the master tutorial7.g script. (Be sure to include "net_inputs.g" before the "include net_conn.g" command since the input elements must be created before they can be connected!) -------------------------------------------------------------------------------- Step 7: Adding more Bells and Whistles ( Back to net_out.g) -------------------------------------------------------------------------------- At this point the only limit to the possibilities of network modelling with GENESIS should be the reader's imagination (and the available computing power). The individual neurons in the network can be made as realistic as necessary, multiple layers of diferent kinds of neurons can be connected together in more PC ("physiologically correct") configurations, and fancier displays can be added to the graphical interface. For a start the reader might want to construct a control panel interface to run the simulations from the screen. (This looks good but is not absolutely necessary for the scientific investigation of the network dynamics of realistic neurons.) For example, in the "official" net_out.g script in the Scripts/tutorials/tutorial7 directory the reader will find a template for a "simple" control panel, that uses a slower clock (clock 1 that must be set in the master tutorial7.g script) for the xview objects, thus speeding up the simulations but giving the output a jerkier appearance. The official version also has a timer that allows the user to see how much time has elapsed in the simulation. This uses the "script_out" object and uses yet another clock (clock 2) set to give updates every 10 msec of simulation time. ------------------------------------------------------------------------------- Acknowledgments ------------------------------------------------------------------------------- This tutorial was written by Rick Jensen and Mike Vanier for the 1995 Methods in Computational Neuroscience course at Woods Hole. Hilary Heuer also provided useful comments on preliminary drafts of this tutorial.