// Det_GABAtonic on gAMPA-Spike_Probability 8x seed_1_4.hoc
// Determine the effect of GABA at deifferent EGABA on spike probability during gAMPA Inputs
//
// GABA Synapses are Exp2-Synapses with physiological kinetic properties and
// a variable reversal potential and a defined conductance
//
// AMPA Synapses are Exp2-Synapses with physiological kinetic properties and
// a fixed reversal potential of -12 mV (from pAMPA = 0.5, e(Na) = 66, e(K) = -90) and fixed conductance
// Conductance determined with Det_gAMPA-Spike_Probability_1_2.hoc
// set at 0.15345 pS gives ca. 50% spike probability with the AMPA train (301 repetitions, seed-AMPA = 0)
//
// Author: Werner Kilb
// Version 1.4
// Date: 16-Apr-2021
//--------------------------------------------------
// Header Values ------------------------------------------------------
strdef VERSION, CELL, AP, DENOM, PROGRAM
PROGRAM = "AMPA_GABA_SpikeProbab_Raster"
VERSION = "2.0"
CELL = "Real"
AP = "ndrf"
gKaMax_ndrfAP = 0.0018 // adapt gK to prevent depolarization block during EPSPs
DENOM = "A"
VARIABLE = 0
//Parameters to define the frequency
StimStart = 50 //- Fixed
StimDuration = 2000
StimNumber = 20
StimFreq = StimNumber/StimDuration * 1000
tstop = StimStart+StimDuration+50
// Facor to calculate gAMPA with 50% Spike Probability according to Det_Spike_Probabl_gAMPA.hoc
if (StimFreq == 1) { gAMPAfact = 3.02 }
if (StimFreq == 2) { gAMPAfact = 2.43 }
if (StimFreq == 3) { gAMPAfact = 2.14 }
if (StimFreq == 5) { gAMPAfact = 1.81 }
if (StimFreq == 10) { gAMPAfact = 1.29 }
if (StimFreq == 20) { gAMPAfact = 0.90 }
// ------------Definition of Parameters -------------------------------
// seed Values for random generator
seed_GABA = 0 // seed for random function
seed_AMPA = seed_AMPA+3
// Determining Parameters GABA ---------------------------
gGABAfact = 1 // factor to adjust GABAergic effects
gGABA = 0.000789*gGABAfact // µS synaptic weight according to miniature events
GABA_Rise = 0.5 // ms arbitraray Value
GABA_Decay = 37 // ms from Lombardi et a. (2018)
GABA_Rev = -40.0 // Reversal Potential will be changed manually
nGABAsyn = StimNumber // Number of GABA synapses
nGABAinputs = 1 // number of inputs per synapse
// Determination Parameters AMPA ------------------------------------
gAMPA = 0.000305 * gAMPAfact// µS synaptic weight for ca. 50% Spike Probability
AMPA_Rise = 0.5 // ms arbitraray Value
AMPA_Decay = 11 // ms from Lombardi et a. (2018)
AMPA_Rev = -12 // mV Estmated reversal potential
nAMPAsyn = StimNumber // Number of GABA synapses
nAMPAinputs = 1 // number of inputs per synapse
// Definition of various runtime parameters --------------------------
v_init = -50.5 // Initial voltage
dt = 0.025 // Step Interval in ms
steps_per_ms = 2
celsius = 31 // measured at°C
ndend=56 // Number of dendrites
NumberRept = 300
APThresh = -10 // mV Thresholf for AP-detection algorithm
RunIndex = VARIABLE // counter for number or repetitions
LineInd = VARIABLE // Index for the element in output vectors
ON = 1
OFF = 0
// Define vectors to link modelled parameter output ---------------------------------
objref voltvec, timevec
voltvec = new Vector() // Vector used fors torage of voltage trace for further analysis
timevec = new Vector() // Vector
voltvec.record(&v(.5)) // Link Volt vector (mesured in soma) to Output-Vectors
timevec.record(&t) // Link time vector
// ---------Definition of synaptic objects -------------------------------------
// Objects for Synapses ---------------------------------------------------------
objref GABAsyn[nGABAsyn]
objref AMPAsyn[nAMPAsyn]
nDistDend = 17 // Number or Perisomatic dendrites
objref DistDend
DistDend = new Vector(nDistDend) // List of the perisomatic dendrites
DistDend.x[0] = 20
DistDend.x[1] = 30
DistDend.x[2] = 32
DistDend.x[3] = 34
DistDend.x[4] = 37
DistDend.x[5] = 38
DistDend.x[6] = 39
DistDend.x[7] = 43
DistDend.x[8] = 44
DistDend.x[9] = 47
DistDend.x[10] = 49
DistDend.x[11] = 50
DistDend.x[12] = 51
DistDend.x[13] = 52
DistDend.x[14] = 53
DistDend.x[15] = 54
DistDend.x[16] = 55
nProxDend = 12 // Number or Proximal dendrites
objref ProxDend
ProxDend = new Vector(nProxDend) // List of the Proximal dendrites
ProxDend.x[0] = 0
ProxDend.x[1] = 1
ProxDend.x[2] = 2
ProxDend.x[3] = 3
ProxDend.x[4] = 4
ProxDend.x[5] = 5
ProxDend.x[6] = 8
ProxDend.x[7] = 9
ProxDend.x[8] = 10
ProxDend.x[9] = 13
ProxDend.x[10] = 14
ProxDend.x[11] = 18
// random function for synapse definition
objref randAMPAloc, randGABAloc // random function for determination of dendrite number
objref randAMPAdend, randGABAdend // random function for localization of synapses in which dendrite
objref randGABAt, randGABAg // random function for synaptip parameters (timing and g)
objref randAMPAt, randAMPAg
// definition of Vectors for Gaba-Stimulation (t_vec = timestamps t_vecr = sorted timestamps, g_vec = rel conductance)
objref GABA_Stim[nGABAsyn], GABA_t_vec[nGABAsyn], GABA_t_vecr[nGABAsyn], NetCon_GABA[nGABAsyn], GABA_g_vec[nGABAsyn]
// definition of Vectors for AMPA-Stimulation
objref AMPA_Stim[nAMPAsyn], AMPA_t_vec[nAMPAsyn], AMPA_t_vecr[nAMPAsyn], NetCon_AMPA[nAMPAsyn], AMPA_g_vec[nAMPAsyn]
// ---- Output vectors and files ---------------------------------------------------------------------------------
objref TimeStamp_List
TimeStamp_List = new Vector() // Output Vector for one run() of the simulation, variable length
objref TimeStamp_Results // Matrix for outputs
// Definition of the output matrix
// Col[0] Col[1] Col[2] ... Repeated for each repitition
// Line[0] gAMPA gAMPA gAMPA
// Line[1] gGABA gGABA gGABA
// Line[2] seed seed seed
// Line[3] GABA_Rev GABA_Rev GABA_Rev
// Line[4] Rept1 Rept 2 Rept3
// Line[5] t[1st AP]
// .. t[n. AP]
// Variable length!!
TimeStamp_Results = new Matrix()
OutCol = VARIABLE // Set of Columns in the Results-Array
strdef OutSPRName // Define Name of Output-File for Rheo-Shift Matrix
objref OutSPRFile // Define Output File for Rheo-Shift Matrix
// ------- Init_Random() ------------------------------------------------------------------//
// Initializes the Random Functions //
// Input: seed_AMPA //
// Call: Init_Random() //
// Output: None //
//-----------------------------------------------------------------------------------------//
proc Init_Random() {
// Initialize Random Functions -----------
randAMPAloc = new Random(seed_AMPA+1)
randGABAloc = new Random(seed_GABA+2)
randAMPAdend = new Random(seed_AMPA+3)
randGABAdend = new Random(seed_GABA+4)
randAMPAt = new Random(seed_AMPA+5)
randAMPAg = new Random(seed_AMPA+6)
randGABAt = new Random(seed_GABA+7)
randGABAg = new Random(seed_GABA+8)
//Define properties of random Function
randGABAt.uniform(50, tstop - 50)
randGABAg.normal(1, 0.28) //rel variance of GABA according to results
randAMPAt.uniform(50, tstop - 50)
randAMPAg.normal(1, 0.26) //rel variance of AMPA according to results
// generate Vectors --- (nGABAinputs, nAMPAinputs defines number of inputs per synapse) ------
for i = 0, nGABAsyn-1 {
GABA_t_vec[i] = new Vector(nGABAinputs)
GABA_t_vecr[i] = new Vector(nGABAinputs)
GABA_g_vec[i] = new Vector(nGABAinputs)
}
for i = 0, nAMPAsyn-1 {
AMPA_t_vec[i] = new Vector(nAMPAinputs)
AMPA_t_vecr[i] = new Vector(nAMPAinputs)
AMPA_g_vec[i] = new Vector(nAMPAinputs)
}
} // end of proc InitRandom
// ------- Procedure Distr_GABA_Synapses --------------------------------------------------//
// Distributes the GABA synpases across the dendrite //
// Input: None //
// Uses global variables: GABA_Rise, GABA_Decay, GABA_Rev //
// Call: Distr_GABA_Synapses() //
// Output: None //
// Note that in this project GABA synapses were simulated as Exp2Syn with variable eRev //
//-----------------------------------------------------------------------------------------//
proc Distr_GABA_Synapses(){local k
for k=0, nGABAsyn-1 {
pos = randGABAloc.uniform(0,ndend-1)
pos2 = randGABAdend.uniform (0.0001, 0.999)
dend_0[pos]{
GABAsyn[k] = new Exp2Syn(pos2)
GABAsyn[k].tau1 = GABA_Rise
GABAsyn[k].tau2 = GABA_Decay
GABAsyn[k].e = GABA_Rev
}
}
} // end of proc Distr_GABA_Synapses()
// ------- Procedure Distr_AMPA_Synapses --------------------------------------------------//
// Distributes the AMPA synpases across the dendrite //
// Input: None //
// Uses global constants: AMPA_Rise, AMPA_Decay //
// Call: Distr_AMPA_Synapses() //
// Output: None //
// Note that in this project AMPA synapses were simulated as Exp2Syn //
//-----------------------------------------------------------------------------------------//
proc Distr_AMPA_Synapses(){local k
for k=0, nAMPAsyn-1 {
pos = randAMPAloc.uniform(0,ndend-1)
pos3 = randAMPAdend.uniform (0.5, 0.999)
dend_0[pos]{
AMPAsyn[k] = new Exp2Syn(pos3)
AMPAsyn[k].tau1 = AMPA_Rise
AMPAsyn[k].tau2 = AMPA_Decay
AMPAsyn[k].e = AMPA_Rev
}
}
} // end of proc Distr_AMPA_Synapses()
// ------- Procedure generateGABAinputs --------------------------------------------------//
// Generates the random inputs to the GABA synapses //
// Input: $1 = gGABA //
// $2 = GABA_Rev //
// Call: generateGABAinputs(gGABA*gGABAfact, GABA_Rev) //
// Output: None //
//-----------------------------------------------------------------------------------------//
proc generateGABAinputs(){local f, i, g
// pick random values for time t and conductance g
for f=0, nGABAsyn-1 {
GABAsyn[f].e = $2
for i=0, nGABAinputs-1 {
t = randGABAt.repick()
g = abs(randGABAg.repick()*$1)
GABA_t_vec[f].x[i]= t
GABA_g_vec[f].x[i]= g
}
}
// sort the timestamps
for f=0, nGABAsyn-1 {
GABA_t_vecr[f] = GABA_t_vec[f].sort()
}
// generate vecstim-Element from the sorted timestamp-vectors -------------------------------
for f=0, nGABAsyn-1 {
GABA_Stim[f] = new VecStim()
GABA_Stim[f].play(GABA_t_vecr[f])
}
// link GABA-vecstim object via NetCon objects to the synapses ---------------------------------------------
for f=0, nGABAsyn-1 {
NetCon_GABA[f] = new NetCon(GABA_Stim[f], GABAsyn[f], 0, 0, GABA_g_vec[f].x[0])
}
} // end of generateGABAinputs()
// ------- Procedure generateAMPAinputs --------------------------------------------------//
// Generates the random inputs to the AMPA synapses //
// Input: $1 = gAMPAvalue //
// Call: generateAMPAinputs(gAMPA) //
// Output: None //
//-----------------------------------------------------------------------------------------//
proc generateAMPAinputs(){local f, i, g
// pick random values for time t and conductance g
for f=0, nAMPAsyn-1 {
for i=0, nAMPAinputs-1 {
t = randAMPAt.repick()
g = abs(randAMPAg.repick()*$1)
AMPA_t_vec[f].x[i]= t
AMPA_g_vec[f].x[i]= g
}
}
for f=0, nAMPAsyn-1 {
AMPA_t_vecr[f] = AMPA_t_vec[f].sort() // sort the timestamps
}
// generate vecstim-elements from the sorted timestamp-vectors -------------------------------
for i=0, nAMPAsyn-1{
AMPA_Stim[i] = new VecStim()
AMPA_Stim[i].play(AMPA_t_vecr[i]) // AMPA stimulator
}
// link GABA-vecstim object via NetCon objects to the synapses ---------------------------------------------
for i=0, nAMPAsyn-1 {
NetCon_AMPA[i] = new NetCon(AMPA_Stim[i], AMPAsyn[i], 0, 0, AMPA_g_vec[i].x[0])
}
} // end of generateAMPAinputs()
// Procedure Pause -----------------------------------------------------------------------------//
// Inputs: none //
// Call: Pause(s) //
// stops excecution fo s seconds //
// ---------------------------------------------------------------------------------------------//
proc pause() { local t0
t0 = startsw()
while (startsw()-t0 < $1) { }
}
// Function Detect_APs --------------------------------------------------------------------------//
// Inputs: $1 Objref to voltvec //
// $2 Theshold in mV //
// $3 Objref to timevec //
// //
// call Detect_APs(voltvec, APThresh, timevec) //
// returns Number of APs as double //
// //
// Detets the numer of APs in a voltvector //
// ----------------------------------------------------------------------------------------------//
proc Detect_APs() {local i, Refract, APs
Refract = 0
for i=0, $o1.size-1 {
if (Refract == 0 && $o1.x[i]>$2){ //look for v crossing threshold in depolarizing direction for whole voltvec
// AP detected by one
TimeStamp_List.append($o3.x[i])
Refract = 1 // switch to refractory period
}
if (Refract == 1 && $o1.x[i]<$2-5){ //look for v crossing threshold in hyperpolarizing direction
// implemented 5 mV security interval here to omit triggering by noise
Refract = 0 // refractory period ends
}
}
} // End of function
//--DetermineSpikeProbab--------------------------------------------------------------------------//
// Determines the Spike Probability for the n= IntSteps gAMPA Steps between gMin and gMax //
// Stores the spike Probability in the OutMatrix (global) //
// Actualized new gMin and gMax values (the two values closest to 50% spike Probability //
// Input: $1 conductance of the AMPA synapse //
// $2 seed Value for seed AMPA //
// Uses the global variable LineInd for output in vectors //
// Call: DetermineSpikeProbab(gAMPA*gAMPAfact, seed_AMPA) //
// Output: None //
//------------------------------------------------------------------------------------------------//
proc DetermineSpikeProbab(){local Rept, SumAPs, NumberSupra
Init_Random($2) // induce repetitions with different seed values
SumAPs = 0 // reset AP number counter
NumberSupra = 0 // reset number of suprathreshold repetitions
for Rept = 1, NumberRept{
// redistribute the synapses
Distr_AMPA_Synapses() // distribute AMPA synapses randomly
generateAMPAinputs($1) // generate random glutamatergic inputs
Distr_GABA_Synapses()
generateGABAinputs(gGABA, GABA_Rev)
Init_Out_Vector(TimeStamp_List,gAMPA,seed_AMPA,Rept)
// run and analyse the simulation
run()
Detect_APs(voltvec, APThresh, timevec) // put stike times in TimeStamp_List
printf("Spike times for repetition %g ",Rept)
TimeStamp_List.printf()
Add_To_Results(TimeStamp_List)
} // end of for (Rept...)
// store the information
}// End of procedure DetermineSpikeProbab()
// Procedure Init_Out_Vector ------------------------------------------------------------------------//
// Clears the three data-output vectors //
// Inputs: $1 ObjRef to ERev_List //
// $2 gAMPA //
// $3 Seed //
// $4 Rept //
// Call: Init_Out_Vector(TimeStamp_List,gAMPA,gGABA_List.x[gGABA_Step -1],Seed_AMPA,GABA_Rev,Rept) //
// ---------------------------------------------------------------------------------------------------//
proc Init_Out_Vector() {
$o1.resize(5)
$o1.x[0] = $2*1000
$o1.x[1] = $3
$o1.x[2] = $4
} // end of proc
// Function Max() ---------------------------------------------------------------------//
// Provides the larger Values of 2 elements //
// Inputs: $1 Element 1 //
// $2 Element 2 //
// Call : Max(TimeStamp_List.size(), TimeStamp_Results.nrow()) //
// Output: The larger of the two input values //
// ------------------------------------------------------------------------------------//
func Max(){
if ($1 > $2){
return $1
} else {
return $2
}
}
// Procedure Add_To_Results ---------------------------------------------------------------------//
// Transferes the results from one Synapse position (in One-Parameter Vector) to Results array //
// Inputs: $1 ObjRef to TimeStamp_List //
// Call: Add_To_Results(TimeStamp_List) //
// Other Variables are global variables //
// ----------------------------------------------------------------------------------------------//
proc Add_To_Results() {local MaxRow
MaxRow = Max(TimeStamp_List.size(), TimeStamp_Results.nrow()) // Determines if Time Stap list has more elements that rows in output array
TimeStamp_Results.resize(MaxRow, TimeStamp_Results.ncol()+1) // New colums, ev new lines to output array
TimeStamp_Results.setcol(TimeStamp_Results.ncol()-1, $o1) // copy TimeStamp_List in the last Column of the TimeStamp_Results Array
} // end of proc
//--savedata-------------------------------------------------------------------------------//
// Stores the results array TimeStamp_Results in a File //
// Input: Result Array //
// Call: savedata(TimeStamp_Results) //
// Output: None //
// Globals: OutRow will be actualized //
//-----------------------------------------------------------------------------------------//
proc savedata(){
OutSPRFile = new File()
sprint(OutSPRName, "Results_%s-%s%s-%s-%s_AMPA%gpS_GABA%gpS_E-GABA%gmV-%gHz.asc", PROGRAM, VERSION, DENOM, CELL, AP, gAMPA*1000, gGABA*1000, GABA_Rev, StimFreq)
OutSPRFile.wopen(OutSPRName)
$o1.fprint(OutSPRFile, "\t%g")
OutSPRFile.close
}
// ________________________________________________________________________________________________
// ---- Start of Simulation -----------------------------------------------------------------------
// ________________________________________________________________________________________________
printf("Start Program_%s-%s%s-%s-%s_AMPA%gpS_GABA%gpS-_E-GABA%gmV-%gHz", PROGRAM, VERSION, DENOM, CELL, AP, gAMPA*1000, gGABA*1000, GABA_Rev, StimFreq)
// determine spike probability performed n = NumberRept repition of the simulations, each with random location/timing/strength of AMPA synapses
DetermineSpikeProbab(gAMPA, seed_AMPA)
printf("\n -- Simulation finished -- \n\n")
savedata(TimeStamp_Results)
printf("Program_%s-%s%s-%s-%s_AMPA%gpS_GABA%gpS_eGABA%gmV)", PROGRAM, VERSION, DENOM, CELL, AP, gAMPA*1000, gGABA*1000,GABA_Rev)
printf(" terminated")
printf(" sucesfully")