This programming guide is intended to be a primer for novices attempting to run the NEURON simulator. Complete programming references, tutorials, and other documentation may be found on the author’s site.
Getting Started
NEURON may be downloaded from http://www.neuron.yale.edu/neuron/install/install.html for Linux, MSWin (95 and up), and Mac OS X 10.4. NIL is running NEURON within the Fedora Linux environment on the basis that of the available OSs, Linux requires the least computational resources and may be implemented cheaply and easily across multiple hardware systems.
NEURON is installed in Linux with the command
rpm nrn-[...].i686.rpm
or installed versions may be upgraded with
rpm -Fvh nrn-[...].i686.rpm
For those operating on a non-Linux system I recommend installing the virtual os program VirtualBox. The program allows any OS (Mac, Win, or Linux) to be run as a virtual (guest) system on any host. Virtual systems have full network and host file system access. NIL is running with both pure and virtual Linux systems.
In recent years NEURON has been modified to interact with the object-oriented language Python. The language comes installed with most flavors of Linux (including Fedora) or may be obtained through their download page. Two additional libraries, ‘numby’ and ’scipy’, are also required and may be installed through the Linux package manager.
Commands
- nrnivmodl – compiles a downloaded model. Run the command within the model’s folder.
- nrngui – executes the model. (i.e. nrngui mosinit.hoc)
Resources
- NEURON home page
- What is NEURON (by the software authors)
- NEURON Quick Reference
- NEURON Instructions and Parameters
- NEURON Tutorial
- The NEURON Forum
- Neural Simulator Resources (internal NIL link). Before continuing with the NEURON Simulator Programming Guide, I strongly recommend that the reader investigates the Database resources. The databases provide pre-built models for immediate gratification.
- Performance Data – Parallel network simulations with NEURON (pdf)
Other Projects Using NEURON
- Blue Brain Project – Massive use of mNEURON (multiprocessor version).
‘.hoc’ Template
The following document outlines the sections necessary to program a structure within the neural simulator NEURON. Where possible, the first instances of keywords have been linked to reference documents for ellaboration.
//********************************************************************** //********************************************************************** // TEMPLATE: Basic Neuron // AUTHOR(s): Richard Friendlich // This file is a composite of various tutorials and books. // Primary contributors include Dr. N.T. Carnevale, Dr. M. L. Hines, Kevin E. Martin (martin@cs.unc.edu) // Additional authors are sited as necessary. // PURPOSE: // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: // NEURON files are saved with the .hoc extension and may be executed via the nrngui command //********************************************************************** //********************************************************************** load file("nrngui.hoc") // Loads GUI and standard runtime library //********************************************************************** // Procedure: celldef // Author(s): Various // PURPOSE: Implements modular approach to cell building // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: 'The NEURON Book' recommends dividing the cell description into: Topology, Geometry & Biophysical Properties //********************************************************************** proc celldef() { topol() subsets() geom() biophys() geom_nseg() } create soma, apical, basilar, axon /*'create' is an nrniv command which creates a list of section names. Existing sections with the same names are destroyed and recreated. The create statement may occur within procedures, but the names must have been previously declared with a create statement at the command level.*/ //********************************************************************** // Procedure: topol // Author(s): Various // PURPOSE: Connects basic cell structure. This represents the cells framework much like a skeleton. // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 //********************************************************************** proc topol() { local i connect apical(0), soma(1) connect basilar(0), soma(0) connect axon(0), soma(0) basic_shape() } //********************************************************************** // Procedure: basic_shape // Author(s): Various // PURPOSE: Assigns 3d coordinates to structures defined in topol // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: The topology works fine with out pt3dadd. Upon creating a 'shape plot' NEURON creates and arbitrary 3d structure // if one has not been specifically designated. //********************************************************************** proc basic_shape() { soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)} // Destroys the 3d location info in the currently accessed section apical {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(120, 0, 0, 1)} // and adds the 3d location and diameter point at the end of the basilar {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-59, 45, 0, 1)} // current pt3d list. axon {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-104, 0, 0, 1)} } objref all, has_HH, no_HH /*Object variables are labels (pointers, references) to the actual objects. Thus o1 = o2 merely states that o1 and o2 are labels for the same object. Objects are created with the new statement. When there are no labels for an object the object is deleted. The keywords objectvar and objref are synonyms.*/ //********************************************************************** // Procedure: subsets // Author(s): Various // PURPOSE: Groups sections (made via 'create' command) into manageable units // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: Subsets a useful shorthand for assigning morphologies to groups of sections at a time. //********************************************************************** proc subsets() { local i objref all, has_HH, no_HH all = new SectionList() soma all.append() apical all.append() basilar all.append() axon all.append() has_HH = new SectionList() soma has_HH.append() axon has_HH.append() no_HH = new SectionList() apical no_HH.append() basilar no_HH.append() } //********************************************************************** // Procedure: geom // Author(s): Various // PURPOSE: Specifies the geometric properties of the sections. // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: //********************************************************************** proc geom() { forsec all { } soma { L = 30 diam = 30 } apical { L = 600 diam = 1 } basilar { L = 200 diam = 2 } axon { L = 1000 diam = 1 } } //********************************************************************** // Procedure: geom_nseg // Author(s): Various // PURPOSE: Establishes required number of segments per section. // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: //********************************************************************** proc geom_nseg() { forsec all { nseg = int((L/(0.1*lambda_f(100))+.9)/2)*2 + 1 } } //********************************************************************** // Procedure: biophys // Author(s): Various // PURPOSE: Inserts biophysical cell properties. // PARAMETERS: None. // VERSION HISTORY: 20 Nov 2007 // NOTES: //********************************************************************** proc biophys() { forsec all { Ra = 100 cm = 1 } forsec has_HH { insert hh // insert is used to place distributed mechanisms (membrane properties) gnabar_hh = 0.12 gkbar_hh = 0.036 gl_hh = 0.0003 el_hh = -54.3 } forsec no_HH { insert pas g_pas = 0.0002 e_pas = -65 } } access soma celldef() //********************************************************************** //********************************************************************** /* Instrumentation //********************************************************************** //********************************************************************** // Synaptic input objref syn soma syn = new AlphaSynapse (0.5) syn.onset = 0.5 syn.tau = 0.1 syn.gmax = 0.5 syn.e = 0 // graphical display objref g g= new Graph() g.size (0,5,-80,40) g.addvar ("soma.v(0.5)",1,1,0.6,0.9,2) //********************************************************************** //********************************************************************** /* Simulation Control //********************************************************************** //********************************************************************** dt = 0.025 tstop = 5 v_init = -65 proc initialize(){ finitialize(v_init) fcurrent() } proc integrate(){ g.begin while(tfadvance() g.plot(t) } g.flush() } proc go(){ initialize() integrate() } tstop()
