spinepos = synpos

load_file("nrngui.hoc")
load_file("../../template/load_templates.hoc")


strdef accstr    // not confuse experimental variable bindings with neurophysiological variable bindings
objref econ                          // Create an experiment object
show_errs=1
debug_lev=1
econ=new ExperimentControl(show_errs,debug_lev)
econ.self_define(econ) 		// points the object at itself
econ.morphology_dir = "../../morphology/n123"                             // Setup morphology directory
econ.generic_dir = "../../experiment/spine"                                    // Setup directory with cell-setup file
econ.add_lib_dir("Terrence","../../lib")                                  // Setup directory with library functions 

if (unix_mac_pc() ==1 ) {
	econ.data_dir       = "data"                       // Define directory to save produced data 
	sprint(econ.syscmd, "mkdir -p %s", econ.data_dir)  // make the data directory
	system(econ.syscmd)
}

// Setup cell

neckW = 0.147
neckL = 0.667
headW = 0.519
headL = 0.519

econ.xopen_geometry_dependent("cell_+spine")              // load the raw cell morphology
econ.xopen_geometry_dependent("cell-analysis")     // load user-defined semantics on morphology 
cell_analysis(econ)
printf("Opening cell setup\n")
econ.xopen_generic("cell-setup")                   // load the cell-setup file (define specific 
printf("Opened. Setting up cell\n")                // channels, membrane properties etc)
cell_setup(econ)

// Set simulation parameters for the experiment 

econ.defvar("Simulation Control", "tstop", "30", "Defines when the simulation stops.")
econ.defvar("Simulation Control", "dt", "0.025", "Timestep") // 0.1 originally
econ.defvar("Simulation Control", "steps_per_ms", "40", "How many points are plotted per ms")
setdt()

nrnmainmenu()
access soma
// Initialize and run the experiment

finitialize(v_init)
fcurrent()