/* Current clamp simulation of dentate gyrus basket cell from Joerg Geiger and Peter Jonas     */
/* See Geiger et al., Neuron 18, 1009-1023, 1997                            */
/* Cell "GCBC0712"                                                          */ 
/* NEURON 3.0 file by Arnd Roth                                             */
/* currentclamp.hoc    Version 1.0 for nrniv       15.3.1996                */
/* ------------------------------------------------------------------------ */
/* usage: special currentclamp.hoc -                                        */
/* compile special first: nrnivmodl                                         */
/* line above modified to reflect compilation taking place in dir with files - tmm 10/02 */
load_file("nrngui.hoc")		/* updates file to nrn 5 10/25/2002 TMM */

xopen("stdRun.hoc")             /* load the standard NEURON hoc library */

/* initial parameters */
t = 0                           /* simulation starts at t = 0 ms */
dt = 0.25                      /* orig simulation time step = 0.005 ms */
steps_per_ms = 4		// controls number of graphed points tmm 11/19/02
tstop = 43                      /* orig simulation ends at t = 25 ms */
Vrest = -70                     /* resting potential, mV */
axialresist = 150               /* axial resistivity in ohm*cm */
membraneresist =10000           /* membrane resistivity in ohm*cm^2 */
membranecap = 0.8               /* membrane capacity in uF/cm^2 */

xopen("GCBC0712_6.nrn")         /* load the description of the morphology */
forall {insert pas g_pas=1/membraneresist e_pas=Vrest}
forall {v=Vrest Ra=axialresist cm=membranecap}
topology()                      /* draw an ascii dendrogram */

file_use = 0

proc stdinit() {                /* customize some functions from stdRun.hoc */
	realtime=0 startsw()
	init()
	initPlot()
	if (file_use) {
		wopen("outfile.1")
		fprint("%12s %12s %12s\n","time/ms", "soma/mV", "dend/mV")
	}
}

proc advance() {
	fadvance()
	if (file_use) {
		if (t < tstop-dt) {fprint("%12.4f %12.4f %12.4f\n", t, soma.v(0.5), dend4_11211.v(1))}
	}
	/* write output to file */
	/* t in ms, voltage at soma.v(0.5) in mV, voltage at dend4_11211.v(1), spacing = dt */
}

/* set up various GUI facilities */

// load_proc("nrnmainmenu")	// Duplicates nrngui.hoc's main menu TMM 11/19/02
// nrnmainmenu()

// use box'es to organize

objref outerbox1, outerbox2, innerbox1, innerbox2
outerbox1 = new VBox()
outerbox1.intercept(1)

  innerbox1 = new HBox()

  innerbox1.intercept(1)

    load_proc("nrncontrolmenu")
    nrncontrolmenu()

    xpanel("crude fig8d")
    xlabel("The below will execute")
    xlabel("an approximate")
    xlabel("version of figure 8d")
    xbutton("Estimate of fig 8d","load_file(\"fig8d.hoc\")")
    xlabel("For more accuracy")
    xlabel("modify fig8d.hoc")
    xlabel("to decrease the")
    xlabel("step size (dt), ")
    xlabel("and step size of ")
    xlabel("offset which is")
    xlabel("currently set to 4")
    xpanel()

    load_template("MenuExplore")
    objectvar menu_explore
    menu_explore = new MenuExplore()
    
    load_template("PointProcessLocator")
    objectvar pplocator[4]
    
    innerbox1.intercept(0)
  innerbox1.map()

  innerbox2 = new HBox()

  innerbox2.intercept(1)
    /* parameters of synapses */

    objectvar mySynapse[3]

	access dend2_1
	mySynapse[0] = new syn2(1)
	mySynapse[0].onset = 1.0      /* ms */
	mySynapse[0].tau0 = 0.08      /* ms */
	mySynapse[0].tau1 = 0.20       /* ms */
        mySynapse[0].e = -5           /* mV */
	mySynapse[0].gmax = 0.008     /* umho */
	pplocator[0] = new PointProcessLocator(mySynapse[0])

	access dend2_12
	mySynapse[1] = new syn2(0.6375)
	mySynapse[1].onset = 1.0      /* ms */
	mySynapse[1].tau0 = 0.08      /* ms */
	mySynapse[1].tau1 = 0.20       /* ms */
        mySynapse[1].e = -5           /* mV */
	mySynapse[1].gmax = 0.008     /* umho */
	pplocator[1] = new PointProcessLocator(mySynapse[1])

	access dend3_1
	mySynapse[2] = new syn2(0.95)
	mySynapse[2].onset = 1.0      /* ms */
	mySynapse[2].tau0 = 0.08      /* ms */
	mySynapse[2].tau1 = 0.20       /* ms */
        mySynapse[2].e = -5           /* mV */
	mySynapse[2].gmax = 0.008     /* umho */
	pplocator[2] = new PointProcessLocator(mySynapse[2])

	access soma                   /* current clamp at the center of soma */
	objectvar myStimulus
	myStimulus = new IClamp(0.5)
	myStimulus.del = 5    /* ms */
	myStimulus.dur = 0.5  /* ms */
	myStimulus.amp = 0.0  /* nA */
	pplocator[3] = new PointProcessLocator(myStimulus)

	innerbox2.intercept(0)
  innerbox2.map()
  outerbox1.intercept(0)
outerbox1.map()

outerbox2 = new VBox()
outerbox2.intercept(1)

    /* window for plotting EPSPs */

    objectvar save_window_
    objectvar scene_vector_[1]
    {
    save_window_ = new Graph(0)
    save_window_.size(0,40,-75,-45)
    save_window_.label(0.81, 0.01, "ms")
    save_window_.label(0.01, 0.81, "mV")
    scene_vector_[0] = save_window_
    {save_window_.view(0, -70, 40, 5, 540, 300, 300, 220)}
    graphList[0].append(save_window_)
    save_window_.save_name("graphList[0].")
    save_window_.addexpr("dend4_11211.v(1)", 3, 1, 4, -66)
    save_window_.addexpr("soma.v(0.5)", 1, 1, 4, -67)
    }

    /* draw the morphology of the cell */
    
    objectvar s
    s = new PlotShape()
    flush_list.append(s)
    s.save_name("flush_list.")
    
    outerbox2.intercept(0)

outerbox2.map()