/* Dentage Gyrus Granule Cell model associated with the papers: 

J. Tejada, G.M. Arisi, N. Garcia-Cairasco, A.C. Roque, Morphological alterations in newly born dentate gyrus granule cells that emerge after status epilepticus contribute to make them less excitable, PLoS ONE. 7 (2012) e40726. doi:10.1371/journal.pone.0040726.

J. Tejada, N. Garcia-Cairasco, A.C. Roque, Combined role of seizure-induced dendritic morphology alterations and spine loss in newborn granule cells with mossy fiber sprouting on the hyperexcitability of a computer model of the dentate gyrus, PLoS Comput. Biol. 10 (2014) e1003601. doi:10.1371/journal.pcbi.1003601.

julian.tejada@gmail.com - 2014  */

//Defining granule cell

	begintemplate GranuleCell9

// Original name on neuroMorpho.org n09-cont02-sl2.CNG.swc

ndend1=7

  
public  pre_list, connect_pre, subsets, is_art, is_connected
public  vbc2gc, vmc2gc, vhc2gc, vgc2bc, vbc2bc, vmc2bc, vhc2bc, vgc2mc, vbc2mc, vmc2mc, vhc2mc, vgc2hc, vmc2hc
public soma, dend
public all, gcldend, pdend, mdend, ddend

nst=10
	objectvar stim[nst]
double stimdur[nst], stimdel[nst], stimamp[nst]
public stim, stimdur, stimamp, stimdel
create soma, dend[ndend1]
objref syn, pre_list


proc init() {
	pre_list = new List()
	subsets()
	gctemp()
	synapse()
}
objref all, gcldend, pdend, mdend, ddend
proc subsets(){ local i
	objref all, gcldend, pdend, mdend, ddend
	all = new SectionList()
		soma all.append()
		for i=0, 6 dend[i] all.append()


	gcldend  = new SectionList()
		dend[0] gcldend.append()


	pdend  = new SectionList()
		dend[2] pdend.append()
		dend[5] pdend.append()




	mdend  = new SectionList()
		dend[1] mdend.append()
		dend[4] mdend.append()
		dend[6] mdend.append()
		

	ddend  = new SectionList()
		dend[3] ddend.append()
		
}
proc gctemp() {

// 	soma {nseg=1 L=16.329 diam=11.165} // changed L & diam
// 		
// 	dend [0] {nseg=1  L=20.05632 diam=2.6}
// 	dend [1] {nseg=1  L=80.78021 diam=1.6478}
// 	dend [2] {nseg=1  L=10.61434 diam=1.1833}
// 	dend [3] {nseg=1  L=25.82767 diam=1.0346}
// 	dend [4] {nseg=1  L=30.89202 diam=0.7664}
// 	dend [5] {nseg=1  L=43.53635 diam=0.9072}
// 	dend [6] {nseg=1  L=37.46003 diam=0.9215}
// 	dend [7] {nseg=1  L=85.47885 diam=0.5756}
// 	dend [8] {nseg=1  L=121.54242 diam=0.6968}
// 	dend [9] {nseg=1  L=78.91646 diam=0.6705}
// 	dend [10] {nseg=1 L=97.50034 diam=0.7203}
// 	dend [11] {nseg=1 L=19.96318 diam=0.8309}
// 	dend [12] {nseg=1 L=125.23049 diam=0.5746}
// 	dend [13] {nseg=1 L=117.23326 diam=0.6059}
// 	dend [14] {nseg=1 L=31.96199 diam=0.6411}
// 	dend [15] {nseg=1 L=45.48879 diam=0.6389}
// 	dend [16] {nseg=1 L=22.50602 diam=0.5591}
// 	dend [17] {nseg=1 L=37.40208 diam=0.6970}
// 	dend [18] {nseg=1 L=20.88699 diam=0.6050}
// 	dend [19] {nseg=1 L=10.10732 diam=0.5985}
	
// 	for i = 1, 20	dend [i] {nseg=1 L=150 diam=3}

// 	gcdend2 [0] {nseg=1 L=50 diam=3}
// 	for i = 1, 3	gcdend2 [i] {nseg=1 L=150 diam=3}	 	

    
	forsec all {
		insert ccanl
	catau_ccanl = 10
	caiinf_ccanl = 0.000005
	Ra=210
	}

	soma {insert ichan2  //ildikos ichan
	gnatbar_ichan2=0.12  //original 0.030 to .055 
	gkfbar_ichan2=0.016  //original 0.015
	gksbar_ichan2=0.006
		insert borgka
	gkabar_borgka=0.012
		insert nca  // HAV-N- Ca channel
	gncabar_nca=0.002  // check to modify- original 0.004
		insert lca 
	glcabar_lca=0.005
		insert cat
	gcatbar_cat=0.000037
		insert gskch
	gskbar_gskch=0.001
		insert cagk
	gkbar_cagk=0.0006
	gl_ichan2 = 0.00004
	cm=1

} 

		forsec gcldend {insert ichan2
	gnatbar_ichan2=0.018  //original 0.015
	gkfbar_ichan2=0.004
	gksbar_ichan2=0.006
		insert nca  // HAV-N- Ca channel
	gncabar_nca=0.003  // check to modify- original 0.004
		insert lca 
	glcabar_lca=0.0075
		insert cat
	gcatbar_cat=0.000075
		insert gskch
	gskbar_gskch=0.0004
		insert cagk
	gkbar_cagk=0.0006
	gl_ichan2 = 0.00004
	cm=1}
		
		forsec pdend {insert ichan2
	gnatbar_ichan2=0.013 
	gkfbar_ichan2=0.004
	gksbar_ichan2=0.006
		insert nca  // HAV-N- Ca channel
	gncabar_nca=0.001  // check to modify- original 0.004
		insert lca 
	glcabar_lca=0.0075
		insert cat
	gcatbar_cat=0.00025
		insert gskch
	gskbar_gskch=0.0002
		insert cagk
	gkbar_cagk=0.001
	gl_ichan2 = 0.000063
	cm=1.0 
        insert pas 
      g_pas = 4e-05
	}
		
	 	forsec mdend {insert ichan2
	gnatbar_ichan2=0.008 
	gkfbar_ichan2=0.001
	gksbar_ichan2=0.006
		insert nca  // HAV-N- Ca channel
	gncabar_nca=0.001  // check to modify- original 0.004
		insert lca 
	glcabar_lca=0.0005
		insert cat
	gcatbar_cat=0.0005
		insert gskch
	gskbar_gskch=0.0
		insert cagk
	gkbar_cagk=0.0024
	gl_ichan2 = 0.000063

	cm=1.0 
        insert pas 
      g_pas = 4e-05}

		forsec ddend {insert ichan2
	gnatbar_ichan2=0.008 
	gkfbar_ichan2=0.001
	gksbar_ichan2=0.008
		insert nca  // HAV-N- Ca channel
	gncabar_nca=0.001  // check to modify- original 0.004
		insert lca 
	glcabar_lca=0.0
		insert cat
	gcatbar_cat=0.001
		insert gskch
	gskbar_gskch=0.0
		insert cagk
	gkbar_cagk=0.0024
	gl_ichan2 = 0.000063
	cm=1.0 
        insert pas 
      g_pas = 4e-05}
		
	
// 	connect dend[0](0), soma(1)
// 	connect gcdend2[0](0), soma(1)
// 	for i=1,3 {
// 	connect dend[i](0), dend[i-1](1)
// 	}
// 	for i=1,3 {
// 	connect gcdend2[i](0), gcdend2[i-1](1)
// 	}
  connect dend(0), soma(1)
  for i = 1, 2 connect dend[i](0), dend(1)
  for i = 3, 4 connect dend[i](0), dend[1](1)
  for i = 5, 6 connect dend[i](0), dend[2](1)
basic_shape()
	    

// 	  connect axon(1), soma(0)


	forsec all {enat = 45 ekf = -90 eks = -90  ek=-90  elca=130 etca=130	 esk=-90
		 el_ichan2 =-70

		cao_ccanl=2 }  // make catau slower70e-3 	cao=2 cai=50.e-6 

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

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

}


proc shape3d_1() {
//   axon {pt3dclear()
// 	pt3dadd(0.03929, -38, 0.01, 0.2)
// 	pt3dadd(0.03929, -18, 0.01, 10)
//   }
//   
  
  soma {pt3dclear()
	pt3dadd(0.03929, -18, 0.01, 10)
	pt3dadd(0.03929, 0.6493, 0, 7.624)
  }
  dend {pt3dclear()
	pt3dadd(0.03929, 0.6493, 0, 7.624)
	pt3dadd(-1.39, -3.16, 0.14, 2.32)
	pt3dadd(-2.6, -4.45, 1.64, 2.23)
	pt3dadd(-3.9, -5, 3.07, 2.13)
	pt3dadd(-5.29, -5.64, 3.07, 2.13)
	pt3dadd(-6.24, -6.35, 2.86, 2.32)
	pt3dadd(-6.88, -7.36, 4.26, 2.6)
  }
//   dendrite {pt3dclear()
// 	pt3dadd(0.03929, 0.6493, 0, 7.624)
// 	pt3dadd(4.82, 0.74, -0.28, 2.04)
// 	pt3dadd(5.94, 0.74, -0.28, 1.67)
// 	pt3dadd(6.86, 1.19, 0.29, 0.93)
// 	pt3dadd(7.98, 0.09, -0.82, 0.65)
// 	pt3dadd(9.28, -0.64, -0.82, 0.65)
// 	pt3dadd(10.39, -1.1, -0.84, 0.56)
// 	pt3dadd(11.78, -1.75, -0.25, 0.74)
// 	pt3dadd(12.62, -2.11, -0.25, 0.56)
// 	pt3dadd(14.29, -2.76, -0.15, 0.83)
// 	pt3dadd(15.4, -3.49, -0.42, 0.56)
// 	pt3dadd(16.51, -3.95, 0.07, 0.65)
// 	pt3dadd(17.35, -4.32, 0.07, 0.56)
// 	pt3dadd(18.83, -4.69, 0.07, 0.56)
// 	pt3dadd(19.48, -5.33, 0.36, 0.56)
// 	pt3dadd(20.5, -5.79, 0.36, 0.56)
//   }
  dend[1] {pt3dclear()
	pt3dadd(-6.88, -7.36, 4.26, 2.6)
	pt3dadd(-6.33, -8.82, 4.59, 0.93)
	pt3dadd(-6.7, -10.01, 5.32, 0.93)
	pt3dadd(-7.16, -12.04, 6.21, 0.93)
	pt3dadd(-7.91, -14.24, 6.26, 0.93)
	pt3dadd(-9.21, -15.25, 6.31, 0.93)
	pt3dadd(-8.46, -16.54, 7.21, 0.93)
	pt3dadd(-7.26, -18.1, 7.95, 0.93)
	pt3dadd(-6.52, -18.65, 8.59, 0.93)
	pt3dadd(-5.96, -19.21, 8.59, 0.74)
	pt3dadd(-6.52, -20.22, 8.59, 0.93)
	pt3dadd(-6.98, -21.23, 8.59, 0.74)
	pt3dadd(-7.44, -21.69, 8.59, 0.93)
	pt3dadd(-8.18, -22.79, 8.59, 0.83)
	pt3dadd(-9.02, -23.71, 8.59, 0.83)
	pt3dadd(-9.76, -24.35, 9.32, 0.83)
	pt3dadd(-10.23, -25.27, 9.32, 0.83)
	pt3dadd(-10.05, -26.15, 9.32, 0.83)
	pt3dadd(-10.51, -27.53, 10.12, 0.83)
	pt3dadd(-10.24, -28.82, 10.53, 0.83)
	pt3dadd(-9.59, -30.38, 10.53, 0.83)
	pt3dadd(-9.4, -31.76, 10.89, 0.83)
	pt3dadd(-8.66, -33.6, 11.01, 0.83)
	pt3dadd(-8.38, -35.25, 11.16, 0.83)
	pt3dadd(-8.19, -36.54, 11.16, 1.21)
	pt3dadd(-9.31, -37.09, 11.69, 0.93)
	pt3dadd(-10.51, -37.27, 11.81, 0.93)
	pt3dadd(-11.44, -37.55, 11.81, 0.93)
	pt3dadd(-11.16, -38.84, 11.81, 1.11)
	pt3dadd(-11.16, -40.03, 11.81, 1.11)
	pt3dadd(-10.79, -41.13, 12.25, 0.74)
	pt3dadd(-10.88, -42.05, 12.25, 0.74)
	pt3dadd(-11.81, -42.42, 12.77, 0.93)
	pt3dadd(-12.93, -43.06, 13.42, 0.93)
	pt3dadd(-13.88, -43.48, 13.68, 0.93)
	pt3dadd(-15.09, -43.67, 13.68, 0.74)
	pt3dadd(-15.18, -44.77, 14.05, 0.83)
	pt3dadd(-15.28, -46.24, 14.01, 0.83)
	pt3dadd(-15.28, -48.08, 14.66, 1.02)
	pt3dadd(-15.65, -49.37, 13.77, 1.02)
	pt3dadd(-15.74, -50.29, 13.77, 0.93)
	pt3dadd(-15.93, -51.11, 13.77, 1.02)
  }
  dend[2] {pt3dclear()
	pt3dadd(-6.88, -7.36, 4.26, 2.6)
	pt3dadd(-8.18, -7.64, 5.02, 1.48)
	pt3dadd(-9.39, -8.56, 5.02, 1.39)
	pt3dadd(-10.04, -9.57, 5.52, 1.21)
	pt3dadd(-8.93, -10.67, 6.09, 1.39)
	pt3dadd(-7.72, -11.59, 6.09, 1.21)
	pt3dadd(-7.44, -12.79, 5.68, 1.21)
	pt3dadd(-8.93, -13.7, 5.33, 1.21)
	pt3dadd(-10.32, -13.7, 5.33, 1.11)
	pt3dadd(-11.52, -14.07, 5.04, 1.11)
	pt3dadd(-12.73, -14.35, 5.04, 1.02)
	pt3dadd(-14.4, -15.18, 4.4, 0.83)
	pt3dadd(-15.05, -16, 4.19, 0.83)
	pt3dadd(-15.05, -17.66, 4.19, 0.83)
	pt3dadd(-14.58, -18.67, 4, 0.83)
	pt3dadd(-13.66, -19.5, 3.76, 0.83)
	pt3dadd(-12.82, -20.6, 3.21, 0.83)
	pt3dadd(-13.38, -21.79, 3.21, 0.83)
	pt3dadd(-14.03, -22.62, 2.4, 0.83)
	pt3dadd(-14.77, -23.36, 2.4, 0.83)
	pt3dadd(-15.33, -23.98, 2.9, 0.83)
	pt3dadd(-15.7, -24.89, 2.6, 1.11)
  }
  dend[3] {pt3dclear()
	pt3dadd(-15.93, -51.11, 13.77, 1.02)
	pt3dadd(-16.07, -52.79, 14.64, 1.3)
	pt3dadd(-16.81, -55, 15.16, 1.48)
	pt3dadd(-17.83, -57.02, 15.16, 1.48)
	pt3dadd(-18.67, -58.59, 15.28, 1.48)
	pt3dadd(-19.69, -59.78, 14.95, 1.3)
	pt3dadd(-20.62, -60.15, 14.95, 1.02)
	pt3dadd(-21.08, -62.17, 14.75, 1.02)
	pt3dadd(-20.62, -63.92, 15.06, 1.02)
	pt3dadd(-21.36, -65.48, 14.28, 0.93)
	pt3dadd(-22.38, -66.95, 13.91, 0.93)
	pt3dadd(-23.31, -68.05, 13.91, 1.02)
	pt3dadd(-24.51, -69.06, 13.91, 1.02)
	pt3dadd(-24.82, -70.23, 14.21, 0.83)
	pt3dadd(-25.28, -71.7, 13.99, 0.83)
	pt3dadd(-25.93, -73.54, 13.99, 0.93)
	pt3dadd(-27.05, -75.1, 13.85, 0.93)
	pt3dadd(-28.07, -76.66, 13.85, 0.93)
	pt3dadd(-28.62, -78.41, 13.26, 1.11)
	pt3dadd(-29.09, -80.71, 12.81, 1.11)
	pt3dadd(-29.83, -81.72, 12.89, 0.83)
	pt3dadd(-31.31, -82.36, 13.23, 0.74)
	pt3dadd(-33.08, -83.46, 12.97, 0.74)
	pt3dadd(-34.28, -84.57, 12.97, 0.74)
	pt3dadd(-34.65, -85.58, 13.78, 0.83)
	pt3dadd(-35.3, -86.86, 13.78, 0.83)
	pt3dadd(-35.8, -88.21, 14.28, 0.74)
	pt3dadd(-36.73, -89.77, 14.28, 0.74)
	pt3dadd(-37.47, -90.69, 14.28, 0.74)
	pt3dadd(-38.4, -92.07, 14.28, 0.65)
	pt3dadd(-39.14, -94, 14.21, 0.74)
	pt3dadd(-39.7, -95.2, 14.21, 0.74)
	pt3dadd(-40.34, -96.39, 14.21, 0.65)
	pt3dadd(-40.99, -97.59, 14.21, 0.65)
	pt3dadd(-41.46, -99.15, 14.13, 0.65)
	pt3dadd(-42.39, -100.7, 14.13, 0.65)
	pt3dadd(-43.03, -101.3, 14.23, 0.65)
	pt3dadd(-43.78, -102.6, 14.17, 0.56)
	pt3dadd(-44.33, -105, 14.23, 0.56)
	pt3dadd(-43.97, -106.8, 14.5, 0.56)
	pt3dadd(-45.27, -107.5, 15.04, 0.56)
	pt3dadd(-46.2, -108.7, 14.88, 0.56)
	pt3dadd(-46.94, -110.3, 14.76, 0.56)
	pt3dadd(-47.59, -112.5, 15.35, 0.56)
	pt3dadd(-47.78, -113.7, 15.35, 1.02)
	pt3dadd(-47.78, -115.1, 15.35, 0.74)
	pt3dadd(-47.78, -116.5, 15.35, 0.74)
	pt3dadd(-48.05, -117.7, 15.97, 0.65)
	pt3dadd(-48.52, -119.5, 15.86, 0.56)
	pt3dadd(-49.07, -121.6, 15.86, 0.56)
	pt3dadd(-49.44, -123.2, 16.48, 0.56)
	pt3dadd(-50, -125, 16.82, 0.56)
	pt3dadd(-50.65, -126.3, 16.82, 0.56)
	pt3dadd(-50.93, -127.5, 16.82, 0.56)
	pt3dadd(-50.46, -128.7, 16.82, 0.56)
	pt3dadd(-50.93, -129.7, 16.83, 0.83)
	pt3dadd(-51.58, -130, 16.83, 0.83)
	pt3dadd(-51.95, -130.9, 16.83, 0.65)
	pt3dadd(-52.32, -132.2, 17.16, 0.65)
	pt3dadd(-52.69, -133.3, 17.27, 0.56)
	pt3dadd(-52.41, -134.3, 17.27, 0.56)
	pt3dadd(-53.34, -136.3, 16.71, 0.56)
	pt3dadd(-53.99, -137.7, 16.71, 0.56)
	pt3dadd(-54.17, -139, 16.75, 0.56)
	pt3dadd(-54.92, -140.1, 16.75, 0.56)
	pt3dadd(-55.47, -141.4, 17.19, 0.56)
	pt3dadd(-55.93, -142.4, 17.19, 0.46)
	pt3dadd(-56.48, -143.8, 17.29, 0.65)
	pt3dadd(-57.04, -145.8, 18.57, 0.65)
  }
  dend[4] {pt3dclear()
	pt3dadd(-15.93, -51.11, 13.77, 1.02)
	pt3dadd(-14.91, -52.4, 13.88, 0.74)
	pt3dadd(-14.53, -53.04, 14.01, 0.83)
	pt3dadd(-14.53, -54.24, 14.62, 0.83)
	pt3dadd(-14.26, -55.34, 14.92, 0.65)
	pt3dadd(-14.26, -56.72, 15.39, 0.65)
	pt3dadd(-14.81, -58.01, 15.92, 0.65)
	pt3dadd(-15.28, -59.29, 16.47, 0.65)
	pt3dadd(-13.88, -59.94, 16.61, 0.65)
	pt3dadd(-14.35, -61.13, 16.76, 0.65)
	pt3dadd(-14.8, -62.42, 17.25, 0.65)
	pt3dadd(-14.98, -63.89, 17.25, 0.65)
	pt3dadd(-15.63, -65.45, 18.09, 0.65)
	pt3dadd(-15.36, -68.03, 18.39, 0.65)
	pt3dadd(-14.98, -69.96, 19.02, 0.56)
	pt3dadd(-15.26, -72.71, 18.67, 0.56)
	pt3dadd(-15.45, -74.37, 19.06, 0.56)
	pt3dadd(-15.91, -75.93, 18.59, 0.56)
	pt3dadd(-16.38, -77.59, 18.48, 0.56)
	pt3dadd(-16.56, -78.96, 18.36, 0.56)
  }
  dend[5] {pt3dclear()
	pt3dadd(-15.7, -24.89, 2.6, 1.11)
	pt3dadd(-15.05, -25.71, 3.1, 0.56)
	pt3dadd(-14.59, -27, 2.69, 0.56)
	pt3dadd(-14.22, -28.01, 2.77, 0.56)
	pt3dadd(-14.96, -29.67, 3.74, 0.56)
	pt3dadd(-14.96, -31.78, 3.05, 0.56)
	pt3dadd(-14.31, -33.43, 3.05, 0.56)
  }
  dend[6] {pt3dclear()
	pt3dadd(-15.7, -24.89, 2.6, 1.11)
	pt3dadd(-16.72, -25.81, 1.75, 0.74)
	pt3dadd(-17, -27.01, 1.75, 0.74)
	pt3dadd(-17.74, -27.47, 1.43, 0.74)
	pt3dadd(-18.39, -28.57, 1.3, 0.74)
	pt3dadd(-19.22, -29.12, 1.3, 0.74)
	pt3dadd(-20.8, -30.04, 1.06, 0.74)
	pt3dadd(-22.19, -30.59, 0.78, 0.74)
	pt3dadd(-22.75, -31.88, 0.88, 0.74)
	pt3dadd(-23.68, -32.98, 0.31, 0.74)
	pt3dadd(-24.6, -33.9, 0.31, 0.74)
	pt3dadd(-25.53, -35.1, 0.19, 0.74)
	pt3dadd(-26.37, -36.29, 0.52, 0.74)
	pt3dadd(-26.74, -37.3, 0.52, 1.02)
	pt3dadd(-27.11, -38.5, 0.33, 1.02)
  }
}
proc shape3d_2() {
  dend[6] {	pt3dadd(-27.39, -39.51, -0.71, 0.83)
  }
}
proc basic_shape() {
  shape3d_1()
  shape3d_2()
}


		
	proc connect_pre() {  // $o1 target point process, $o2 returned NetCon
	soma $o2 = new NetCon (&v(1), $o1)
	//alternative statement		$o1.soma pre_list.append(new NetCon(soma.v(1),syn,0,Delsyn,0))
	}

	objref syn
	
	objref ProximalSynapses 
	objref ProximalSynapsePositions 
	proc synapse() { 
  
 // //***** PP syn   
 
 
 // //***** MC syn   
 
ProximalSynapses = new Vector(0,0) 
ProximalSynapses .append(0 , 1 , 2 , 5 , 6) 
ProximalSynapsePositions = new Vector(0,0) 
ProximalSynapsePositions .append(0.5 ,    0.33363   ,      0.5   ,  0.43563 ,    0.20639) 
for i= 0 , 4 { 
dend[ProximalSynapses .x[i]] syn = new Exp2Syn(ProximalSynapsePositions .x[i]) // // MC syn *** Estimated 
syn.tau1 = 1.5	syn.tau2 = 5.5	syn.e = 0 
pre_list.append(syn) // #  
} 
 
 // //***** HIPP   
 
 
 // //***** BC syn   
 
soma syn = new Exp2Syn(0.5) // BC  syn syn based on Bartos 
syn.tau1 = 0.26	syn.tau2 = 5.5	syn.e = -70 
pre_list.append(syn) // # 0 
 
 // //***** Sprout   
 
for i= 0 , 4 { 
dend[ProximalSynapses .x[i]] syn = new Exp2Syn(ProximalSynapsePositions .x[i]) // // MC syn *** Estimated 
syn.tau1 = 1.5	syn.tau2 = 5.5	syn.e = 0 
pre_list.append(syn) // # 0 
} 

}
	func is_art() { return 0 }

	endtemplate GranuleCell9
//************************************************************************************************************