CNrun
CNrun is a neuronal network model simulator, similar in purpose to NEURON except that individual neurons are not compartmentalised. It can be extremely precise and slow, or very fast but sloppy. The core of the simulator, including in particular the RK65 algorithm, comes from refactored code originally written by Thomas Nowotny.Features
- Supported unit types:
- Neurons
- HH, Hodgkin–Huxley by Traub and Miles (1991);
- HHRate, Rate-based model of the HH neuron;
- HH2, Hodgkin–Huxley by Traub & Miles with K leakage current;
- Poisson, Poisson oscillator, with configurable spike duration;
- DotPoisson, Duration-less spike (i.e., a spike lasting for one dt) Poisson oscillator;
- DotPulse, Dot Pulse generator;
- NMap, Map neuron, a very fast approximation of the HH neuron;
- Colpitts, Colpitts oscillator;
- VdPol, Van der Pol oscillator.
- Synapses
- AB, αβ synapse (Destexhe, Mainen, Sejnowsky, 1994);
- ABMinus, same, w/out the (1 — S) term;
- Rall, Rall synapse (Rall, 1967);
- Map, Map synapse (complementary to the NMap neuron).
- Neurons
- Reads network topology description from a NeuroML file (as, for example, generated by neuroConstruct), where the cell_type attribute determines the unit class (from the list above).
- Integration cycle using a Runge–Kutta 6-5-order method, with adjustable minimal and maximal time step.
-
Extensive scripting capabilities courtesy of Lua.
CNrun ver. 2 is implemented as a Lua module, which makes
available core CNrun API for
use in your scripts (normally,
with
require("cnrun")
). -
Individual unit state introspection from your scripts:
- runtime, via
get_unit_vars()
, providing state variable readout into Lua variables; - logging, via
start_listen()
, for offline plotting or analysis.
- runtime, via
- Neuroplastic processes, such as addition/removal of units, identified by label or regexp, or of a random fraction of a population.
-
Repeatability of the output of random number dependent
units (such as Poisson oscillator). CNRun uses the gsl (GNU
Scientific Library) rng facilities. You can set the seed and
the rng type with the environment
variables
GSL_RNG_TYPE
andGSL_RNG_SEED
(leave the latter unset for seeding from the current time’s microsecond value).
Source code and availability
-
Since mid-August, 2012 CNrun is available in Debian/testing
(and also in all current releases of Ubuntu). The old (1.x)
package
cnrun
, is a standalone executable interpreter. The newer, version 2.x comes in four packages, of which you will wantlua-cnrun
if you just want to execute Lua scripts, orlibcnrun2-dev
if you are interested in CNrun C++ API. - There is an ebuild, too, in gentoo ‘science’ overlay, available since 2015-02-18.
-
If you want to build from sources (say, to compile it using
-mtune=native -O3 -flto
, or build standalone tools), make sure you have (the development packages of) these packages installed:gsl
,libxml2
andlua
. Get the source tarball here; build and install per usual autotools instructions (./configure && make install
). - The project’s public Git repositories are hosted on github, on Debian’s servers, at home and, historically, also at SourceForge.
Usage
-
For CNrun 2.x, there is an example installed
in
/usr/share/doc/lua-cnrun/examples
and a node of info pages (info lua-cnrun
, with the same contents available in html). -
For CNrun 1.x, which interprets simple commands with no code
flow, let’s look at the following example:
# create a model called "fafa" new_model fafa # add a couple of neurons add_neuron HH n1 add_neuron HH n2 # connect them reciprocally add_synapse AB syn1 n1 n2 add_synapse AB syn2 n2 n1 # make the synapses inhibitory # note that synapse are identified by their source and target neurons set_parm_synapse n. n. Esyn -80 # make them spontaneously active (by injecting a DC) set_parm_neuron n. Idc 0.1 # enable listening start_listen n. # run the simulation for 2 seconds advance_for 2000
Starting CNrun with option
-e script
will execute that script.Alternatively, have your NeuroML file ready and load it using
load_nml filename
.Now you have two files,
n1.var
andn2.var
containing, in two tab-separated columns, a timestamp and the value of state variable E per record. This can readily be plotted using gnuplot. - If your generated var files are growing into hundreds of
megabytes, you might consider setting a larger listening dt
(say, with
listen_dt 1
) and/or enabling options-L1
to only log the first state variable, and-Lx
, to produce binary logs (or use the commandlisten_mode 1+b+
. In the latter case CNrun will output state variable data in native form, which will speed up gnuplot considerably at the expense of those files becoming unreadable. To plot binary data, useplot "your-file.varx" binary format "%lf%lf" with lines