load_file("nrngui.hoc")

load_file("geo5038804.hoc")
numbasal  = 52
numapical = 70
numuser5  = 49

load_file("biophys.hoc")
load_file("synapses.hoc")
load_file("efheader.hoc")



tstop=500

proc init() {

  t=0

  
  finitialize(Vrest)

	forall {
		v = Vrest
		if(ismembrane("nax") || ismembrane("na3")) {
			ena=55
		}
		if(ismembrane("kdr") || ismembrane("kap") || ismembrane("kad")) {
			ek=-90
		}
		if(ismembrane("hd")) {
			ehd_hd=-30
		}
	}

	finitialize(Vrest)
	fcurrent()

	forall {
		for(x) {
			if(ismembrane("na3") || ismembrane("nax")) {
				e_pas(x)=v(x)+(ina(x)+ik(x))/g_pas(x)
			}
			if(ismembrane("hd")) {
				e_pas(x)=e_pas(x)+i_hd(x)/g_pas(x)
			}
		}
	}

	for i = 0, nsyn-1 {
  		st[i].seed(114)
	}

}



load_file("voltage.ses")
objref vp
vp = save_window_
vp.exec_menu("Keep Lines")
proc sim() {
  vp.erase_all()

	vp.label(0.949956, 0.931495, "no EF", 2, 1, 0, 0, 1)
	vp.label(0.950834, 0.878114, "EF", 2, 1, 0, 0, 2)
  vp.brush(2)
  vp.color(1)
  vp.addvar("", "v(0.5)")
  setstim(0, 1200, 50, 50, 0)
  changefield(100, 90, 90)
  run()

  vp.color(2)
  vp.addexpr("", "v(0.5)")
  setstim(0, 1200, 50, 50, 40)
  changefield(100, 90, 90)
  run()

}


xpanel("electric field sim")
xbutton("Run sims", "sim()")
xpanel(255,672)