Next Slide (Previous)
SIMULATION CONTROL I: Basic Concepts (TOC)
Problems:
serious problem: "lost in parameter space"
silly problem: "lost the parameters"
The solution: organization
Next Slide (Previous)
Simulation management (TOC)
Wet physiology: variability is acceptable
Simulations should be completely replicable
Adequate documentation to rerun sims 6 mos or 6 years later
Next Slide (Previous)
Aspects of big simulations (TOC)
Comparable to major software projects (eg writing a compiler)
Structured programming
Compartmentalization of file types:
mod: INCLUDE
hoc: templates
prepared packages
The binding problem: parameters, sims, graphics, data
Graphics must be offline
Next Slide (Previous)
Types of big simulations (TOC)
Parameter searchs (parset)
Networks (NetCon)
Phase plane analyses
Hybrid networks (Hinton)
Next Slide (Previous)
WYSIWYNTS (TOC)
What You See Is What You Need To See
Hide boiler-plate code
Hide background functions
Be able to step back, look at big picture then zoom in
outline mode
revision control system
index file (readable and runnable)
lab notebook (readable)
and of course: comment code; write doc files immediately
Next Slide (Previous)
The mod interface (TOC)
Maintain a mod control file
list mod files with version numbers
maintain co and compile command:
co -r1.7 naf.mod; co -r1.3 kdr.mod; nrnivmodl naf.mod kdr.mod
Use INCLUDE statements for boiler-plate code
Combine: mkmod to put together mod files
Avoid copying complex blocks of code
NEURON {
SUFFIX NAME
}
PARAMETER {
param1 = 15
...
}
INCLUDE "body.inc"
Maintain a separate list of rarely-changed compiled code
parameters.multi
Next Slide (Previous)
The hoc interface (TOC)
Put shortcut procs in init files (eg syncode.hoc)
Separate out templates (only load once)
Separate network, cell, parameter definitions
HOC tools to manage complexity:
templates
lists
vectors
iterators
Next Slide (Previous)
My tool box (in addition to NEURON/hoc/mod) (TOC)
emacs -- a programmable editor
perl -- a flexible interpreted programming language
RCS -- revision control system (SCCS, VC)
Hoc packages:
vector, list manipulations
grvec: vector graphics
parset: parameter exploration and graphics
Next Slide (Previous)
Simulation samsara: the eternal cycle of simulation and regret (TOC)
Great results but done on the fly in interpreter
Reviewers always want 1 more sim
Collaborator wants to run sims
Next Slide (Previous)
Need to maintain correspondence among different versions of the same virtual reality: (TOC)
Primary: what's running in the simulator
Check periodically that params in sim are as expected
Secondary: the ascii text of parameter (hoc) and source (.mod) files
Tertiary: lab notebook, graphics, data files
Periodically go back 1-2 weeks and make sure everything still same
Next Slide (Previous)
Other solutions: run traces as you type (TOC)
Upside: Everything that you did is recorded.
Downside: A complex sim will want to use pre-made files. These will still need some kind of version numbers.
Next Slide (Previous)
Second easiest solution (TOC)
Use tar or zip to put everything together
Save the bundle as date.num.tar
maintain and index file with date.num and a comment
Downside
needs to be unpacked before being run
hard to directly compare between runs
Next Slide (Previous)
Snapshot: what files do we need to save? (TOC)
mod and hoc files
saving executable: difficult with dynamically-linked libraries
Change files at different rates: params > network > cells > channels
Next Slide (Previous)
Version control (TOC)
Used by software developers: eg Windows 3.0
Keep track of previous work
Use with ascii -- don't save tar or zip files this way
Check-in is analogous to saving from WP to disk
Next Slide (Previous)
RCS (Revision Control System) (TOC)
lock and unlock are for sharing, not necessary if you're not sharing
look at grv.hoc in various incarnations
can do more complicated things like look at all changes since a certain date
rcsgetdate "Jul 25 1998" trcagk.mod trahp.mod calr.mod
check-in tantamount to saving to disk since overwrite file
don't neglect the failed simulation: will be useful to see 6 mos. from now
Next Slide (Previous)
VC Snapshots: (TOC)
Control releases and configurations with multiple files
Revisions are assigned symbolic names
Mark as figure, final, works, loads (cf released, stable, experimental)
configurations of modules can be described simply and directly.
Next Slide (Previous)
Developing an index file (TOC)
redundant: kept separate from lab notebook to facilitate automated parsing
define a set of template files and a set of sim files
templates in template.hoc
sim files usually geom.hoc or network.hoc, params.hoc, run.hoc
names stay constant -- only version numbers change
new versions of other files also recorded: mod files, multi files, ancillary hoc files
eg index
Next Slide (Previous)
SIMULATION CONTROL II: Comparing and contrasting (TOC)
Next Slide (Previous)
Sims are computer experiments (cf Wolfram -- Scientific American) (TOC)
run control then change 1 thing
always comparing simulations
graphic power of NEURON facilitates this
still have to organize sims and data files to make it easy
Next Slide (Previous)
Using vectors for data storage, data analysis and graphics (TOC)
Generally network sims are too slow and too complex to watch in real time
Storage to vectors allows maintaining the data in compact manner
Save both RAM and disk space
Rapid disk i/o (fread, fwrite)
Full access to analysis tools
Rapid graphing since a native format for Interviews
Next Slide (Previous)
grvec.hoc provides a bunch of shortcuts using basic vec calls (TOC)
vec.record: cycle through all instances of a particular cell
vec.plot: superimpose current sim and old sims
vec.write/read: store and retrieve quickly
read in data files: easy to mix fantasy and reality
Next Slide (Previous)
SIMCTRL automates simulation control (TOC)
everything could be done adequately by hand
computer consulting adage: organize before automating
Next Slide (Previous)
Don't type in the simulator unless trace ongoing (TOC)
Type in sim files
Save (RCS) sim files after running
Maintain correspondence between all records:
index + notebook, graphics, data, parameters, source code
Next Slide (Previous)
Parameter comparisons (TOC)
set up with for loops or explicit selections; eg
proc parset () {
prsl.remove_all()
prsfor("LEAK","gl_hh",2e-4,1e-3,2e-4)
ob = new PRS("Na","gnabar_hh=",0.05,0.3,0.7,1.4)
ob = new PRS("Kdr","gkbar_hh=",0.03,0.06,0.3,0.6,2)
ob = new PRS("STIM","stim.amp=",0.2,0.5,1)
ob = new PRS("STIM","stim.amp=",0.2,0.5,1)
sims = setprs() // required!
}
Next Slide (Previous)
Next Slide (Previous)
NETWORK SIMULATIONS (TOC)
Next Slide (Previous)
Next Slide (Previous)
Next Slide (Previous)
Basic netcon call very simple: new NetCon(source,dest) (TOC)
eg Cell[15].soma ncl.append(new netcon(&v(0.5),Cell[23].ampa)
params: set netcon.thresh, netcon.weight, netcon.delay
will want to handle much of this with loops eg
for ltr (XO,new List($s1)) { // presyn list
for ltr (YO,$o2) { // postsyn list
if (pp_loc(YO,ts1,syn2)) {
// print "connecting ",XO," to ",syn2
XO.soma ncl.append(new NetCon(&v(.5), YO))
}
}
}
Next Slide (Previous)
Traub defines his CA3 networks by connection probabilities (TOC)
Next Slide (Previous)
Number of synapses is product of convergence and number of postsynaptic cells (TOC)
(or product of divergence and number of presynaptic cells)
Percent convergence == Percent divergence
Next Slide (Previous)
define cell names symbolically (TOC)
ctypes = 2 // number of cell types
PYR = 0
IN1 = 1
use a hoc array
double pmat[ctypes][ctypes]
pmat[PYR][PYR] = 0.03
pmat[PYR][IN1] = 0.8
pmat[IN1][PYR] = 0.1
pmat[IN1][IN1] = 0.8
Next Slide (Previous)
If define randomly according to convergence need to balance divergence (TOC)
look at pickpre in syncode.hoc
Next Slide (Previous)
Also need to balance synaptic weights -- might move to absolute conv numbers (TOC)
for ltr(XO,ncl) {
XO.threshold = 0
XO.weight = gvari(5/numdg,0.1)
XO.delay = gvari(10,0.5)
}
//** vari returns randomly chosen $1+/-$2
func uvari () { return $1 - $1*$2 + (u_rand() * 2 * $1*$2) }
func gvari () { return $1 - (norm() * $1*$2) }
Next Slide (Previous)
Synapse routines (from syncode.hoc) (TOC)
make common things easy to do
eg conv(): which cells converge onto granule cell 15?
which cells converge onto GABA_A synapses of granule cell 15?
What is the average weight of these synapses
eg
//* synapse linking
//** geolink(s1,s2,s3) s1 for presyns and s2 for postsyns, connect s3's
//** nowraplk(s1,s2,s3) s1 for presyns and s2 for postsyns, connect s3's
//** synlink(s1,s2,s3,[gmax,del]) s1 for presyns and s2 for postsyns, connect s3's
//** synconn(l1,s2,s3,%div) l1 list of presyns and s2 for postsyns, connect s3's
//** pickpost() tries to reduce divergence variance
//** syncopy() copies from one set of syns to another for colocalization ***
//** simple netconnect routines: netsoma(), netgen()
//*** genlink(o1,s2,s3) o1 for gen and s2 for postsyns, connect s3's
//* synapse setting
//** scale gmax
//** set/get gmax
//** set/get delay
//** set/get thresh
//** synremove: remove post, pre/post, pre/post/type; synshow
//* informational procs
//** pp_loc(PP,STR,SCRATCH) returns true if point process PP is located in STR (regexp match)
//** ndivo, ncono, sdivo, scono: objects; ndivs, ncons, sdivs, scons: strings
//* misc and commentary
//** vari returns randomly chosen $1+/-$2
//** latlink() gives wrap-around
Next Slide (Previous)
Thalamus model is slightly more complicated (TOC)
Next Slide (Previous)
3D pmat since define columns as well (TOC)
//* Connectivity matrix
{TC=0 RE=1 CTYPES=2}
dist = 3
double pmat[CTYPES][CTYPES][2*dist+1]
fseed(2312951)
// TC -> RE
pmat[TC][RE][dist] = 1
pmat[TC][RE][dist+1] = 0.67
pmat[TC][RE][dist-1] = 0.67
pmat[TC][RE][dist+2] = 0.34
pmat[TC][RE][dist-2] = 0.34
pmat[TC][RE][dist+3] = 0.15
pmat[TC][RE][dist-3] = 0.15
// RE -> TC
pmat[RE][TC][dist] = 1
pmat[RE][TC][dist+1] = 0.67
pmat[RE][TC][dist-1] = 0.67
pmat[RE][TC][dist+2] = 0.34
pmat[RE][TC][dist-2] = 0.34
pmat[RE][TC][dist+2] = 0.15
pmat[RE][TC][dist-2] = 0.15
// RE -> RE
pmat[RE][RE][dist] = 0
pmat[RE][RE][dist+1] = 1.0
pmat[RE][RE][dist-1] = 1.0
pmat[RE][RE][dist+2] = 0.5
pmat[RE][RE][dist-2] = 0.5
pmat[RE][RE][dist+3] = 0
pmat[RE][RE][dist-3] = 0
Next Slide (Previous)
Need graphics to understand what you've got -- still difficult (GIGO -> GICGO) (TOC)
Next Slide (Previous)
Dentate gyrus model has 3 cell types (TOC)
Next Slide (Previous)
Pmat reflects 3 cell types (TOC)
pmat[DG][AC] = 2/5 // Feedforward inhib
pmat[DG][MC] = 1/20 // Varying this parameter now
pmat[AC][MC] = 1/10 // too much input so changed
pmat[MC][DG] = 1/20 // MC gets input from many dg's initial 1/20
pmat[MC][AC] = 1/5 // Each ac projects to 4 mc
pmat[AC][AC] = 1/5 // Inhib to inhib
pmat[AC][DG] = 1/100 // Each Ac gets 1/100th input from dg's
pmat[DG][DG] = 0 // turn off sprouting
Next Slide (Previous)
Next Slide (Previous)
With a 268 line network.hoc file, very nice to have outline mode (TOC)
eg network.hoc
Next Slide (Previous)
Use grvec.hoc to look at results graphically (TOC)
Next Slide (Previous)
Raster plot (TOC)
Next Slide (Previous)
Summate to get population activity (can smooth) (TOC)
Next Slide (Previous)
Previous Slide