-
Notifications
You must be signed in to change notification settings - Fork 1
/
twobirampsdel.hoc
172 lines (104 loc) · 2.94 KB
/
twobirampsdel.hoc
1
/* make2biramps.hoc sets up a triangular waveform for use as a command potential assumes the following are known: dt time step*/// Easy mnemonics so I can set these in the interpreter// and then invoke simple() (just in case I forget the calling// syntax for mkramp(), or maybe only want to change one param).// My convention for constants is upper caseRSTRT1=0 SLOPE1 = 0.2 TR = 10000 // msRSTRT2=0 SLOPE2 = 0.1DEL = 1000 objref mycmd1,mycmd1a,mycmd1b,mycmd1c,mycmd1d,mycmd2,mycmd2a,mycmd2b,mycmd2c,mycmd2dmycmd1 = new Vector() // must create object outside procmycmd1a = new Vector() // must create object outside procmycmd1b = new Vector() // must create object outside procmycmd1c = new Vector() // must create object outside procmycmd1d = new Vector() // must create object outside procmycmd2 = new Vector() // must create object outside procmycmd2a = new Vector() // must create object outside procmycmd2b = new Vector() // must create object outside procmycmd2c = new Vector() // must create object outside procmycmd2d = new Vector() // must create object outside proc/* Creates a "ramp" vector _____ v1 / / slopev0 / tr arguments: $1 v0 command at start of ramp (mV) $2 slope dv/dt during ramp (mV/ms) $3 tr duration of ramp (ms) $4 del hold period at start and end of ramp note 1: v1 = v0 + slope*tr note 2: at end of t0 + tr, vector.play will leave command at v1, but if this is played into dur2 of a SEClamp object, what really happens will depend on whether t enters dur3 */// I double the initial letter so these local variables won't // collide with global names that I may want to use laterproc mkbiramp1d() { local ii, vv0, sslope, ttr, vv1, ddel1 vv0 = $1 sslope = $2 ii=0 if (sslope<0) { sslope *= -1 ii=1 } ttr = $3 ddel1=$4 vv1 = vv0 + sslope*ttr/2 mycmd1a.resize(ddel1/dt) mycmd1a.fill(vv0) mycmd1b.indgen(vv0, vv1, dt*sslope) mycmd1c.indgen(vv0,vv1,dt*sslope) mycmd1d.resize(ddel1/dt) mycmd1d.fill(vv0) mycmd1c.reverse() mycmd1.resize(0) mycmd1.append(mycmd1a,mycmd1b,mycmd1c,mycmd1d) if (ii==1) { mycmd1.sub(vv0) mycmd1.mul(-1) mycmd1.add(vv0)}}proc mkbiramp2d() { local ii, vv0, sslope, ttr, vv1, ddel1 vv0 = $1 sslope = $2 ii=0 if (sslope<0) { sslope *= -1 ii=1 } ttr = $3 ddel1=$4 vv1 = vv0 + sslope*ttr/2 mycmd2a.resize(ddel1/dt) mycmd2a.fill(vv0) mycmd2b.indgen(vv0, vv1, dt*sslope) mycmd2c.indgen(vv0,vv1,dt*sslope) mycmd2d.resize(ddel1/dt) mycmd2d.fill(vv0) mycmd2c.reverse() mycmd2.resize(0) mycmd2.append(mycmd2a,mycmd2b,mycmd2c,mycmd2d) if (ii==1) { mycmd2.sub(vv0) mycmd2.mul(-1) mycmd2.add(vv0)}}// I can invoke mkbirampd() with all 4 arguments,// or I can change a single "constant" (V0, SLOPE, TR, or HOLD)// and then invoke simple2d() with no arguments.proc simple2del() { mkbiramp1d(RSTRT1, SLOPE1, TR, HOLD) mkbiramp2d(RSTRT2, SLOPE2, TR, HOLD)}