//**********   Perforant Path Stimulus   ***********************************************

// artificial stimulus to activate PP

// extracted from
// Dentate gyrus network model 
// Santhakumar V, Aradi I, Soltesz I (2005) J Neurophysiol 93:437-53 
// https://senselab.med.yale.edu/ModelDB/showModel.cshtml?model=51781&file=\dentategyrusnet2005\DG500_M7.hoc

// ModelDB file along with publication:
// Yim MY, Hanuschkin A, Wolfart J (2015) Hippocampus 25:297-308.
// http://onlinelibrary.wiley.com/doi/10.1002/hipo.22373/abstract

// modified by
// Man Yi Yim / 2015
// Alexander Hanuschkin / 2011

begintemplate PPstim

//external PP_rate_, tstop
//external PP_box_start_,PP_box_stop_			// stimulation window instead of Poisson input ...

external PP_freq_
public pp, connect_pre, is_art, acell
create acell
objref pp


proc init() {
	actemp()
    pp_index = $1
    PP_rate_ = $2 // Is this even used??
    tstop = $3
    PP_box_start_ = $4
    PP_box_stop_ = $5
    PP_freq_ = $6
    PP_min_invl_ = $7
    PP_scale_max_invl_ = $8
}



proc actemp() {
    //TODO: Re-write this s.t. there's no dependancy on external variable
    if (PP_freq_){                      
        acell pp = new NetStimOsc(.5)
	        pp.start = PP_box_start_
	        pp.forcestop = PP_box_stop_ 
            pp.freq = PP_freq_
            pp.min_invl = PP_min_invl_
            pp.scale_max_invl = PP_scale_max_invl_
        print "using NetStimOsc"
    }else{
        acell pp = new NetStimBox(0.5)
            pp.start = PP_box_start_
            pp.forcestop = PP_box_stop_
        print "using NetStimBox"
    }
      
}

func is_art() {return 1}

proc connect_pre() {acell $o2 = new NetCon(pp, $o1)}

endtemplate PPstim