/* This is the primary file for creating the MSP cell - this file calls all
	of the hoc files necessary to build one cell and sets the default
	parameter values.
	
	
	
	Jason Moyer 2005 - jtmoyer@seas.upenn.edu
	Michele Mattioni 2008 - mattioni@ebi.ac.uk
*/
	

//****************************************************************************
//Load all the baseline parameters to start with

sprint(dirstr, "%s/hoc/baseline_values.txt", preface)
//print dirstr
xopen(dirstr)
//load_file("../input_params/baseline_values.txt")
//****************************************************************************



//****************************************************************************
// all_tau_vecs.hoc loads the tables used to define the taus for many channels

sprint(dirstr, "%s/hoc/all_tau_vecs.hoc", preface)
//print dirstr
xopen(dirstr)
//load_file("all_tau_vecs.hoc")
//****************************************************************************


//****************************************************************************
// load cell template - builds the cell topology, including inserting
// channels and synapses; dlambda code is in here (under geom()) along 
// with code to output the number of compartments in cell

sprint(dirstr, "%s/hoc/msp_template.hoc", preface)
xopen(dirstr)
//load_file ("msp_template.hoc")
//****************************************************************************



//create acell_home_

objref MSN // Handy pointer
MSN = new MSP_Cell(RA,CM) // It is possible to refer to the same object with MSP_Cell[0] or MSN


//****************************************************************************
// create msp cells using cell_append(), nc_append()
// set number of segments using geom_nseg() (in fixnseg.hoc)
// create shunt for sharp electrode

//sprint(dirstr, "%s/hoc/create_mspcells.hoc", preface)
//xopen(dirstr)
//load_file("create_mspcells.hoc")
//****************************************************************************





//**********************************************************************
// calculate membrane area, access soma by default
A1 = 0
Ad = 0

forsec "dend._.*" {
	for i = 1, nseg {
		Ad = Ad + area( i/(nseg+1) )
	}
}

forsec "MSP_Cell[0]"  {
	for i = 1, nseg {
		A1 = A1 + area( i/(nseg+1) )
	}
}

Ap = A1 - Ad

print "Total cell membrane area = ", A1		// equals whole cell membrane area
print "Mid + Dist mem area = ", Ad
print "Soma + Prox mem area = ", Ap 

//**********************************************************************





//****************************************************************************
// specify cell's active properties using constants listed in
// input_params/baseline_values.txt
//

sprint(dirstr, "%s/hoc/basic_procs.hoc", preface)
xopen(dirstr)

set_pas(G_PAS)

set_naf(G_NAF)
set_nafd(G_NAFD)
set_nap(G_NAP)
set_napd(G_NAPD)

set_kir(G_KIR)
set_kas(G_KAS)
set_kasd(G_KASD)
set_kaf(G_KAF)
set_kafd(G_KAFD)
set_krp(G_KRP)
set_bkkca(G_BKKCA)
set_skkca(G_SKKCA)

set_caL(P_CAL)
set_caL13(P_CAL13)
set_can(P_CAN)
set_caq(P_CAQ)
set_car(P_CAR)
set_cat(P_CAT)

set_cainf(CAINF)
set_taur(TAUR)
set_cadrive(CA_DRIVE)
set_pump(CA_PUMP)

set_ek(EK)
forsec "MSP_Cell" {Ra = RA    cm = CM}

//****************************************************************************


access MSP_Cell[0].soma