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

{load_file("../cells/olm_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, Cell4, Cell5
objectvar 	syn1, syn2, syn3, syn4, syn5
objectvar   nclist, stim, sn1, sn2, sn3, sn4, sn5
objectvar   clamp1, clamp2, clamp3, clamp4, clamp5
objref 		sn1, i1_ca1, i2_ca1, i3_ca1, i4_ca1, i5_ca1
objref      FILE1, FILE2, FILE3, FILE4, FILE5
strdef 		tmp1, tmp2, tmp3, tmp4, tmp5


Cell1 = new OLMCell()  // template for synapse CA3 to OLM
Cell2 = new OLMCell()  // template for synapse PC to OLM
Cell3 = new OLMCell()  // template for synapse BSC to OLM
Cell4 = new OLMCell()  // template for synapse OLM to OLM
Cell5 = new OLMCell()  // template for synapse VIPCR to OLM



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 CA3 synapse to OLM at dend1 dendrite
//weigth_CA3toOLM 
w1 = 1.05e-4

Cell1.dend1  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 PC synapse to OLM at dend1 dendrite
//weigth_PCtoOLM 
w2 = 2.0e-4

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



//making BSC synapse to OLM at dend1 dendrite
//weigth_BSCtoOLM 
w3 = 2.0e-5*factor2

Cell3.dend1  syn3 = new MyExp2Syn(0.5) 
syn3.tau1 = 1.0
syn3.tau2 = 8.0
syn3.e 	  = -75
//making the netcon
sn3	= new NetCon(stim, syn3, -20, 1, w3)



//making OLM synapse to OLM at dend1 dendrite
//weigth_OLMtoOLM 
w4 = 1.2e-3*factor2

Cell4.dend1  syn4 = new MyExp2Syn(0.5) 
syn4.tau1 = 0.25
syn4.tau2 = 7.50
syn4.e 	  = -75
//making the netcon
sn4	= new NetCon(stim, syn4, -20, 1, w4)



//making VIPCR synapse to OLM at soma
//weigth_VIPCRtoOLM 
w5 = 7.0e-4*factor2*5.0

Cell5.soma   syn5 = new MyExp2Syn(0.5) 
syn5.tau1 = 1.0
syn5.tau2 = 8.0
syn5.e 	  = -75
//making the netcon
sn5	= new NetCon(stim, syn5, -20, 1, w5)



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


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

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

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

clamp4.dur[0]= 2000			
clamp4.amp[0]= -73.5

clamp5.dur[0]= 2000			
clamp5.amp[0]= -73.5


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


//recording
i1_ca1.record(&clamp1.i)
i2_ca1.record(&clamp2.i)
i3_ca1.record(&clamp3.i)
i4_ca1.record(&clamp4.i)
i5_ca1.record(&clamp5.i)


run()

FILE1 = new File()
sprint(tmp1, "SynapticProperties/CA3toOLM_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/PCtoOLM_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/BSCtoOLM_i_rec_soma.txt")
FILE3.wopen(tmp3)
for i=0, i3_ca1.size()-1 {FILE3.printf("%f\n",i3_ca1.x[i])}
FILE3.close()	

FILE4 = new File()
sprint(tmp4, "SynapticProperties/OLMtoOLM_i_rec_soma.txt")
FILE4.wopen(tmp4)
for i=0, i4_ca1.size()-1 {FILE4.printf("%f\n",i4_ca1.x[i])}
FILE4.close()	

FILE5 = new File()
sprint(tmp5, "SynapticProperties/VIPCRtoOLM_i_rec_soma.txt")
FILE5.wopen(tmp5)
for i=0, i5_ca1.size()-1 {FILE5.printf("%f\n",i5_ca1.x[i])}
FILE5.close()