begintemplate MossyCell

ndend1=4
ndend2=4
ndend3=4
ndend4=4

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, mcdend1, mcdend2, mcdend3, mcdend4
create soma, mcdend1[ndend1], mcdend2[ndend2], mcdend3[ndend3], mcdend4[ndend4]
public all, adend, bdend, cdend, ddend
objref pre_list, fl
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, 3 mcdend1 [i] all.append()
		for i=0, 3 mcdend2 [i] all.append()
		for i=0, 3 mcdend3 [i] all.append()
		for i=0, 3 mcdend4 [i] all.append()

	pdend  = new SectionList()
		mcdend1 [0] pdend.append()
		mcdend2 [0] pdend.append()
		mcdend3 [0] pdend.append()
		mcdend4 [0] pdend.append()

	ddend  = new SectionList()
		for i=1, 3 mcdend1 [i] ddend.append()
		for i=1, 3 mcdend2 [i] ddend.append()
		for i=1, 3 mcdend3 [i] ddend.append()
		for i=1, 3 mcdend4 [i] ddend.append()
}


proc temp() {

	soma {nseg=1 L=20 diam=20} // changed L & diam
		
	mcdend1 [0] {nseg=1 L=50 diam=5.78}
	mcdend1 [1] {nseg=1 L=50 diam=4}
	mcdend1 [2] {nseg=1 L=50 diam=2.5}
 	mcdend1 [3] {nseg=1 L=50 diam=1}

	mcdend2 [0] {nseg=1 L=50 diam=5.78}
	mcdend2 [1] {nseg=1 L=50 diam=4}
	mcdend2 [2] {nseg=1 L=50 diam=2.5}
	mcdend2 [3] {nseg=1 L=50 diam=1}
 		 
	mcdend3 [0] {nseg=1 L=50 diam=5.78}
	mcdend3 [1] {nseg=1 L=50 diam=4}
	mcdend3 [2] {nseg=1 L=50 diam=2.5}
	mcdend3 [3] {nseg=1 L=50 diam=1} 
	
	mcdend4 [0] {nseg=1 L=50 diam=5.78}
	mcdend4 [1] {nseg=1 L=50 diam=4}
	mcdend4 [2] {nseg=1 L=50 diam=2.5}
	mcdend4 [3] {nseg=1 L=50 diam=1} 	

    
	forall {
		insert ccanl
		   catau_ccanl = 10
		   caiinf_ccanl = 5.e-6
		
		insert borgka
		   gkabar_borgka=0.00001
		
		insert nca  // HAV-N- Ca channel
		   gncabar_nca=0.00008  // check to modify- original 0.004
		
		insert lca 
		   glcabar_lca=0.0006
		
		insert gskch
	 	   gskbar_gskch=0.016
		
		insert cagk
		   gkbar_cagk=0.0165
		
		insert hyperde3
		   ghyfbar_hyperde3=0.000005
		   ghysbar_hyperde3=0.000005
	}

	soma {
		insert ichan2  //ildikos ichan
		   gnatbar_ichan2=0.09  //original 0.030 to .055 
		   gkfbar_ichan2=0.001	//0.0005  //original 0.015
		   gl_ichan2 = 0.000011
		   cm=0.6
	} 

	forsec pdend {
		insert ichan2
		   gnatbar_ichan2=0.09  //original 0.015
		   gkfbar_ichan2=0.005
		   gl_ichan2 = 0.000044
		   cm=2.4
	}
		
	forsec ddend {
		insert ichan2
		   gnatbar_ichan2=0.0
		   gkfbar_ichan2=0.00
		   gl_ichan2 = 0.000044
		   cm=2.4
	}
		
	forall {
		Ra=100
	}
	
	forall {
		enat = 55 
		ekf = -90  
		ek=-90  
		esk=-90 
		elca=130
		ehyf=-40 
		ehys=-40
		el_ichan2 =-59
		cao_ccanl=2 
	}  // make catau slower70e-3 	cao=2 cai=50.e-6 

		
	connect mcdend1[0](0), soma(1)
	connect mcdend2[0](0), soma(1)
	connect mcdend3[0](0), soma(0)
	connect mcdend4[0](0), soma(0)
	for i=1,3 {
		connect mcdend1[i](0), mcdend1[i-1](1)
	}
	for i=1,3 {
		connect mcdend2[i](0), mcdend2[i-1](1)
	}
	for i=1,3 {
		connect mcdend3[i](0), mcdend3[i-1](1)
	}
	for i=1,3 {
		connect mcdend4[i](0), mcdend4[i-1](1)
	}


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

/* 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 fl
//soma fl = new Gfluct2(0.5)
//fl.g_e0 = 0.0242
//fl.g_i0 = 0.1146
//fl.std_e = 0.0375
//fl.std_i = 0.01875


}
objref syn_  

proc synapse() {

	mcdend1 [3] syn_ = new Exp2Syn(0.7)	//PP(AMPA) syn_ to dist dend similar to PP to GC
	syn_.tau1 = 1.5	
	syn_.tau2 = 5.5	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend2 [3] syn_ = new Exp2Syn(0.7)	//PP(AMPA) syn_ to dist dend similar to PP to GC
	syn_.tau1 = 1.5	
	syn_.tau2 = 5.5	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend3 [3] syn_ = new Exp2Syn(0.7)	//PP(AMPA) syn_ to dist dend similar to PP to GC
	syn_.tau1 = 1.5	
	syn_.tau2 = 5.5	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend4 [3] syn_ = new Exp2Syn(0.7)	//PP(AMPA) syn_ to dist dend similar to PP to GC
	syn_.tau1 = 1.5	
	syn_.tau2 = 5.5	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend1 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>CA3 Jonas '93
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend2 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>CA3 Jonas '93
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend3 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>CA3 Jonas '93
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend4 [0] syn_ = new Exp2Syn(0.5)	//GC(AMPA) syn_ to prox dend similar to GC>CA3 Jonas '93
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend1 [0] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to prox dend similar to CA#>CA3 Aaron
	syn_.tau1 = 0.45 	
	syn_.tau2 =2.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend2 [0] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to prox dend similar to CA#>CA3 Aaron
	syn_.tau1 = 0.45	
	syn_.tau2 = 2.2		
	syn_.e = 0
	pre_list.append(syn_)

	mcdend3 [0] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to prox dend similar to CA#>CA3 Aaron
	syn_.tau1 = 0.45	
	syn_.tau2 = 2.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend4 [0] syn_ = new Exp2Syn(0.5)	//MC(AMPA) syn_ to prox dend similar to CA#>CA3 Aaron
	syn_.tau1 = 0.45	
	syn_.tau2 = 2.2	
	syn_.e = 0
	pre_list.append(syn_)

	soma syn_ = new Exp2Syn(0.5)	//BC(GABA) syn_ to prox dend based on BC>CA3 Bartos PNAS (mice)
	syn_.tau1 = 0.3	
	syn_.tau2 = 3.3	
	syn_.e = -70
	pre_list.append(syn_)

	mcdend1 [2] syn_ = new Exp2Syn(0.5)	//HIPP(GABA) syn_ to prox dend based on Hilar>GC Harney&Jones
	syn_.tau1 = .5	
	syn_.tau2 = 6		
	syn_.e = -70
	pre_list.append(syn_)

	mcdend2 [2] syn_ = new Exp2Syn(0.5)	//HIPP(GABA) syn_ to prox dend based on Hilar>GC Harney&Jones
	syn_.tau1 = .5	
	syn_.tau2 = 6		
	syn_.e = -70
	pre_list.append(syn_)

	mcdend3 [2] syn_ = new Exp2Syn(0.5)	//HIPP(GABA) syn_ to prox dend based on Hilar>GC Harney&Jones
	syn_.tau1 = .5	
	syn_.tau2 = 6		
	syn_.e = -70
	pre_list.append(syn_)

	mcdend4 [2] syn_ = new Exp2Syn(0.5)	//HIPP(GABA) syn_ to prox dend based on Hilar>GC Harney&Jones
	syn_.tau1 = .5	
	syn_.tau2 = 6	
	syn_.e =-70
	pre_list.append(syn_)

	mcdend1 [0] syn_ = new Exp2Syn(0.5)	//CA3(AMPA) syn_ to prox dend
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend2 [0] syn_ = new Exp2Syn(0.5)	//CA3(AMPA) syn_ to prox dend
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend3 [0] syn_ = new Exp2Syn(0.5)	//CA3(AMPA) syn_ to prox dend
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)

	mcdend4 [0] syn_ = new Exp2Syn(0.5)	//CA3(AMPA) syn_ to prox dend
	syn_.tau1 = 0.5	
	syn_.tau2 = 6.2	
	syn_.e = 0
	pre_list.append(syn_)
	

// Total of 21 synapses 	0-3 PP; 	4-7 GC; 	8-11 MC; 	12 BC;		13-16 HIPP;  	17-20 CA3
}

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 MossyCell