load_file("nrngui.hoc")



load_file("fig7a.ses")
forsec "axon" L=2000
load_file("fig7A_VperD.hoc")

steps_per_ms=20	// for plot function
dt = 0.025

// record traces in these variables for later graphing

objref axon_d_vec, axon_v_vec, time_vec	// distance and voltage vectors

vsize=tstop/dt+1
dvecsize = 3
axon_v_vec = new Vector()	// these will be taken from range var plots
axon_d_vec = new Vector()	// these will be taken from range var plots

time_vec=new Vector(vsize)		// this will just be recorded

// time_vec.record(&t)	// delete if not used

objref Box, tobj
strdef tstr

Box = new VBox()

objref isi_vec, snapshot_vec, g[4]

isi_vec = new Vector()

isi_vec.append(85, 100, 110, 0)	// the interspike intervals in ms
				// note in the last case, zero,
				// the second pulse is turned off
				// so this time is ignored.

snapshot_vec = new Vector()	// this holds the times that the
				// voltage along the axon is displayed
				// for each isi graph.

proc create_graph() {	// argument is
			// isi_vec index (index to relative time of 2nd excitatory 
			// pulse) to display voltage as a function of distance 
			// along the axon with
			
	g[$1] = new Graph(0)
	g[$1].exec_menu("Keep Lines")
	
	// set the pulse time onset to the isi from the passed index:
	
	AlphaSynapse[1].onset = AlphaSynapse[0].onset+isi_vec.x[$1]
	// print "additive term is ",isi_vec.x[$1]
	// print "onset time is ",AlphaSynapse[1].onset

	// select the appropriate set of times to record the voltages
	snapshot_vec = new Vector()

	if ($1==0) {
		snapshot_vec.append(3,4,6,7)
	} else if ($1==1) {
		snapshot_vec.append(3,6,9,12,15,18)
	} else if ($1==2) {
		snapshot_vec.append(3,6,9,12,15,18)
	} else if ($1==3) {
		snapshot_vec.append(3,6,9,12,15)
		AlphaSynapse[1].gmax=0	// the time was set to 0 which
					// is relative to the other pulse
					// given by AlphaSynapse[0].  Here
					// AlphaSynapse[1] is turned off so
					// that we may just pay attention to
					// AlphaSynapse[0].
	}
	
	init()
	stdinit()


	for i=0,snapshot_vec.size-1 {	// loop over the snapshot times
		// print "snapshot time will be ",AlphaSynapse[1].onset+snapshot_vec.x[i]
		continuerun(AlphaSynapse[1].onset+snapshot_vec.x[i])

		// move v(d) onto graph

		VvsDgraph.getline(-1, axon_d_vec, axon_v_vec)
		sprint(tstr," %d",snapshot_vec.x[i])
		axon_v_vec.label(tstr)

		axon_v_vec.line(g[$1],axon_d_vec,1+i,0)
	}
	g[$1].view(0, -80, 2000, 120, 602, 85, 150, 150)
}

stdrun_quiet = 1	// causes graphs to be ploted after run not during
Box.intercept(1)

  
    xpanel("fig 7Aa")
    xlabel("Fig 7Aa, ISI = 85ms")	// description
    xpanel()

    xpanel("7Aa")
    create_graph(0)
    xpanel()

    xpanel("fig 7Ab")
    xlabel("Fig 7Ab, ISI = 100ms")	// description
    xpanel()

    xpanel("7Ab")
    create_graph(1)
    xpanel()
     
    xpanel("fig 7Ac")
    xlabel("Fig 7Ac, ISI = 110ms")	// description
    xpanel()

    xpanel("7Ac")
    create_graph(2)
    xpanel()
    
    xpanel("fig 7Ad")
    xlabel("Fig 7Ad, ISI = infinity")	// description
    xpanel()

    xpanel("7Ad")
    create_graph(3)
    xpanel()
    
    /**/
Box.intercept(0)
Box.map("figure 7A",200,350,500,550)