load_file("kinetics.hoc")

begintemplate TypicalCell
public axon,soma,dendrite,apical_dendrite,extstim_site,stim_sr,stim_loc,junction_site,prop_site,IS,nsection,stim_length,extstim_sr,extstimrec_loc,vip_secs,insertwhole_Traub,insertwhole_modTraub,resetwhole_modTraub,insertwhole_Jonas,resetwhole_Jonas
external tstop,choose_stim_site

create soma[1]
create axon[65]
create dendrite[49]
create apical_dendrite[127]

//create axon[1]
objref this,stim_sr,extstim_sr,vip_secs

proc init(){
    xopen("C040896A-P3.hoc")
    nsection = 65
    extstim_site = 43
    junction_site = 40 
    prop_site = 2
    IS = 0
    access axon[IS]
    
    // alternative extstim sites
    // extstim_site = 34
    // junction_site = 26
    
    // extstim_site = 64
    // junction_site = 40
    
    // extstim_site = 16
    // junction_site = 13

    vip_secs = new SectionList()
    soma{
	      vip_secs.append()
	      vip_secs.children()
    }
    axon[IS]{
	      vip_secs.subtree()
    }
    vip_secs.unique()
    forsec vip_secs{
        nseg = int(L/$2) + 1
    }
    
    kinetics = $1
    print "kinetics = ", kinetics
    if(kinetics==0){
        insertwhole_Traub()
    }else if(kinetics==1){
	      insertwhole_Jonas(this,IS)
    }else{
        print "inserting whole-cell modTraub"
        insertwhole_modTraub(this,IS)
    }
    stim_length = 0
    stim_loc = 0
    extstimrec_loc = 0
    choose_stim_site(this,kinetics)
    print "axon[junction_site]=", axon[junction_site].diam
    
}

xopen("kinetics_wholecell.hoc")

endtemplate TypicalCell

begintemplate ShortISCell
public axon,soma,dendrite,apical_dendrite,extstim_site,stim_sr,stim_loc,junction_site,prop_site,IS,nsection,stim_length,extstim_sr,extstimrec_loc,vip_secs,insertwhole_Traub,insertwhole_modTraub,resetwhole_modTraub,insertwhole_Jonas,resetwhole_Jonas
external tstop,choose_stim_site

create soma[1]
create axon[47]
create dendrite[29]
create apical_dendrite[49]

objref this,stim_sr,extstim_sr,vip_secs

proc init(){
    xopen("C230797B-P4.hoc")
    // Length is IS is 55.460211 um
    nsection = 47
    extstim_site = 7
    junction_site = 1
    prop_site = 25
    IS = 0
    access axon[IS]
    
    // alternative extstim sites
    // extstim_site = 36
    // junction_site = 34
    
    // extstim_site = 23 (short collateral)
    // junction_site = 23
    
    // extstim_site = 27 (short collateral)
    // junction_site = 26
    
    vip_secs = new SectionList()
    soma{
	      vip_secs.append()
	      vip_secs.children()
    }
    axon[IS]{
	      vip_secs.subtree()
    }
    vip_secs.unique()
    forsec vip_secs{
        nseg = int(L/$2) + 1
    }
    
    kinetics = $1
    print "kinetics = ", kinetics
    if(kinetics==0){
        insertwhole_Traub()
    }else if(kinetics==1){
	      insertwhole_Jonas(this,IS)
    }else{
        print "inserting whole-cell modTraub"
        insertwhole_modTraub(this,IS)
    }
    stim_length = 0
    stim_loc = 0
    extstimrec_loc = 0
    choose_stim_site(this,kinetics)
    print "axon[junction_site]=", axon[junction_site].diam
    
}

xopen("kinetics_wholecell.hoc")

endtemplate ShortISCell

begintemplate MedISCell
public axon,soma,dendrite,apical_dendrite,extstim_site,stim_sr,stim_loc,junction_site,prop_site,IS,nsection,stim_length,extstim_sr,extstimrec_loc,vip_secs,insertwhole_Traub,insertwhole_modTraub,resetwhole_modTraub,insertwhole_Jonas,resetwhole_Jonas
external tstop,choose_stim_site

create soma[1]
create axon[49]
create dendrite[67]
create apical_dendrite[33]

objref this,stim_sr,extstim_sr,vip_secs

proc init(){
    xopen("C280199C-P1.hoc")
    // Length is IS is 68.210581
    nsection = 49
    extstim_site = 20
    junction_site = 13
    prop_site = 32
    IS = 0
    access axon[IS]
    
    // alternative extstim sites
    // extstim_site = 8
    // junction_site = 1
    
    // extstim_site = 43
    // junction_site = 43
    
    // extstim_site = 25
    // junction_site = 23
    
    // extstim_site = 29
    // junction_site = 27
    
    // extstim_site = 34
    // junction_site = 33
    
    vip_secs = new SectionList()
    soma{
	      vip_secs.append()
	      vip_secs.children()
    }
    axon[IS]{
	      vip_secs.subtree()
    }
    vip_secs.unique()
    forsec vip_secs{
        nseg = int(L/$2) + 1
    }
    
    kinetics = $1
    print "kinetics = ", kinetics
    if(kinetics==0){
        insertwhole_Traub()
    }else if(kinetics==1){
	      insertwhole_Jonas(this,IS)
    }else{
        print "inserting whole-cell modTraub"
        insertwhole_modTraub(this,IS)
    }
    stim_length = 0
    stim_loc = 0
    extstimrec_loc = 0
    choose_stim_site(this,kinetics)
    print "axon[junction_site]=", axon[junction_site].diam
    
}

xopen("kinetics_wholecell.hoc")

endtemplate MedISCell

begintemplate ComplexShortISCell
public axon,soma,dendrite,apical_dendrite,extstim_site,stim_sr,stim_loc,junction_site,prop_site,IS,nsection,stim_length,extstim_sr,extstimrec_loc,vip_secs,insertwhole_Traub,insertwhole_modTraub,resetwhole_modTraub,insertwhole_Jonas,resetwhole_Jonas
external tstop,choose_stim_site

create soma[1]
create axon[67]
create dendrite[47]
create apical_dendrite[33]

objref this,stim_sr,extstim_sr,vip_secs

proc init(){
    xopen("030625DS2.hoc")
    // Length is IS is 82.38088 um
    nsection = 67
    extstim_site = 59
    junction_site = 59
    prop_site = 3
    IS = 0
    access axon[IS]
    
    // alternative extstim sites
    // extstim_site = 51
    // junction_site = 43
    
    // extstim_site = 54
    // junction_site = 52

    // extstim_site = 15
    // junction_site = 5

    // extstim_site = 27
    // junction_site = 19

    vip_secs = new SectionList()
    soma{
	      vip_secs.append()
	      vip_secs.children()
    }
    axon[IS]{
	      vip_secs.subtree()
    }
    vip_secs.unique()
    forsec vip_secs{
        nseg = int(L/$2) + 1
    }
    
    kinetics = $1
    print "kinetics = ", kinetics
    if(kinetics==0){
        insertwhole_Traub()
    }else if(kinetics==1){
	      insertwhole_Jonas(this,IS)
    }else{
        print "inserting whole-cell modTraub"
        insertwhole_modTraub(this,IS)
    }
    stim_length = 0
    stim_loc = 0
    extstimrec_loc = 0
    choose_stim_site(this,kinetics)
    print "axon[junction_site]=", axon[junction_site].diam
    
}

xopen("kinetics_wholecell.hoc")

endtemplate ComplexShortISCell

begintemplate GenericCell
public axon,soma,dendrite,apical_dendrite,extstim_site,stim_sr,stim_loc,junction_site,prop_site,IS,nsection,stim_length,extstim_sr,extstimrec_loc,vip_secs,insertwhole_Traub,insertwhole_modTraub,resetwhole_modTraub,insertwhole_Jonas,resetwhole_Jonas
external tstop,choose_stim_site

create soma[1]
create axon[131]
create dendrite[65]
create apical_dendrite[331]

objref this,stim_sr,extstim_sr,vip_secs
strdef cell_name

proc init(){localobj del_list
    strdef cell_file_name
    cell_name = $s1
    sprint(cell_file_name,"cell_geoms/%s.hoc",cell_name)
    xopen(cell_file_name)
    
    // prune extra compartment away
    del_list = new SectionList()
    del_list.allroots()
    soma{ 
	      del_list.remove()
    }
    forsec del_list{
	      delete_section()
    }
    
    nsection = 67
    IS = $2
    prop_site = $3
    extstim_site = $4
    junction_site = $5
    access axon[IS]
    
    vip_secs = new SectionList()
    soma{
	      vip_secs.append()
	      vip_secs.children()
    }
    axon[IS]{
	      vip_secs.subtree()
    }
    vip_secs.unique()
    forsec vip_secs{
        nseg = int(L/$7) + 1
    }
    
    kinetics = $6
    if(axon[IS].L<40){
        ISchild = $7
    }
    print "kinetics = ", kinetics
    if(kinetics==0){
        insertwhole_Traub()
    }else if(kinetics==1){
	      insertwhole_Jonas(this,IS)
    }else{
        print "inserting whole-cell modTraub"
        if(axon[IS].L>=40){
            insertwhole_modTraub(this,IS)
        }else{
            insertwhole_modTraub(this,IS,ISchild)
        }
    }
    stim_length = 0
    stim_loc = 0
    extstimrec_loc = 0
    choose_stim_site(this,kinetics)
    //print "axon[junction_site]=", axon[junction_site].diam
    
}

xopen("kinetics_wholecell.hoc")

endtemplate GenericCell