//Created by Paulo Aguiar [pauloaguiar@fc.up.pt]

// CREATE WDR NEURON

begintemplate WDRwithoutinter

public soma, dendrite, hillock, axon

create soma, dendrite, hillock, axon

proc init() {
    
    create soma      // create a section called soma
    soma {    
        nseg = 3     // define number of segments for discretization
        L = 20.0     // define length of compartment
        diam = 20.0  // define diameter of compartment

        //HH channels: iNat and iK
        insert HH2 {    // insert the density mechanism HH2 as defined by a .mod file, and set some of its parameter values
            gnabar_HH2 = 0.08
            gkbar_HH2 = 0.02
            vtraub_HH2 = -55.0
        }

        //intracellular Ca dynamics
        insert CaIntraCellDyn {
            depth_CaIntraCellDyn = 0.1
            cai_tau_CaIntraCellDyn = 1.0
            cai_inf_CaIntraCellDyn = 50.0e-6
        }

        //high-voltage activated long-lasting calcium current, L-type
        insert iCaL {
            pcabar_iCaL = 0.0001 //0.0001 - IMPORTANT: this current drives the (activity control) somatic iKCa current
        }

        //non-specific current dependent on intracellular calcium concentration
        insert iCaAN {
            gbar_iCaAN = 0.0 //0.0
        }

        //potassium current dependent on intracellular calcium concentration
        insert iKCa {
            gbar_iKCa = 0.002 //0.0001
        }

        //sodium persistent current
        insert iNaP {
            gnabar_iNaP = 0.0001 //0.0001
        }

        ek = -70.0    // set inversion potential of potassium for all mechanisms of soma

        Ra = 150.0    // set axial resistivity of soma

        insert pas   // pas (for passive) is a predefined mechanism modeling leak current through the membrane
        g_pas = 4.2e-5
        e_pas = -65.0
    }
    
    create dendrite
    dendrite {    
        nseg = 5
        L = 500.0
        diam = 4.0

        //intracellular Ca dynamics
        insert CaIntraCellDyn {
            depth_CaIntraCellDyn = 0.1
            cai_tau_CaIntraCellDyn = 2.0
            cai_inf_CaIntraCellDyn = 50.0e-6
        }

        //high-voltage activated long-lasting calcium current, L-type
        insert iCaL {
            pcabar_iCaL = 3.0e-5 //3.0e-5 IMPORTANT: this current is important for activity control (drives the iKCa current)
        }

        //non-specific current dependent on intracellular calcium concentration
        insert iCaAN {
            gbar_iCaAN = 0.00007 //0.00007; This is a sensible parameter
            //higher values of gbar_iCaAN produce graphs similar to Silviloti et al 93
        }

        //potassium current dependent on intracellular calcium concentration
        insert iKCa {
            gbar_iKCa = 0.0025 //0.001; higher values place "holes" in the scatter plot, resulting from the cai bump after synaptic activation);
            //naturally, lower values will lead to increased firing
        }

        ek = -70.0

        Ra = 150.0

        insert pas
        g_pas = 4.2e-5
        e_pas = -65.0
    }
    
    
    create hillock
    hillock {   
        nseg = 3
        L = 3
        diam(0:1) = 2.0:1.0    // diameter varies from 2 microns at the 0 end of the section to 1 micron at the other end

        //HH channels: iNa,t and iK
        insert HH2 {
            gnabar_HH2 = 0.1
            gkbar_HH2 = 0.04
            vtraub_HH2 = -55.0
        }

        Ra = 150.0

        insert pas
        g_pas = 4.2e-5
        e_pas = -65.0
    }
    
    create axon
    axon {    
        nseg = 5
        L = 1000.0
        diam = 1.0

        //HH channels: iNa,t and iK
        insert HH2 {
            gnabar_HH2 = 0.1
            gkbar_HH2 = 0.04	//0.04
            vtraub_HH2 = -55
        }

        Ra = 150.0

        insert pas
        g_pas = 4.2e-5
        e_pas = -65.0
    }
    
    
    //CONNECTIONS
    soma connect hillock(0),1   // connect the 0 ending of hillock to the 1 ending of soma
    hillock connect axon(0),1
    soma connect dendrite(0),0 
    
}


endtemplate WDRwithoutinter





//************************************************************************************
//UNITS	    
//Category									Variable			Units
//Time											t							[ms]
//Voltage										v							[mV]
//Current										i							[mA/cm2] (distributed)	[nA] (point process)
//Concentration							ko, ki, etc.	[mM]
//Specific capacitance			cm						[uf/cm2]
//Length										diam, L				[um]
//Conductance								g							[S/cm2] (distributed)	[uS] (point process)
//Cytoplasmic resistivity		Ra						[ohm cm]
//Resistance								Ri						[10E6 ohm]