From 1a9e3d5f3fb420bae6a1ddd8af83a77e77e73fb2 Mon Sep 17 00:00:00 2001
From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com>
Date: Mon, 5 Aug 2024 13:20:44 +0200
Subject: [PATCH] Add Allen Institute's Exp2Syn to Arbor. (#2293)

Add the Allen Institute flavoured Exp2Syn to the Allen catalogue.
---
 mechanisms/CMakeLists.txt    |  2 +-
 mechanisms/allen/Exp2Syn.mod | 80 ++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 1 deletion(-)
 create mode 100644 mechanisms/allen/Exp2Syn.mod

diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt
index de0718e5..a16fe6c0 100644
--- a/mechanisms/CMakeLists.txt
+++ b/mechanisms/CMakeLists.txt
@@ -11,7 +11,7 @@ make_catalogue(
 
 make_catalogue(
   NAME allen
-  MOD CaDynamics Ca_HVA Ca_LVA Ih Im Im_v2 K_P K_T Kd Kv2like Kv3_1 NaTa NaTs NaV Nap SK
+  MOD CaDynamics Ca_HVA Ca_LVA Ih Im Im_v2 K_P K_T Kd Kv2like Kv3_1 NaTa NaTs NaV Nap SK Exp2Syn
   VERBOSE ${ARB_CAT_VERBOSE}
   ADD_DEPS ON)
 
diff --git a/mechanisms/allen/Exp2Syn.mod b/mechanisms/allen/Exp2Syn.mod
new file mode 100644
index 00000000..b9cd2f7b
--- /dev/null
+++ b/mechanisms/allen/Exp2Syn.mod
@@ -0,0 +1,80 @@
+COMMENT
+
+Two state kinetic scheme synapse described by rise time tau1,
+and decay time constant tau2. The normalized peak condunductance is 1.
+Decay time MUST be greater than rise time.
+
+The solution of A->G->bath with rate constants 1/tau1 and 1/tau2 is
+ A = a*exp(-t/tau1) and
+ G = a*tau2/(tau2-tau1)*(-exp(-t/tau1) + exp(-t/tau2))
+    where tau1 < tau2
+
+If tau2-tau1 is very small compared to tau1, this is an alphasynapse with time constant tau2.
+If tau1/tau2 is very small, this is single exponential decay with time constant tau2.
+
+The factor is evaluated in the initial block
+such that an event of weight 1 generates a
+peak conductance of 1.
+
+Because the solution is a sum of exponentials, the
+coupled equations can be solved as a pair of independent equations
+by the more efficient cnexp method.
+
+ENDCOMMENT
+
+NEURON {
+    POINT_PROCESS Exp2Syn
+    RANGE tau1, tau2, erev
+    NONSPECIFIC_CURRENT i
+}
+
+UNITS {
+    (nA) = (nanoamp)
+    (mV) = (millivolt)
+    (uS) = (microsiemens)
+}
+
+PARAMETER {
+    v (mV)
+    tau1 = 0.1 (ms) <1e-9,1e9>
+    tau2 = 10 (ms) <1e-9,1e9>
+    erev = 0 (mV)
+}
+
+ASSIGNED {
+    factor
+}
+
+STATE {
+    A (uS)
+    B (uS)
+}
+
+INITIAL {
+    LOCAL tp
+    : NOTE Arbor doesn't allow this, so removed for now
+    :if (tau1 > 0.9999*tau2) { tau1 = 0.9999*tau2 }
+    :if (tau1 <   1e-9*tau2) { tau1 = tau2*1e-9   }
+    A = 0
+    B = 0
+    tp = (tau1*tau2)/(tau2 - tau1) * log(tau2/tau1)
+    factor = -exp(-tp/tau1) + exp(-tp/tau2)
+    factor = 1/factor
+}
+
+BREAKPOINT {
+    SOLVE state METHOD cnexp
+    LOCAL g
+    g = B - A
+    i = g*(v - erev)
+}
+
+DERIVATIVE state {
+    A' = -A/tau1
+    B' = -B/tau2
+}
+
+NET_RECEIVE(weight (uS)) {
+    A = A + weight*factor
+    B = B + weight*factor
+}
-- 
GitLab