// ------------------------------------------

// This file computes the main results of fig 4.
// It compares dADF and hADF spatial extents in function of internodes lengths.

// ------------------------------------------



load_file("nrngui.hoc")

v_init=-70

celsius=37



// Create graphs to plot the results when the soma is depolarized during 10 s before the spike
objref g_subthreshold_depolarization

g_subthreshold_depolarization=new Graph(0)

g_subthreshold_depolarization.view(0,0,6000,15,0,100,300,200)

objref g_AP_area_increase

g_AP_area_increase=new Graph(0)

g_AP_area_increase.view(0,100,6000,20,500,100,300,200)

objref g_dADF_first_bouton

g_dADF_first_bouton=new Graph(0)

g_dADF_first_bouton.view(0,100,5000,40,1000,100,300,200)

// Create graphs to plot the results when the soma is depolarized during 200 ms before the spike
objref g_subthreshold_hyerpolarization

g_subthreshold_hyerpolarization=new Graph(0)

g_subthreshold_hyerpolarization.view(0,0,6000,15,0,500,300,200)

objref g_AP_overshoot_increase

g_AP_overshoot_increase=new Graph(0)

g_AP_overshoot_increase.view(0,0,6000,10,500,500,300,200)

objref g_hADF_first_bouton

g_hADF_first_bouton=new Graph(0)

g_hADF_first_bouton.view(1,100,5000,35,1000,500,300,200)






g_subthreshold_depolarization.label(0.3,0.8,"normalized subthreshold depolarization (mV)",2,1,0,0,1)
g_AP_area_increase.label(0.3,0.8,"normalized AP area increase (%)",2,1,0,0,1)
g_dADF_first_bouton.label(0.3,0.8,"dADF first presypatic sites (%)",2,1,0,0,1)
g_subthreshold_hyerpolarization.label(0.3,0.8,"normalized subthreshold hyperpolarization (mV)",2,1,0,0,1)
g_AP_overshoot_increase.label(0.3,0.8,"normalized AP overshoot increase (mV)",2,1,0,0,1)
g_hADF_first_bouton.label(0.3,0.8,"hADF first presypatic sites (%)",2,1,0,0,1)






// run the model with a myelinated mainaxon and full length internodes
load_file("myelinated_axon_1.hoc")


run_all_simulations()



// plot the results when the soma is depolarized during 10 s before AP
vec_voltage_mainaxon_before_AP_depol_normalized.mark(g_subthreshold_depolarization,vec_dist_mainaxon, "O",2,1)
vec_voltage_mainaxon_before_AP_depol_normalized.line(g_subthreshold_depolarization,vec_dist_mainaxon,1,1)
g_subthreshold_depolarization.label(0.5,0.7,"full length internodes",2,1,0,0,1)

vec_dist_mainaxon.remove(0)
vec_intPA_depol_normalized.remove(0)
vec_intPA_depol_normalized.mark(g_AP_area_increase,vec_dist_mainaxon,"O",2,1)
vec_intPA_depol_normalized.line(g_AP_area_increase,vec_dist_mainaxon,1,1)
g_AP_area_increase.label(0.5,0.7,"full length internodes",2,1,0,0,1)
vec_dist_mainaxon.insrt(0,0)

vec_dADF_first_bouton.mark(g_dADF_first_bouton,vec_dist_first_bouton, "O",2,1)
vec_dADF_first_bouton.line(g_dADF_first_bouton,vec_dist_first_bouton,1,6)
g_dADF_first_bouton.label(0.5,0.7,"full length internodes",2,1,0,0,1)


// plot the results when the soma is hyperpolarized during 200 ms before AP
vec_voltage_mainaxon_before_AP_hyperpol_normalized.mark(g_subthreshold_hyerpolarization,vec_dist_mainaxon, "O",2,1)
vec_voltage_mainaxon_before_AP_hyperpol_normalized.line(g_subthreshold_hyerpolarization,vec_dist_mainaxon,1,1)
g_subthreshold_hyerpolarization.label(0.5,0.7,"full length internodes",2,1,0,0,1)

vec_dist_mainaxon.remove(0)
vec_overshoot_hyperpol_normalized.remove(0)
vec_overshoot_hyperpol_normalized.mark(g_AP_overshoot_increase,vec_dist_mainaxon, "O",2,1)
vec_overshoot_hyperpol_normalized.line(g_AP_overshoot_increase,vec_dist_mainaxon,1,1)
g_AP_overshoot_increase.label(0.5,0.7,"full length internodes",2,1,0,0,1)
vec_dist_mainaxon.insrt(0,0)

vec_hADF_first_bouton.mark(g_hADF_first_bouton,vec_dist_first_bouton, "O",2,1)
vec_hADF_first_bouton.line(g_hADF_first_bouton,vec_dist_first_bouton,1,6)
g_hADF_first_bouton.label(0.5,0.7,"full length internodes",2,1,0,0,1)




// run the model with a myelinated mainaxon and half length internodes
load_file("myelinated_axon_2.hoc")


run_all_simulations()



// plot the results when the soma is depolarized during 10 s before AP
vec_voltage_mainaxon_before_AP_depol_normalized.mark(g_subthreshold_depolarization,vec_dist_mainaxon, "O",2,2)
vec_voltage_mainaxon_before_AP_depol_normalized.line(g_subthreshold_depolarization,vec_dist_mainaxon,2,1)
g_subthreshold_depolarization.label(0.5,0.65,"half length internodes",2,1,0,0,2)

a=vec_dist_mainaxon.x[0]
b=vec_dist_mainaxon.x[1]
vec_dist_mainaxon.remove(0,1)
vec_intPA_depol_normalized.remove(0,1)
vec_intPA_depol_normalized.mark(g_AP_area_increase,vec_dist_mainaxon, "O",2,2)
vec_intPA_depol_normalized.line(g_AP_area_increase,vec_dist_mainaxon,2,1)
g_AP_area_increase.label(0.5,0.65,"half length internodes",2,1,0,0,2)
vec_dist_mainaxon.insrt(0,a,b)

vec_dADF_first_bouton.mark(g_dADF_first_bouton,vec_dist_first_bouton, "O",2,2)
vec_dADF_first_bouton.line(g_dADF_first_bouton,vec_dist_first_bouton,2,6)
g_dADF_first_bouton.label(0.5,0.65,"half length internodes",2,1,0,0,2)


// plot the results when the soma is hyperpolarized during 200 ms before AP
vec_voltage_mainaxon_before_AP_hyperpol_normalized.mark(g_subthreshold_hyerpolarization,vec_dist_mainaxon, "O",2,2)
vec_voltage_mainaxon_before_AP_hyperpol_normalized.line(g_subthreshold_hyerpolarization,vec_dist_mainaxon,2,1)
g_subthreshold_hyerpolarization.label(0.5,0.65,"half length internodes",2,1,0,0,2)

a=vec_dist_mainaxon.x[0]
b=vec_dist_mainaxon.x[1]
vec_dist_mainaxon.remove(0,1)
vec_overshoot_hyperpol_normalized.remove(0,1)
vec_overshoot_hyperpol_normalized.mark(g_AP_overshoot_increase,vec_dist_mainaxon, "O",2,2)
vec_overshoot_hyperpol_normalized.line(g_AP_overshoot_increase,vec_dist_mainaxon,2,1)
g_AP_overshoot_increase.label(0.5,0.65,"half length internodes",2,1,0,0,2)
vec_dist_mainaxon.insrt(0,a,b)

vec_hADF_first_bouton.mark(g_hADF_first_bouton,vec_dist_first_bouton, "O",2,2)
vec_hADF_first_bouton.line(g_hADF_first_bouton,vec_dist_first_bouton,2,6)
g_hADF_first_bouton.label(0.5,0.65,"half length internodes",2,1,0,0,2)





// run the model with a myelinated mainaxon and a quarter length internodes
load_file("myelinated_axon_3.hoc")


run_all_simulations()


// plot the results when the soma is depolarized during 10 s before AP
vec_voltage_mainaxon_before_AP_depol_normalized.mark(g_subthreshold_depolarization,vec_dist_mainaxon, "O",2,3)
vec_voltage_mainaxon_before_AP_depol_normalized.line(g_subthreshold_depolarization,vec_dist_mainaxon,3,1)
g_subthreshold_depolarization.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)

a=vec_dist_mainaxon.x[0]
b=vec_dist_mainaxon.x[1]
c=vec_dist_mainaxon.x[2]
d=vec_dist_mainaxon.x[3]
vec_dist_mainaxon.remove(0,3)
vec_intPA_depol_normalized.remove(0,3)
vec_intPA_depol_normalized.mark(g_AP_area_increase,vec_dist_mainaxon,"O",2,3)
vec_intPA_depol_normalized.line(g_AP_area_increase,vec_dist_mainaxon,3,1)
g_AP_area_increase.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)
vec_dist_mainaxon.insrt(0,a,b,c,d)

vec_dADF_first_bouton.mark(g_dADF_first_bouton,vec_dist_first_bouton, "O",2,3)
vec_dADF_first_bouton.line(g_dADF_first_bouton,vec_dist_first_bouton,3,6)
g_dADF_first_bouton.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)


// plot the results when the soma is hyperpolarized during 200 ms before AP
vec_voltage_mainaxon_before_AP_hyperpol_normalized.mark(g_subthreshold_hyerpolarization,vec_dist_mainaxon, "O",2,3)
vec_voltage_mainaxon_before_AP_hyperpol_normalized.line(g_subthreshold_hyerpolarization,vec_dist_mainaxon,3,1)
g_subthreshold_hyerpolarization.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)

a=vec_dist_mainaxon.x[0]
b=vec_dist_mainaxon.x[1]
c=vec_dist_mainaxon.x[2]
d=vec_dist_mainaxon.x[3]
vec_dist_mainaxon.remove(0,3)
vec_overshoot_hyperpol_normalized.remove(0,3)
vec_overshoot_hyperpol_normalized.mark(g_AP_overshoot_increase,vec_dist_mainaxon, "O",2,3)
vec_overshoot_hyperpol_normalized.line(g_AP_overshoot_increase,vec_dist_mainaxon,3,1)
g_AP_overshoot_increase.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)
vec_dist_mainaxon.insrt(0,a,b,c,d)

vec_hADF_first_bouton.mark(g_hADF_first_bouton,vec_dist_first_bouton, "O",2,3)
vec_hADF_first_bouton.line(g_hADF_first_bouton,vec_dist_first_bouton,3,6)
g_hADF_first_bouton.label(0.5,0.6,"quarter length internodes",2,1,0,0,3)