// init.hoc
// Olfactory bulb network model: initialisation file
// Andrew Davison, The Babraham Institute, 2000.

objref exptBox, ctrlBox
strdef filename
quitmodel = 0

exptBox = new VBox()
exptBox.intercept(1)
  xpanel("Experiments")
    xlabel("Choose an experiment:")
  
    xradiobutton("Figure1", "run_experiment(\"fig1\")")
    xradiobutton("Figure2", "run_experiment(\"fig2ace\")")

    xpanel()
    xpanel("Controls",1)
    xbutton("Quit","quit()")
    xpanel()
    exptBox.intercept(0)
    exptBox.map("Olfactory bulb network model",0,80,-1,-1)

proc run_experiment() {
  exptBox.unmap()
  ctrlBox = new VBox()
  ctrlBox.intercept(1)
    xpanel("Progress")
    xlabel("The network is being created. This may take some time.")
    xpanel()
  ctrlBox.intercept(0)
  ctrlBox.map("Olfactory bulb network model",0,80,-1,-1)
  xopen("mathslib.hoc")			// mathematical procedures
  print "Reading channel tables"
  xopen("tabchannels.hoc")		// channel tables
  sprint(filename,"parameters_%s.hoc",$s1)
  xopen(filename)                       // model parameters

  print "Reading mitral cell template"
  load_file("mitral.tem") 			// mitral cell template

  print "Reading parameters"

  print "Creating cells"
  xopen("bulb.hoc")			// model set-up
  print "Reading input procedures"

  print "Setting-up experiment"
  sprint(filename,"experiment_%s.hoc",$s1)
  xopen(filename)                       // which parameters to record
  ctrlBox.unmap()
  ctrlBox = new VBox()
  ctrlBox.intercept(1)
  xpanel("Instructions")
    xlabel("* To run the simulation, click on run fig _.")
    xlabel("* When the simulation is complete, go to matlab and run the figure name programm.")
    xlabel("* If you wish to run a different experiment, you will have")
    xlabel("  to quit NEURON and restart.")
  xpanel()
  xpanel("Controls",1)
    xbutton("Quit","quit()")
    xlabel(" ")
  xpanel()
  ctrlBox.intercept(0)
  ctrlBox.map("Olfactory bulb network model",0,80,-1,-1)
  
}