Chapter 7. Programming Simulations

"Generally, things which haven't been used DON'T work" -- Michael L. Hines on simulation programs.

Jump to

7.1 Sample application program .

A. Component structure.

The process of writing an application program is clearly a matter of personal style but it was deemed useful to present an example or two of the structure of some programs which we have written. This style fits our needs for encapsulating statements in categories so that they can be found and edited quite easily. I use a building block approach because it is the way in which I view the program and which I hope will be helpful for new users. In the block below are listed several steps in writing a simple program with the functions performed noted in the comments at the right of box1. In turn, the component hoc programs called for in this box are defined in more detail within later boxes. The composition of a sample application to be simulated is shown in the box just below.

Box 1. Sample nervecell.hoc


    load_proc("nrnmainmenu")	//loads the master menu procedure
    nrnmainmenu()		//executes this procedure, bringing
					up main menu

    xopen(morphology.hoc")	// retrieves morphological description:
					 names, dimensions, connections
 
    xopen ("mechanisms.hoc")	// retrieves mechanisms and parameters
					types, locations, & densities

    xopen("synapses.hoc")	// inserts synaptic parameters:
					locations. strengths, & sources

    xopen("electrode.hoc")	// inserts electrodes at desired 
					locations driven by current clamp,
					voltage clamp: single and families
					of levels

    xopen("nervecell.ses")	// recalls saved set of panels and	
					parameter values

B. Concatenated structure for simple morphologies

PATCH: For a patch of uniform membrane, one needs only a trivial four line program.


	load_proc("nrnmainmenu")
	nrnmainmenu()
	create patch
	patch {insert hh}

	xopen("patch.ses")

The expression "patch {insert hh}" tells the interpreter to carry out all operations within the braces. In this case, simply to insert Hodgkin-Huxley channels; one could also insert other channels and mechanisms here as well. Inclusion of the xopen("patch.ses") line provides for recall of a previously stored session and makes a "turnkey" simulation ready to run with mouse "clicks". If one has installed NEURON on one's local machine according to the proceedure to run complex simulations of NEURON from Mosaic, this program for a patch of membrane may be run by pressing here. The program may be stopped by clicking on the "Other" button on the "Print and File Window Manager" panel and then choosing "Quit".

SIMPLE CELL: For a simple cell, one does not need the compartmentalization used in A and can concatenate the program into a few lines. The program below creates three "sections": a soma, an axon and one dendrite. The convention for connections is that a Child is connected to a Parent as shown here:


  Rules 
	Only ends of a Child may be connected
		e.g. Child(0) for left end or Child (1) for the right end
	Connections to a Parent may be made anywhere along its length
		e.g. Parent(0 -- 1): 0 for the left end, 1 for the right
		 and fractions for  the relative position along the length
  Syntax
	connect Child(0), Parent(.5)
	connect x(1), y(.75)

The program below uses this convention to connect the dendritic and the axon to opposite ends of the soma, chosen as the parent .


    load_proc("nrnmainmenu")
    nrnmainmenu()

    create soma, axon, dendrite
 	
    connect axon(0), soma(1)
	    //connect 0 end of axon to 1 end of soma 
    connect dendrite(0), soma(0)	
	    //connect 0 end of dend to 0 end of soma

	    //ASSIGN geometry and channels to sections
    soma	{ L=200 	diam=200	nseg=1} 	
		//1 segment for spherical section
    soma	{insert hh}

    axon	{nseg=25	L=7500		diam=25}
    axon	{insert hh }


    dendrite	{nseg=5	  L=1500	diam=96}
    dendrite	{insert pas	e_pas=-65}

	     
    access soma     //Choose Section of interest or default

    topology()      // runs procedure to show topology assigned

    xopen("cell.ses")
To run this program, press axon-soma-dendrite

Such a program structure is still applicable for a simple neuron with only a few dendrites and used as the example some of the figures shown later in this chapter. However as complexity builds, there is a point at which management seems to become easier with the component structure shown above.

When NEURON 3.0 is started , and executes the procedure call "nrnmainmenu()", it brings us the Main Menu panel shown below and whose functions are described in detail in Chapter 5.4. The buttons on this panel provide access to all the major operations necessary for simulation control up to what might be called the "oscilloscope" level of complexity. An example would be stimulation of the cell, recording the time course of a few variables, and managing changes in a few parameters. This level of complexity is sufficient for a large variety of problems such as

  • Monitoring all assignments of morphology, distributed mechanisms, point processes, ion concentrations, etc. when starting a new simulation.
  • Exploring the range of behaviors associated with parameter changes.
  • Manual fitting of parameters to experimental data, for example as described in Chapter 3. under Manual Iterative Searches for "best fit"

The extraction of summary information from a large series of sumulation runs will usually "problem specific" and will probably require a hoc program to capture and plot the desired information. Examples of this are available in Chapter 14 of the Reference Manual.

Forward to
Mechanisms
Synapses
Electrodes