//****************************************************************************
// basic_procs.hoc defines procedures for setting conductances and range
// variables of channels - these are primarily used to change variables
// from the gui

proc set_pas() {    NEW_GPAS = $1
    forall if (ismembrane("pas")) {g_pas = NEW_GPAS}
	nG_PAS = NEW_GPAS
}


//*****************
// Sodium conductance settings

proc set_naf() {		NEW_GBAR = $1
	nG_NAF = NEW_GBAR
	forsec "soma" {gnabar_naf = nG_NAF}

 }

proc set_nafd() {		NEW_GBAR = $1
	nG_NAFD = NEW_GBAR
	forsec "dend.*" {gnabar_naf = nG_NAFD}
}

proc set_nap() {		NEW_GBAR = $1
	nG_NAP = NEW_GBAR
	forsec "soma" {gnabar_nap = nG_NAP}
	}

proc set_napd() {		NEW_GBAR = $1
	nG_NAPD = NEW_GBAR
	forsec "dend.*" {gnabar_nap = nG_NAPD}
}

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


	


//*****************
// Potassium conductance settings

proc set_ek() {	newEK = $1
	forsec "MSP" {ek = newEK}
	EK = newEK
}

proc set_kir() {		NEW_GBAR = $1
	nG_KIR = NEW_GBAR
	forall if (ismembrane("kir")) {gkbar_kir = nG_KIR}
}

proc set_kas() {		NEW_GBAR = $1
	nG_KAS = NEW_GBAR
	forsec "soma" {gkbar_kas = nG_KAS}
	MSP_Cell[0].dend1 gkbar_kas = nG_KAS
	MSP_Cell[0].dend2 gkbar_kas = nG_KAS
	MSP_Cell[0].dend3 gkbar_kas = nG_KAS
	MSP_Cell[0].dend4 gkbar_kas = nG_KAS
 }

proc set_kasd() {		NEW_GBAR = $1
	nG_KASD = NEW_GBAR
	forsec "dend._.*" {gkbar_kas = nG_KASD}
}
proc set_kaf() {		NEW_GBAR = $1
	nG_KAF = NEW_GBAR
	forsec "soma" {gkbar_kaf = nG_KAF}
	MSP_Cell[0].dend1 gkbar_kaf = nG_KAF
	MSP_Cell[0].dend2 gkbar_kaf = nG_KAF
	MSP_Cell[0].dend3 gkbar_kaf = nG_KAF
	MSP_Cell[0].dend4 gkbar_kaf = nG_KAF

}

proc set_kafd() {		NEW_GBAR = $1
	nG_KAFD = NEW_GBAR
	forsec "dend._.*" {gkbar_kaf = nG_KAFD}
}

proc set_krp() {		NEW_GBAR = $1
	nG_KRP = NEW_GBAR
	forall if (ismembrane("krp")) {gkbar_krp = NEW_GBAR}
}

proc set_bkkca() {		NEW_GBAR = $1
	nG_BKKCA = NEW_GBAR
	forall if(ismembrane("bkkca")) {gkbar_bkkca = NEW_GBAR}
}

proc set_skkca() {		NEW_GBAR = $1
	nG_SKKCA = NEW_GBAR
	forall if(ismembrane("skkca")) {gkbar_skkca = NEW_GBAR}
}

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





//******************
// Calcium conductance settings

proc set_caL() {		NEW_PBAR = $1
	nP_CAL = NEW_PBAR
	forall if (ismembrane("caL")) {pbar_caL = NEW_PBAR}
}

proc set_caL13() {		NEW_PBAR = $1
	nP_CAL13 = NEW_PBAR
	forall if (ismembrane("caL13")) {pcaLbar_caL13 = NEW_PBAR}
}

proc set_can() {		NEW_PBAR = $1
	nP_CAN = NEW_PBAR
	forall if (ismembrane("can")) {pbar_can = NEW_PBAR}
}

proc set_caq() {		NEW_PBAR = $1
	nP_CAQ = NEW_PBAR
	forall if (ismembrane("caq")) {pcaqbar_caq = NEW_PBAR}
}

proc set_car() {		NEW_PBAR = $1
	nP_CAR = NEW_PBAR
	forall if (ismembrane("car")) {pcarbar_car = NEW_PBAR}
}
proc set_cat() {		NEW_PBAR = $1
	nP_CAT = NEW_PBAR
	forall if (ismembrane("cat")) {pcatbar_cat = NEW_PBAR}
}

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





//******************
// Calcium dynamics procs

proc set_cainf() {	NEW_CAINF = $1
	nCA_INF = NEW_CAINF
	forall if (ismembrane("cadyn")) {cainf_cadyn = NEW_CAINF}
	forall if (ismembrane("caldyn")) {cainf_caldyn = NEW_CAINF}
}

proc set_taur() {	NEW_TAUR = $1
	nCA_TAUR = NEW_TAUR
	forall if (ismembrane("cadyn")) {taur_cadyn = NEW_TAUR}
	forall if (ismembrane("caldyn")) {taur_caldyn = NEW_TAUR}
}
proc set_cadrive() { 	NEW_DRIVE = $1
	nCA_DRIVE = NEW_DRIVE
	forall if (ismembrane("cadyn")) {drive_cadyn = NEW_DRIVE}
	forall if (ismembrane("caldyn")) {drive_caldyn = NEW_DRIVE}
}
proc set_pump() {	NEW_PUMP = $1
	nCA_PUMP = NEW_PUMP
	forall if (ismembrane("cadyn")) {pump_cadyn = NEW_PUMP}
	forall if (ismembrane("caldyn")) {pump_caldyn = NEW_PUMP}
}
//******************



 
//******************
// synaptic gbar procs
proc gampa() {	NEW = $1		// AMPA conductance
	nG_AMPA = NEW
	for j = 0, NGLU-1 {AMPA[j].gbar = NEW}
}

proc gnmda() {	NEW = $1		// NMDA conductance
	nG_NMDA = NEW
	for j = 0, NGLU-1 {NMDA[j].gbar = NEW}
}

proc ggaba() {	NEW = $1		// GABA conductance
	nG_GABA = NEW
	for j = 0, NGABA-1 {GABA[j].gbar = nG_GABA}
}
//******************




//******************
// netstim variables
proc tstart() {		NEW = $1	// time of netstims to start spiking
	nT_START = NEW
	for i = 0, NSYN-1 {NS_NetStim[i].pp.start = NEW}
}

proc setnetn() {	NEW = $1	// number of times a netstim will spike
	nNET_N = NEW
	for i = 0, NSYN-1 { NS_NetStim[i].pp.number = nNET_N }
}

proc setnoise() { NEW = $1		// netstim noise - 1 = random, 0 = not
	nNOISE = NEW
	for i = 0, NSYN-1 { NS_NetStim[i].pp.noise = nNOISE }
}
//******************