celsius=14

load_file("nparams.hoc")
load_file("custominit.hoc")
load_file("cell_d.hoc")

cell_nr = cell_nr-1

// PHASIC CELL
if(cell_type == 1){
    rho=vp_rho.x(cell_nr)
    Le=vp_Le.x(cell_nr)
    CS=vp_CS.x(cell_nr) 
    GS=vp_GS.x(cell_nr)
    GSh=vp_GSh.x(cell_nr)
    GNa=p_GNa
    GK=p_GK
    GKCa=p_GKCa
    tn=p_tn
    tca=p_tca
    N=p_N 
    GKd=vp_GKd.x(cell_nr)
    tfac=p_tfac
    El=p_El
    Els=p_Els
    bn=p_bn
    gn=p_gn
}

// TONIC CELL
if(cell_type == 2){
    rho=vt_rho.x(cell_nr)
    Le=vt_Le.x(cell_nr)
    CS=vt_CS.x(cell_nr) 
    GS=vt_GS.x(cell_nr)
    GSh=vt_GSh.x(cell_nr)
    GNa=vt_GNa.x(cell_nr)
    GK=vt_GK.x(cell_nr)
    GKCa=vt_GKCa.x(cell_nr)
    tn=vt_tn.x(cell_nr)
    tca=vt_tca.x(cell_nr)
    N=t_N 
    GKd=t_GKd
    tfac=t_tfac
    El=t_El
    Els=t_Els
    bn=t_bn
    gn=t_gn
}

objectvar currcell
currcell = new cell(N, rho, Le, CS, GS, GSh, GNa, GK, GKd, tfac, GKCa, El, Els, bn, gn, tn, tca)

access currcell.soma

objref stim
objref stimvec, f, ivec, tvec
objectvar window



if(stim_type == 1){

tstop = 1200

stim = new IClamp(0.5)
stim.del = 100
stim.dur = 1000
stim.amp = amp

window = new Graph(0)
window.size(0,1200,-80,40)
window.view(0, -80, 1200, 120, 325, 127, 699.84, 250.24)
graphList[0].append(window)
window.addexpr("v(.5)", 1, 1, 0.8, 0.9, 2)

}

if(stim_type == 2){

dt = 0.1
steps_per_ms = 1/dt // or steps_per_ms = 1/dt/N if you prefer 1 point per N fadvances

tstop = 30000

stim = new IClamp(0.5)
stim.del = 0
stim.dur = tstop
stim.amp = 0

f = new File("zapstim.txt")
f.ropen()
stimvec = new Matrix()
stimvec.scanf(f)
tvec = stimvec.getcol(0)
ivec = stimvec.getcol(1)

ivec = ivec.mul(amp)

// third argument == 1 means play with interpolation
ivec.play(&stim.amp, tvec, 1)

window = new Graph(0)
window.size(0,30000,-90,40)
window.view(0, -90, 30000, 120, 325, 127, 699.84, 250.24)
graphList[0].append(window)
window.addexpr("v(.5)", 1, 1, 0.8, 0.9, 2)

}


run()