//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This simulation was used in an article at Frontiers in Computational Neuroscience,
// special issue on Structure, dynamics and function of brains:
//  Citation: Neymotin SA, Lee H, Park E, Fenton AA and Lytton WW (2011). Emergence of physiological oscillation
//  frequencies in a computer model of neocortex. Front. Comput. Neurosci. 5:19. doi: 10.3389/fncom.2011.00019
//  Received: 19 Oct 2010; Accepted: 01 Apr 2011. 
//  Edited by:   Ad Aertsen, Albert Ludwigs University, Germany
//  Reviewed by: Imre Vida, University of Glasgow, UK 
//               Michael Schmuker, Freie UniverstiƤt Berlin, Germany 
//               Maxim Bazhenov, University of California, USA 
// 
// article available at:
//  http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/abstract
//
// for help with simulation/analysis routines: contact email: samn at neurosim dot downstate dot edu
//
// note that paper used matlab's pmtm and fft functions which are only commercially available, so not
// used in this demonstration. some differences in spectral output visible depending on which spectral
// methods employed. see readme.txt and getpsd function below for more information
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// load files for running NEURON + analysis, etc.
load_file("nrngui.hoc")
xopen("./setup.hoc")
xopen("./nrnoc.hoc")
load_file("init.hoc")

usens = 1 // if set to 1 uses NetStims (faster to load, less memory). usens set to 0 for paper
mytstop = 20e3 // sets duration of simulation in milliseconds

// load sim-related files
load_file("nqsnet.hoc")
load_file("network.hoc")
print "setting up external inputs...please wait..."
load_file("params.hoc")
load_file("run.hoc")
load_file("nload.hoc")

objref myg[4] // Graph objects

load_file("finish_run.hoc")

xpanel("Neymotin et al. 2011")
  xbutton("long run","{mytstop=20e3 finish_run()}")
  xbutton("short run(auto-launch demo)","{mytstop=0.1e3 tstop=mytstop finish_run()}")
xpanel()