Save the following to a file called initn.hoc, then use NEURON to execute it. Note the organization of the program, in particular the extensive use of procedures, and how it performs the following tasks in sequence:
- declares important constants (model parameters and simulation parameters)
- loads files that other stuff will depend on
- creates the model itself (just a collection of cells that spike at random times)
- specifies instrumentation (in this case, recording of spike times)
- specifies simulation control
- executes one or more simulations with various model parameters
/* initn.hoc demonstrates that multiple NetStims draw from a shared distribution */ NSNUM = 2 // how many NetStims to create ISI = 10 // default NetStim parameters NUM = 10 START = 1 NOISE = 1 TSTOP = 20 // length of simulation load_file("nrngui.hoc") ///// model setup objref nslist nslist = new List() proc makenetstims() { local i localobj ns nslist = new List() for i = 0, $1-1 { ns = new NetStim() nslist.append(ns) } } makenetstims(NSNUM) proc setparams() { local i for i = 0,nslist.count()-1 { nslist.o(i).interval = ISI nslist.o(i).number = NUM nslist.o(i).start = START nslist.o(i).noise = NOISE } } setparams() ///// instrumentation objref tvec, idvec, nil tvec = new Vector() idvec = new Vector() proc instrumentation() { local i localobj nc tvec = new Vector() idvec = new Vector() for i = 0,nslist.count()-1 { nc = new NetCon(nslist.o(i), nil) nc.record(tvec, idvec, i) } } instrumentation() ///// simulation control tstop = TSTOP proc seed() { // all NetStims share the same random number generator // so we only have to call one NetStim's seed() method. nslist.o($1).seed($2) } proc myrun() { local i run() print " time cell" for i=0, tvec.size-1 printf("%7.3f \t%d\n", tvec.x(i), idvec.x(i)) } ///// print "============================================================" print "Control: both have interval 10, number 10, start 1, noise 1" print "============================================================" myrun() print "============================================================" print "Test: NetStim 1 starts at 6 ms" print "============================================================" seed(0,1) // reset random number generator to start of sequence nslist.o(1).start = 6 myrun()