// 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("Figure1cde","run_experiment(\"fig1cde\")")
  xradiobutton("Figure1fg","run_experiment(\"fig1fg\")")
  xradiobutton("Figure2","run_experiment(\"fig2bdf\")")
  xradiobutton("Figure3","run_experiment(\"fig3\")")
  xradiobutton("Figure4","run_experiment(\"fig4\")")
  xradiobutton("Figure5","run_experiment(\"fig5\")")
  xradiobutton("Figure6","run_experiment(\"fig6\")")
  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 granule cell template"
  load_file("granule.tem")			// granule cell template


  xpanel("Instructions")
    xlabel("* Once you have set the parameters")
    xlabel("* To run the simulation, click on Run fig_ button")
    xlabel("* While the simulation is running,")
    xlabel("* You can close the graphes to make it faster")
    xlabel("* If you wish to run a different experiment,")
    xlabel("* you will have  to quit NEURON and restart.")
  xpanel(107,128)
  xpanel("Controls",1)
    xbutton("Quit","quit()")
  xpanel(107,378)
  ctrlBox.intercept(0)
  ctrlBox.map("Olfactory bulb network model",0,80,-1,-1)

  print "Reading parameters"

  print "Creating network"
  xopen("bulb.hoc")			// model set-up
 
  print "Setting-up experiment"
  sprint(filename,"experiment_%s.hoc",$s1)
  xopen(filename)                       // which parameters to record
  ctrlBox.unmap()
  ctrlBox = new VBox() 
  ctrlBox.intercept(1)

  print "Initialisation complete"
}