I'm not sure why you want to replace these fstim calls. If it ain't broke,
don't fix it. It's even easy to understand what they are doing. If you have
to fix something, there are other things in this code that I would suggest
fixing first.
Code: Select all
proc run4bd() {
tstop=800 // execution stops at t=800 ms
access apical[7] // apical[7] is the currently accessed function
nstim=3
// throw away any existing fstim specification
// and set up a new one that will deliver 3 current pulses
fstim(nstim)
// all are located at 0.4 on apical [7]
fstim(0, 0.4, 5, 450, 0.1) // first pulse is 0.1 nA from 5 to 455 ms
fstim(1, 0.4, 455, 250, -0.5) // second is -0.5 nA from 455 to 705 ms
fstim(2, 0.4, 705, 70, 0.1) // third is 0.1 nA from 705 to 775 ms
g.erase_all()
g.size(0,tstop,-120,0)
// This looks like a bug.
// Each time run4bd() is called, apical[dist].v(0.4) is added to g's plotlist.
// If run4bd is called several times, the simulation will execute more
// slowly each time. But maybe the person who wrote this code
// designed the rest of the program in such a way that run4bd will only
// be called once, or just a very few times.
g.addvar("apical[dist].v(0.4)",3,1,2*tstop,0,2)
g.xaxis(1)
g.begin()
printf ("running...")
run()
printf("done \n")
}
Just don't use fstim if you're writing a new program. To do something like
this, you could just use three IClamps. Or you could use a single IClamp
and take advantage of the Vector class's play() method
http://www.neuron.yale.edu/neuron/stati ... .html#play
For example, if you are using fixed time step integration, this should work:
Code: Select all
objref ivec, tvec, stim
apical[7] stim = new IClamp(0.4)
ivec=new Vector(9)
tvec=ivec.c
tvec.x[0]=0 ivec.x[0]=0
tvec.x[1]=5 ivec.x[1]=0
tvec.x[2]=5 ivec.x[2]=0.1
tvec.x[3]=455 ivec.x[3]=0.1
tvec.x[4]=455 ivec.x[4]=-0.5
tvec.x[5]=705 ivec.x[5]=-0.5
tvec.x[6]=705 ivec.x[6]=0.1
tvec.x[7]=775 ivec.x[7]=0.1
tvec.x[8]=775 ivec.x[8]=0
ivec.play(&stim.i, tvec)
tstop=800 // execution stops at t=800 ms
g.size(0,tstop,-120,0)
g.addvar("apical[dist].v(0.4)",3,1,2*tstop,0,2)
g.xaxis(1)
g.begin()
proc run4bd() {
g.erase_all()
printf ("running...")
run()
printf("done \n")
}
If you want to use variable time step integration, the
vsrc.play(&var or stmt, tvec, indices_of_discontinuities_vector)
form of Vector play() should be used (for this example, the
indices_of_discontinuities_vector would have 4 elements, whose values
are 1, 2, 3, 4).