// (C) Armin Bahl, Jun 18 2009
// Simplified Geometry for layer 5 Pyramidal Neuron

////////////////////////////////////////////////////////////////////////////////////////////////
// The Geometry will fulfill these area conditions
// Surface areas were calculated from a detailed reconstruction from a Pyramidal Neuron

soma_area = 1682.96028429
basal_area = 7060.90626796
apicalshaftoblique_area = 9312.38528764
tuft_area = 9434.24861189

PI  = 3.1415926535897932384

////////////////////////////////////////////////////////////////////////////////////////////////
// Create the Segments and connect them properly and set the number of compartments per Segment
create soma
create basal
create apical
create tuft
create hillock
create iseg
create axon

connect basal(0), soma(0.5)
connect apical(0), soma(1)
connect tuft(0), apical(1)
connect hillock(0), soma(0)
connect iseg(0), hillock(1)
connect axon(0), iseg(1)

soma			nseg = 1
basal			nseg = 1
apical			nseg = 5
tuft			nseg = 2
hillock			nseg = 5
iseg			nseg = 5
axon			nseg = 1

////////////////////////////////////////////////////
// Define Sections

objref axon_list, axosomatic_list, apicaltree_list, apicalshaftoblique_list, tuft_list, soma_list, basal_list

axon_list 				= new SectionList()
axosomatic_list 		= new SectionList()
apicalshaftoblique_list = new SectionList()
apicaltree_list 		= new SectionList()
tuft_list 				= new SectionList()
soma_list 				= new SectionList()
basal_list 				= new SectionList()

hillock			axon_list.append()
iseg			axon_list.append()
axon			axon_list.append()

soma			axosomatic_list.append()
basal			axosomatic_list.append()
hillock			axosomatic_list.append()
iseg			axosomatic_list.append()
axon			axosomatic_list.append()

apical 			apicalshaftoblique_list.append()
apical			apicaltree_list.append()
tuft			apicaltree_list.append()

tuft 			tuft_list.append() 

soma			soma_list.append()

basal			basal_list.append()

// As we do not have oblique dendrites in the reduced model this is the same (important for area calculation)

///////////////////////////////////////////////////////////
// Set the Parameters that were Found by the Geometry Optimization Algorithm



soma Ra =  82

basal L	 = 257   
basal Ra = 734 

apical L = 500
Ra_apical = 261
diam_apical = apicalshaftoblique_area/PI/apical.L
apical Ra =  Ra_apical

tuft L = 499
tuft Ra = 527


proc recalculate_geometry() {
	soma 		diam = L =  sqrt(soma_area/PI)
	basal 		diam = basal_area/PI/basal.L
	
	apical   	diam = diam_apical
	
	tuft 		diam = tuft_area/PI/tuft.L
}

recalculate_geometry()

////////////////////////////////////////////////
// Also append an Axon

hillock { 
	L = 20
	diam(0:1) = 3.5:2.0
	Ra = soma.Ra
}

iseg {
	L = 25
	diam(0:1) = 2.0:1.5
	Ra = soma.Ra
}

axon { 
	L = 500
	diam = 1.5
	Ra = soma.Ra
}