load_file("nrngui.hoc")
load_file("morphology_mechanisms_CaTransients.hoc")

xopen("CaTransientsDisplay.ses")

celsius = 34
Dt = 0.02
steps_per_ms = 1/Dt
tstop = 5000
v_init = -90

objref pulse1, pulse2, pulse3, pulse4

objref InjectMatrix

objref InjectFile, InjectVector0, InjectVector
InjectFile = new File("CaSpikeProtocol.dat")
InjectFile.ropen()

InjectMatrix = new Matrix()
InjectMatrix.scanf(InjectFile,500001,2)
InjectVector = new Vector(500001)
for(i=0; i<InjectVector.size-1; i = i+1){
        if(i>=InjectMatrix.nrow){
                InjectVector.x[i] = -95
        }else{
                InjectVector.x[i]=InjectMatrix.x[i][1]
        }
}

proc init_VClamp() {
        access dend[0]
        pulse1 = new SEClamp(0.5)
        pulse1.dur1 = tstop
        InjectVector.play(&pulse1.amp1,dt)
}
proc init_VClamp1() {
        access dend[1]
        pulse2 = new SEClamp(0.5)
        pulse2.dur1 = tstop
        InjectVector.play(&pulse2.amp1,dt)
}
proc init_VClamp2() {
        access dend[2]
        pulse3 = new SEClamp(0.5)
        pulse3.dur1 = tstop
        InjectVector.play(&pulse3.amp1,dt)
}
proc init_VClamp3() {
        access dend[3]
        pulse4 = new SEClamp(0.5)
        pulse4.dur1 = tstop
        InjectVector.play(&pulse4.amp1,dt)
}


finitialize()
init_VClamp()
init_VClamp1()
init_VClamp2()
init_VClamp3()
run()