Using For Loops to Call Multiple Simulation Runs
Posted: Wed Nov 13, 2013 6:00 pm
Hi, I am trying to write a hoc file that will iterate through a user defined number of runs but I keep getting errors that Neuron says are at the end of the hoc file but which do not make much sense. The reason for iterating through the number of runs is that I am changing a list of event times on each run. For instance:
/Applications/NEURON-7.3/nrn/x86_64/bin/nrniv: syntax error
in mosinit2.hoc near line 65
file = new File()
If I move that command to earlier in the file, I get a syntax error pointing to the last line of the hoc file again.
My protocol for populating the vector is contained in a hoc file that is loaded by the mosinit hoc file that I use to run the simulation. This protocol is called interval:
Then in the mosinit file I load the file containing the above code and the rest of the simulation parameters and then:
newvec is to create a new spike-counting vector each run of the simulation.
counter finds the average spike frequency and appends this to a vector.
gocount launches the simulation.
Neuron does not seem to be happy with this code but it is not giving me error messages that make much sense. How can I run the simulation with iteratively calls so that I can increment my call to the interval procedure?
/Applications/NEURON-7.3/nrn/x86_64/bin/nrniv: syntax error
in mosinit2.hoc near line 65
file = new File()
If I move that command to earlier in the file, I get a syntax error pointing to the last line of the hoc file again.
My protocol for populating the vector is contained in a hoc file that is loaded by the mosinit hoc file that I use to run the simulation. This protocol is called interval:
Code: Select all
// create vector for spike times
objref svec
svec = new Vector()
proc interval () { local i, x
low = $1
reps = $3
x = low
dx = $2
for i = 1,reps {
svec.append(x)
x = x + dx
}
}
// create a vector stim that generates events at times in svec
objref vecstim
vecstim = new VecStim()
vecstim.play(svec)
Code: Select all
dt = 0.025
tstop = 10000
v_init = -60
proc init() {
finitialize(-60)
frecord_init()
}
proc integrate() {
while (t<tstop) {
fadvance()
}
}
proc go() {
init()
integrate()
}
proc newvec() {
objref grcspk, nc, nil
grcspk = new Vector()
grc nc = new NetCon(&v(0.5), nil)
nc.threshold = 0
nc.record(grcspk)
}
proc counter() { local firstspk, lastspk, totspk, spkfreq
totspk = grcspk.size
firstspk = grcspk.x[0]
lastspk = grcspk.x[totspk-1]
if (totspk > 1) {
spkfreq = (totspk - 1)/(lastspk - firstspk)
} else{
spkfreq = 0
}
spkcnts.append(spkfreq)
}
proc gocount() { local ii
for ii = 1,2 {
newvec()
interval(3000, ii, 100)
go()
counter()
}
gocount()
counter finds the average spike frequency and appends this to a vector.
gocount launches the simulation.
Neuron does not seem to be happy with this code but it is not giving me error messages that make much sense. How can I run the simulation with iteratively calls so that I can increment my call to the interval procedure?