neurenv/stim.hoc
2026-07-11 18:20:01 -04:00

68 lines
1.7 KiB
Plaintext

// $Id: stim.hoc,v 1.5 2009/02/24 00:55:27 ted Exp ted $
// Create a rectangular stimulus waveform and set up the Ve scaling
// Modified by Zhen Qi
// default values
DEL = 0 // ms
DUR = 0.1 // ms
SCA = -70 // unitless
// with fixed dt and adaptive integration
objref stim_scale, stim_time
stim_scale = new Vector()
stim_time = new Vector()
proc stim_waveform() {
// this uses interpolated play
// index 0 1 2 3 4 5
// stim vec 0, 0, 1, 1, 0 0
// time vec 0, DEL, DEL, DEL+DUR, DEL+DUR, DEL+DUR+1
// really 0, $1, $1, $1+$2, $1+$2, $1+$2+1
// first the stim vector
stim_scale.resize(6)
stim_scale.fill(0)
stim_scale.x[2]=1
stim_scale.x[3]=1
stim_scale.mul($3)
// now the time vector
stim_time.resize(6)
stim_time.x[1]=$1
stim_time.x[2]=$1
stim_time.x[3]=$1+$2
stim_time.x[4]=$1+$2
stim_time.x[5]=$1+$2+1
}
ATTACHED__ = 0
proc attach_stim() {
// since stim_xtra is GLOBAL, we only need to specify Vector.play()
// for one instance of xtra, i.e. at just one internal node
// of only one section that contains xtra
forall { // check each section to find one that has xtra
if (ATTACHED__ == 0) { // don't bother if stim is already attached to something
if (ismembrane("xtra")) {
stim_scale.play(&stim_xtra, stim_time, 1) // "interpolated" play
ATTACHED__ = 1
}
}
}
}
proc setstim() {
del = $1
dur = $2
sca = $3
stim_waveform(del, dur, sca)
attach_stim()
}
xpanel("Extracellular Stimulus Current", 0)
xvalue("del (ms)", "DEL", 1, "setstim(DEL,DUR,SCA)", 0, 1)
xvalue("dur (ms)", "DUR", 0.1, "setstim(DEL,DUR,SCA)", 0, 1)
xvalue("scale", "SCA", 1, "setstim(DEL,DUR,SCA)", 0, 1)
xpanel(0,560)