-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsahp.go
112 lines (89 loc) · 3.16 KB
/
sahp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) 2022, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package chans
import "cogentcore.org/core/math32"
//gosl:start chans
// SahpParams implements a slow afterhyperpolarizing (sAHP) channel,
// It has a slowly accumulating calcium value, aggregated at the
// theta cycle level, that then drives the logistic gating function,
// so that it only activates after a significant accumulation.
// After which point it decays.
// For the theta-cycle updating, the normal m-type tau is all within
// the scope of a single theta cycle, so we just omit the time integration
// of the n gating value, but tau is computed in any case.
type SahpParams struct {
// strength of sAHP current
Gbar float32 `default:"0.05,0.1"`
// time constant for integrating Ca across theta cycles
CaTau float32 `default:"5,10"`
// integrated Ca offset (threshold) for infinite time N gating function -- where the gate is at 50% strength
Off float32 `default:"0.8"`
// slope of the infinite time logistic gating function
Slope float32 `default:"0.02"`
// maximum slow rate time constant in msec for activation / deactivation. The effective Tau is much slower -- 1/20th in original temp, and 1/60th in standard 37 C temp
TauMax float32 `default:"1"`
// 1/Tau
CaDt float32 `display:"-" edit:"-"`
// 1/Tau
DtMax float32 `display:"-" edit:"-"`
pad int32
}
// Defaults sets the parameters
func (mp *SahpParams) Defaults() {
mp.Gbar = 0.05
mp.CaTau = 5
mp.Off = 0.8
mp.Slope = 0.02
mp.TauMax = 1
mp.Update()
}
func (mp *SahpParams) Update() {
mp.DtMax = 1.0 / mp.TauMax
mp.CaDt = 1.0 / mp.CaTau
}
func (mp *SahpParams) ShouldDisplay(field string) bool {
switch field {
case "Gbar":
return true
default:
return mp.Gbar > 0
}
}
// EFun handles singularities in an elegant way -- from Mainen impl
func (mp *SahpParams) EFun(z float32) float32 {
if math32.Abs(z) < 1.0e-4 {
return 1.0 - 0.5*z
}
return z / (math32.FastExp(z) - 1.0)
}
// NinfTauFromCa returns the target infinite-time N gate value and
// time constant tau, from integrated Ca value
func (mp *SahpParams) NinfTauFromCa(ca float32, ninf, tau *float32) {
co := ca - mp.Off
// logical functions, but have signularity at Voff (vo = 0)
// a := mp.DtMax * vo / (1.0 - math32.FastExp(-vo/mp.Vslope))
// b := -mp.DtMax * vo / (1.0 - math32.FastExp(vo/mp.Vslope))
a := mp.DtMax * mp.Slope * mp.EFun(-co/mp.Slope)
b := mp.DtMax * mp.Slope * mp.EFun(co/mp.Slope)
*tau = 1.0 / (a + b)
*ninf = a * *tau // a / (a+b)
return
}
// CaInt returns the updated time-integrated Ca value from current value and current Ca
func (mp *SahpParams) CaInt(caInt, ca float32) float32 {
return caInt + mp.CaDt*(ca-caInt)
}
// DNFromCa returns the change in gating factor N based on integrated Ca
// Omit this and just use ninf directly for theta-cycle updating.
func (mp *SahpParams) DNFromV(ca, n float32) float32 {
var ninf, tau float32
mp.NinfTauFromCa(ca, &ninf, &tau)
dn := (ninf - n) / tau
return dn
}
// GsAHP returns the conductance as a function of n
func (mp *SahpParams) GsAHP(n float32) float32 {
return mp.Gbar * n
}
//gosl:end chans