objectvar save_window_, rvp_
objectvar scene_vector_[5]
objectvar ocbox_, ocbox_list_, scene_, scene_list_
objref sh0,sh1,sh2

{ocbox_list_ = new List()  scene_list_ = new List()}
//{pwman_place(22,482)}
{
sh0 = new Graph(0)
sh0.size(0,100,-90,40)
scene_vector_[2] = sh0
{sh0.view(0,-100, 110, 150, 5, 90, 300, 240)}
graphList[0].append(sh0)
sh0.save_name("graphList[0].")
sh0.addexpr("v(.5)", 1, 1, 1, 0, 2)
sh0.addexpr("mbSec.sec.v(1)", 2, 1, 1, 0, 2)
}
sh0.exec_menu("Erase Axis")
sh0.xaxis(0,100,-100,5,0,0,1)
sh0.yaxis(-80,40,-1,6,0,0,1)
{
xpanel("RunControl", 0)
//v_init = -73.65
xvalue("Init","v_init", 1,"init()", 1, 1 ) 
//xbutton("Init","finitialize(v_init)") 
xbutton("Init & Run","run()")
xbutton("Stop","stoprun=1")
runStopAt = 5
runStopIn = 10
xvalue("Continue for","runStopIn", 1,"{continuerun(t + runStopIn) stoprun=1}", 1, 1 )
xbutton("Single Step","steprun()")
t = 0
xvalue("t","t", 2 )
tstop = 75
xvalue("Tstop","tstop", 1,"tstop_changed()", 0, 1 )
dt = 0.00625
xvalue("dt","dt", 1,"setdt()", 0, 1 )
steps_per_ms = 20
xvalue("Points plotted/ms","steps_per_ms", 1,"setdt()", 0, 1 )
realtime = 0
xvalue("Real Time","realtime", 0,"", 0, 1 )
xpanel(421,21)
}
//{
//sh1 = new PlotShape(0)
//sh1.size(-386.7,313.3,-150.382,1048.64)
//sh1.variable("v")
//scene_vector_[3] = sh1
//{sh1.view(-386.7, -150.382, 700, 1199.02, 431, 30, 325, 570)}
//fast_flush_list.append(sh1)
//sh1.save_name("fast_flush_list.")
//}
//{
//sh2= new PlotShape(0)
//sh2.size(-792.112,571.207,-154.611,1031.33)
//sh2.variable("cai")
//scene_vector_[4] = sh2
//{sh2.view(-792.112, -154.611, 1363.32, 1185.94, 5, 480, 300, 260)}
//fast_flush_list.append(sh2)
//sh2.save_name("fast_flush_list.")
//}
objectvar scene_vector_[1]
{doNotify()}

//sh1.exec_menu("Show Diam")
//sh1.exec_menu("Shape Plot")

//sh2.exec_menu("Show Diam")
//sh2.exec_menu("Shape Plot")
//sh2.scale(0,3)


proc figBAP() {
  st.amp   = $1 //1.9
  syn.imax =  0
  print "Somatic current injection is ", st.amp, " nA"
  print "Dendritic EPSP like current injection is ", syn.imax, " nA"
  print "" }

proc figEPSP() {
  st.amp   = 0
  syn.imax = $1 //0.6
  print "Somatic current injection is ", st.amp, " nA"
  print "Dendritic EPSP like current injection is ", syn.imax, " nA"
  print "" }

proc figCa() {
  st.amp   = 0
  syn.imax = $1 //1.7
  print "Somatic current injection is ", st.amp, " nA"
  print "Dendritic EPSP like current injection is ", syn.imax, " nA"
  print "" }

proc figBAC() {
  st.amp   = $1 //1.9
  syn.imax = $2 //0.3
  print "Somatic current injection is ", st.amp, "nA"
  print "Dendritic EPSP like current injection is ", syn.imax, "nA"
  print "" }
  
proc give_delay(){
    st.del = start_at + 1.1
    syn.onset = start_at + 3.1
    print "Onset delay is ", start_at, "ms" 
    print ""}  

xpanel("A Model Of BAC firing")
BAP_current = 2.0
xvalue("Backpropagating AP","BAP_current", 1,"figBAP(BAP_current)",0,1)
EPSP_inj = 0.315
xvalue("EPSP","EPSP_inj", 1,"figEPSP(EPSP_inj)",0,1)
CASP_inj = 1.7
xvalue("Ca spike","CASP_inj",1, "figCa(CASP_inj)",0,1)
xbutton("BAC firing","figBAC(BAP_current,EPSP_inj)")
start_at = 2
xvalue("delay","start_at",1, "give_delay()")
xpanel(421,395)

sh0.color(2)
sh0.label(0.7,0.7,"Dendrite@MB")
sh0.color(1)
sh0.label(0.8,0.8,"Soma")

//sh1.color(1)
//sh1.label(0.4,0.95,"Membrane Voltage")

//sh2.color(1)
//sh2.label(0.22,0.95,"Intracellular Calcium concentration")
//sh2.label(0.22,0.88,"                 (arbitrary units)")

syn.imax=0
st.amp=0