vector.play doesn't work when executed inside of proc
Posted: Wed Oct 23, 2013 7:37 am
I was starting to write this function to allow me to play in arbitrary waveforms via IClamp (starting with simple EPSCs, with a mind to build up to chirp/zap functions). The code works when I enter it directly into the nrn window, but when I try to execute it as a function, it doesn't work (no errors. the IClamp just doesn't do anything). My feeling is this is something to do with the scope that the vector has, i.e. it is local to the function preparePlayVector() and hence it is destroyed by the time finitialize() is called.. But I'm trying to be a good coder and avoid global variables. Is there a way to execute vector.play() with local variables?
Code:
Code:
Code: Select all
objref somastim
somastim = new IClamp(0.5)
somastim.del = 0
somastim.dur = 1e9
obfunc createEPSC() {local factor, n, t localobj oneEPSC //$1=rise, $2=decay, $3=amplitude
oneEPSC = new Vector(10001)
factor = (($2/$1)^($2/($1-$2)))*(($2-$1)/$1)
for (n=0; n<10001; n+=1) {
t = n*dt // n = sample number, t = time in ms
oneEPSC.x(n) = ($3)/factor*(exp(-t/$2)-exp(-t/$1))
}
return oneEPSC
}
proc preparePlayVector() {local n, EPSCdel localobj summedEPSC //$1=number of EPSCs, $2=decay
EPSCdel = 1000
summedEPSC = new Vector(tstop/dt)
summedEPSC.copy(createEPSC(.5, 3, 20), EPSCdel/dt)
summedEPSC.play(&somastim.amp, dt) //HERE IS THE PROBLEM!!!
}
preparePlayVector()