begintemplate HIPPCell

ndend1=3
ndend2=3
ndend3=3
ndend4=3

public  pre_list, connect2target, subsets, is_art, is_connected
public vbc2gc, vmc2gc, vhc2gc, vgc2bc, vbc2bc, vmc2bc, vhc2bc, vgc2mc, vbc2mc, vmc2mc, vhc2mc, vgc2hc, vmc2hc
public soma, hcdend1, hcdend2, hcdend3, hcdend4
create soma, hcdend1[ndend1], hcdend2[ndend2], hcdend3[ndend3], hcdend4[ndend4]
public all, pdend, ddend
objref pre_list
nst=10

objectvar stim[nst]
double stimdur[nst], stimdel[nst], stimamp[nst]
public stim, stimdur, stimamp, stimdel


proc init() {
	pre_list = new List()
	subsets()
	temp()
	synapse()
}

objref all, pdend, ddend

proc subsets() { local i
	objref all, pdend, ddend
	all = new SectionList()
		soma all.append()
		for i=0, 2 hcdend1 [i] all.append()
		for i=0, 2 hcdend2 [i] all.append()
		for i=0, 2 hcdend3 [i] all.append()
		for i=0, 2 hcdend4 [i] all.append()

	pdend  = new SectionList()
		hcdend1 [0] pdend.append()
		hcdend2 [0] pdend.append()
		hcdend3 [0] pdend.append()
		hcdend4 [0] pdend.append()

	ddend  = new SectionList()
		for i=1, 2 hcdend1 [i] ddend.append()
		for i=1, 2 hcdend2 [i] ddend.append()
		for i=1, 2 hcdend3 [i] ddend.append()
		for i=1, 2 hcdend4 [i] ddend.append()
}

proc temp() {

	soma {nseg=1 L=20 diam=10} // changed L & diam
		
	hcdend1 [0] {nseg=1 L=75 diam=3}
	hcdend1 [1] {nseg=1 L=75 diam=2}
	hcdend1 [2] {nseg=1 L=75 diam=1}

	hcdend2 [0] {nseg=1 L=75 diam=3}
	hcdend2 [1] {nseg=1 L=75 diam=2}
	hcdend2 [2] {nseg=1 L=75 diam=1}
 		 
	hcdend3 [0] {nseg=1 L=50 diam=3}
	hcdend3 [1] {nseg=1 L=50 diam=2}
	hcdend3 [2] {nseg=1 L=50 diam=1}
	
	hcdend4 [0] {nseg=1 L=50 diam=3}
	hcdend4 [1] {nseg=1 L=50 diam=2}
	hcdend4 [2] {nseg=1 L=50 diam=1}	

    
	forall {
		insert ccanl
		   catau_ccanl = 10
		   caiinf_ccanl = 5.e-6
		
		insert borgka
		   gkabar_borgka=0.0008
		
		insert nca  // HAV-N- Ca channel
		   gncabar_nca=0.0  //0005  check to modify- original 0.004
		
		insert lca
		   glcabar_lca=0.0015
		
		insert gskch
		   gskbar_gskch=0.003
		
		insert cagk
		   gkbar_cagk=0.003
		
		insert hyperde3
		   ghyfbar_hyperde3=0.000015
		   ghysbar_hyperde3=0.000015
	}

	soma {
		insert ichan2  //ildikos ichan
		   gnatbar_ichan2=0.2  //original 0.030 to .055 
		   gkfbar_ichan2=0.006  //original 0.015
		   gl_ichan2 = 0.000036
		   cm=1.1
	} 

	forsec pdend {
		insert ichan2
		   gnatbar_ichan2=0.2  //original 0.015
		   gkfbar_ichan2=0.006
		   gl_ichan2 = 0.000036
		   cm=1.1
	}
		
	forsec ddend {
		insert ichan2
		   gnatbar_ichan2=0.0
		   gkfbar_ichan2=0.00
		   gl_ichan2 = 0.000036
		   cm=1.1
	}

	forall {
		Ra=100
	}
	forall {
		enat = 55 
		ekf = -90 
		ek=-90  
		esk=-90 
		elca=130
		el_ichan2 =-70.45	
		ehyf=-40 
		ehys=-40
		cao_ccanl=2 
	}  // make catau slower70e-3 	cao=2 cai=50.e-6 


	connect hcdend1[0](0), soma(1)
	connect hcdend2[0](0), soma(1)
	connect hcdend3[0](0), soma(0)
	connect hcdend4[0](0), soma(0)
	for i=1,2 {
		connect hcdend1[i](0), hcdend1[i-1](1)
	}
	for i=1,2 {
		connect hcdend2[i](0), hcdend2[i-1](1)
	}
	for i=1,2 {
		connect hcdend3[i](0), hcdend3[i-1](1)
	}
	for i=1,2 {
		connect hcdend4[i](0), hcdend4[i-1](1)
	}


//for i=0,0 {
//stimdel[i]=500
//stimdur[i]=500
//stimamp[i]=0.1

/* 0.4 stim when we want the cell to fire with regular spikes */

//soma stim[i] = new IClamp(0.5)
//stim.del[i]=stimdel[i]
//stim.dur[i]=stimdur[i]
//stim.amp[i]=stimamp[i]
//}
}

objref syn_  
proc synapse() {

	hcdend1 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>BC		0
	syn_.tau1 = .3	syn_.tau2 = .6	syn_.e = 0
	pre_list.append(syn_)

	hcdend2 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>BC		1
	syn_.tau1 = .3	syn_.tau2 = .6	syn_.e = 0
	pre_list.append(syn_)

	hcdend3 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>BC		2
	syn_.tau1 = .3 syn_.tau2 = .6	syn_.e = 0
	pre_list.append(syn_)

	hcdend4 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>BC		3
	syn_.tau1 = .3	syn_.tau2 = .6	syn_.e = 0
	pre_list.append(syn_)

	hcdend1 [1] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to mid dend similar to CA3>int Aaron	4
	syn_.tau1 = .9	syn_.tau2 = 3.6	syn_.e = 0 //*** Assumed data at physio temp
	pre_list.append(syn_)

	hcdend2 [1] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to mid dend similar to CA3>int Aaron	5
	syn_.tau1 = 0.9	syn_.tau2 = 3.6	syn_.e = 0 //*** Assumed data at physio temp
	pre_list.append(syn_)

	hcdend3 [1] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to mid dend similar to CA3>int Aaron	6
	syn_.tau1 = 0.9	syn_.tau2 = 3.6	syn_.e = 0  //*** Assumed data at physio temp
	pre_list.append(syn_)

	hcdend4 [1] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to mid dend similar to CA3>int Aaron	7
	syn_.tau1 = 0.9		syn_.tau2 = 3.6 	syn_.e = 0  //*** Assumed data at physio temp
	pre_list.append(syn_)

	soma syn_ = new Exp2Syn(0.5)		// GABA-A septum					8
    	syn_.tau1 = 1
    	syn_.tau2 = 8
    	syn_.e = -75
    	pre_list.append(syn_)	

	
// Total of 8 synapses 	0-3 GC; 	4-7 MC;		8 septum	
}

obfunc connect2target() { localobj nc //$o1 target point process, optional $o2 returned NetCon
  	soma nc = new NetCon(&v(1), $o1)
  	nc.threshold = -10
  	if (numarg() == 2) { $o2 = nc } // for backward compatibility
  	return nc
}

func is_art()  { return 0 }


endtemplate HIPPCell