//genesis - Purkinje cell M9 genesis2.1 script
/* Copyright E. De Schutter (Caltech and BBF-UIA) */

/**********************************************************************
** Sets of synapse objects developed for rat cerebellum Purkinje
** E. De Schutter, Caltech, 1991-1992
**********************************************************************/

/* Reference:
** E. De Schutter and J.M. Bower: An active membrane model of the
** cerebellar Purkinje cell: II. Simulation of synaptic responses.
** Journal of Neurophysiology  71: 401-419 (1994).
** http://bbf-www.uia.ac.be/TNB/TNB_pub7.html
** Consult this reference for sources of experimental data.
*/

// CONSTANTS
/* should be defined by calling routine (all correctly scaled):
**	E_non_NMDA
**	E_GABA, G_GABA */

// factor Q10 of 1.5: Regehr et al. J. Neuroscience 1996 16(18):5661-5671
float Q10 = 1.5
function Calc_tau(Q10,T1,T2,tau1)
  return {tau1 / { Q10**{{T2 -T1}/10}}}
end

float temp = 37 // Celsius degrees
float Q12_non_NMDA = 1.68 // for 10 1.4


// correctio for low input resistance
float Rin_corr = 1
int include_Purk_syn

if ( !{include_Purk_syn} )
  include_Purk_syn = 1

  /*********************************************************************
  **               The synaptic conductance equations 
  *********************************************************************/
  
function make_Purkinje_syns
  
    echo making Purkinje synapse library...
    
    /* The conductance equations in this library are general and not
    **  specific to the Purkinje celxl */
    
    /* GABA channel, made by SS */
    /* Reference: current clamp data from 
    ** Pouzat C. and Hestrin S. J. Neuroscince 1997
    ** V_drive 60 mV, I_syn 20 pA -> G_peak = 333 pS
    ** (that is 35.3 pA at 37 C which should be recorded in voltage clamp)
    ** T_rise: 2.6 +- 0.5 ms, Thalf-width = 16.7 +- 2.7 ms 
    ** room temperature: we assume 23 Celsius degrees
    ** Found T_on = 1.65 ms and T_off = 9.3 ms by hand (MATLAB)
    ** Found with c++ program /bbf/milaan/sergio/Work/C++/Rise2Tau/rise2tau:
    ** Found T_on = 2.1 ms and T_off = 15.3 ms by hand (c++)	*/
    float PC_GABAA_factor = 5.8
    // Stell & Stell1 channels: average conpartment surface  4.020627647e-11 m2
    float PC_GABAA_gmax = {333e-12 /  4.020627647e-11 * PC_GABAA_factor}
    // Stell3 channels: average conpartment surface  2.247033843e-10 m2
    float PC_GABAAm_gmax = {333e-12 / 2.49670427e-10 * PC_GABAA_factor}
    // Stell4 channels: somatic surface  m2
    float PC_GABAAs_gmax = {3.5e-9 / 2.789857497e-09 }
    float PC_GABAA_t_on = 1.65e-3
    float PC_GABAA_t_off = 9.3e-3

    /* Synaptic channel for Stellate connections */
    if (!({exists GABA}))
        	create synchan GABA
    end
    setfield GABA Ek {E_GABA} 	\
  	tau1 {Calc_tau {Q10} 23 {temp} {PC_GABAA_t_on}} \
        	tau2 {Calc_tau {Q10} 23 {temp} {PC_GABAA_t_off}}  \
       	gmax {G_GABA} frequency {0.0}
  
    /* Synaptic channel for Basket connections on PC main dendrite */
    if (!({exists GABA2}))
        	create synchan GABA2
    end
    setfield GABA2 Ek {E_GABA} 	\
  	tau1 {Calc_tau {Q10} 23 {temp} {PC_GABAA_t_on}} \
        	tau2 {Calc_tau {Q10} 23 {temp} {PC_GABAA_t_off}}  \
       	gmax {G_GABA} frequency {0.0}
  
    /* Synaptic channel for Basket connections PC soma */
    if (!({exists GABA3}))
        	create synchan GABA3
    end

    setfield GABA3 Ek {E_GABA} 	\
  	tau1 {Calc_tau {Q10} 37 {temp} {PC_GABAA_t_on}} \ // We use 37 degrees here since it's not specified in the article
        	tau2 {Calc_tau {Q10} 37 {temp} {PC_GABAA_t_off}}  \
       	gmax {G_GABA} frequency {0.0}


    // set the right GABAA density value to get gmax from Hausser M. and Clark B. A. Neuron 1997
    G_GABA = {{PC_GABAA_gmax} * {Q10**{{{temp} - 23}/10}}}
    echo GABAA gmax {G_GABA}
    G_GABAm = {{PC_GABAAm_gmax} * {Q10**{{{temp} - 23}/10}}}
    echo GABAA2 gmax {GB_GABA}
    G_GABAs = {{PC_GABAAs_gmax} * {Q10**{{{temp} - 37}/10}}} // We use 37 degrees here since it's not specified in the article
    echo GABAAs soma gmax {GB_GABAs}

    
    /* non-NMDA channel, made by SS */
    /* Reference: Barbour B. 2002 (personal communication)
    ** room temp: 32 C
    ** somatic EPSC peak = 8.4 +- 7.1 pA
    ** (that is 10.2 pA at 37 C which should be recorded in voltage clamp)
    ** the driving force at the excitatory synapse is 70 mV 
    ** during Voltage clamp at -70 mV
    ** thus the peak conductance G_par_syn = 120 pS
    ** t_on = 1.0 +- 0.7 ms
    ** the low-pass filtering effect of the large PC dendritic tree
    ** could slow down the fast rise EPSC fase. Since the effect of single vescicle release
    ** is kown to have an almost instantaneous effect on PSC we use a faster t_on
    ** t_on = 0.7 ms
    ** t_off = 11.1 +- 5.7 ms 
    ** t_off is long and it light be due to the glutammate spillover
    ** activating the extrasynaptic AMPA receptors 
    ** We use t_off = 1.2 ms */

    /* Modified by SS 30/04/2002
    ** We need to be able to set the AMPA receptor strength 
    ** indipendently on previous settings 
    ** since when the AMPA receptor is placed on the spine head
    ** it's scaled by its surface here we devide the gmax by the surface */
    float dia = 0.54e-6
    float surf = dia*dia*{PI}
    //- here we can keep control of the Gmax since the readcell 
    //   will add the spines (*rand_spines) without modify them
    float PC_AMPA_factor = 9
    float PC_AMPA_gmax =  {120e-12/surf * PC_AMPA_factor}
    float PC_AMPA_t_on = 0.7e-3
    float PC_AMPA_t_off = 1.2e-3
  
    /* asynchronously firing channel */
    if (!({exists non_NMDA}))
        	create synchan non_NMDA
    end
    
    setfield non_NMDA 	Ek {E_non_NMDA} \
        		tau1 {Calc_tau {Q10} 32 {temp} {PC_AMPA_t_on}} \
        		tau2 {Calc_tau {Q10} 32 {temp} {PC_AMPA_t_off}}   \
        	        frequency {0.0}
    
    G_par_syn = {{PC_AMPA_gmax}  * {Q10**{{{temp} - 32}/10}} }
    echo AMPA gmax = {G_par_syn}

    /* synchronously firing channel */
    if (!({exists non_NMDA2}))
        create synchan non_NMDA2
    end
  
    setfield non_NMDA2 Ek {E_non_NMDA} tau1 {0.50e-3} tau2 {1.20e-3}
  
  end
end