{load_file("nrngui.hoc")}  // load the GUI and standard run libraries

{load_file("../cells/vipcr_cell.hoc")} //load axoaxonic cell

{xopen("kblock.hoc")} //execute open.load_file just reads

strdef temp_mkdir, temp_dir
// Create the directory
sprint(temp_dir, "SynapticProperties/")
sprint(temp_mkdir, "mkdir -p %s", temp_dir)
system(temp_mkdir)

objectvar 	Cell1, Cell2, Cell3
objectvar 	syn1, syn2, syn3
objectvar   nclist, stim, sn1, sn2, sn3
objectvar   clamp1, clamp2, clamp3
objref 		sn1, i1_ca1, i2_ca1, i3_ca1
objref      FILE1, FILE2, FILE3
strdef 		tmp1, tmp2, tmp3


Cell1 = new VIPCRCell()  // synapse from EC to VIPCR
Cell2 = new VIPCRCell()  // synapse from CA3 to VIPCR
Cell3 = new VIPCRCell()  // synapse from PC to VIPCR


stim = new NetStim (0.5)
stim.interval 	= 1
stim.number		= 1
stim.start		= 900


// Time parameters///////////////////////////////
tstop = 2000 //stop time in ms
steps_per_ms = 10
dt    = 0.1
n     = tstop*steps_per_ms



//Vclamp for AMPA & GABAA
print "Vclamp"
factor2 = 1.0

//making EC synapse to VIPCR at lmM1 dendrite
//weigth_ECtoVIPCR 
w1 = 3.0e-4

Cell1.lmM1  syn1 = new MyExp2Syn(0.5) 
syn1.tau1 = 2.0
syn1.tau2 = 6.3
syn1.e 	  = 0
//making the netcon
sn1	= new NetCon(stim, syn1, -20, 1, w1)



//making CA3 synapse to VIPCR at radMed1 dendrite
//weigth_CA3toVIPCR 
w2 = 1.05e-4

Cell2.radMed1 syn2 = new MyExp2Syn(0.5)
syn2.tau1 = 2.0
syn2.tau2 = 6.3
syn2.e    = 0
//making the netcon 
sn2	= new NetCon (stim,syn2,-20, 1, w2)  //..threshold,delay,weight)



//making PC synapse to VIPCR at oriProx1 dendrite
//weigth_PCtoVIPCR 
w3 = 5.0e-4

Cell3.oriProx1  syn3 = new MyExp2Syn(0.5) 
syn3.tau1 = 0.5
syn3.tau2 = 3.0
syn3.e 	  = 0
//making the netcon
sn3	= new NetCon(stim, syn3, -20, 1, w3)


//Vclamp at soma
Cell1.soma clamp1 = new VClamp(0.5)  
Cell2.soma clamp2 = new VClamp(0.5)  
Cell3.soma clamp3 = new VClamp(0.5)   


clamp1.dur[0]= 2000			//duration of clamp in ms
clamp1.amp[0]= -70       //voltage clamp amplitude / near to Vrest

clamp2.dur[0]= 2000			
clamp2.amp[0]= -70

clamp3.dur[0]= 2000			
clamp3.amp[0]= -70


//cutting potasium
//k_block()
//making the vectors	
i1_ca1 = new Vector(n)
i2_ca1 = new Vector(n)
i3_ca1 = new Vector(n)


//recording
i1_ca1.record(&clamp1.i)
i2_ca1.record(&clamp2.i)
i3_ca1.record(&clamp3.i)

run()

FILE1 = new File()
sprint(tmp1, "SynapticProperties/ECtoVIPCR_i_rec_soma.txt")
FILE1.wopen(tmp1)
for i=0, i1_ca1.size()-1 {FILE1.printf("%f\n",i1_ca1.x[i])}
FILE1.close()

FILE2 = new File()
sprint(tmp2, "SynapticProperties/CA3toVIPCR_i_rec_soma.txt")
FILE2.wopen(tmp2)
for i=0, i2_ca1.size()-1 {FILE2.printf("%f\n",i2_ca1.x[i])}
FILE2.close()	

FILE3 = new File()
sprint(tmp3, "SynapticProperties/PCtoVIPCR_i_rec_soma.txt")
FILE3.wopen(tmp3)
for i=0, i3_ca1.size()-1 {FILE3.printf("%f\n",i3_ca1.x[i])}
FILE3.close()