Skip to content

Commit 974e05b

Browse files
committed
gabab plot updates
1 parent 37653e2 commit 974e05b

File tree

6 files changed

+75
-92
lines changed

6 files changed

+75
-92
lines changed

chans/chanplots/gabab-plot.go

Lines changed: 59 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -17,106 +17,92 @@ import (
1717
"github.com/emer/axon/v2/chans"
1818
)
1919

20-
type GababPlot struct {
20+
type GABABPlot struct {
2121
// standard chans version of GABAB
22-
GABAstd chans.GABABParams
22+
GABAB chans.GABABParams `display:"add-fields"`
2323

24-
// multiplier on GABAb as function of voltage
25-
GABAbv float64 `default:"0.1"`
24+
// multiplier on GABA-B as function of voltage
25+
Vgain float64 `default:"0.1"`
2626

27-
// offset of GABAb function
28-
GABAbo float64 `default:"10"`
27+
// voltage offset for GABA-B exponential function
28+
Voff float64 `default:"10"`
2929

3030
// GABAb reversal / driving potential
31-
GABAberev float64 `default:"-90"`
31+
Erev float64 `default:"-90"`
3232

3333
// starting voltage
3434
Vstart float64 `default:"-90"`
3535

3636
// ending voltage
37-
Vend float64 `default:"0"`
37+
Vend float64 `default:"10"`
3838

3939
// voltage increment
4040
Vstep float64 `default:"1"`
4141

4242
// max number of spikes
43-
Smax int `default:"15"`
44-
45-
// rise time constant
46-
RiseTau float64
47-
48-
// decay time constant -- must NOT be same as RiseTau
49-
DecayTau float64
50-
51-
// initial value of GsX driving variable at point of synaptic input onset -- decays expoentially from this start
52-
GsXInit float64
53-
54-
// time when peak conductance occurs, in TimeInc units
55-
MaxTime float64 `edit:"-"`
56-
57-
// time constant factor used in integration: (Decay / Rise) ^ (Rise / (Decay - Rise))
58-
TauFact float64 `edit:"-"`
43+
Smax int `default:"30"`
5944

6045
// total number of time steps to take
6146
TimeSteps int
6247

6348
// time increment per step
6449
TimeInc float64
6550

51+
// time in msec for inputs to remain on in TimeRun
52+
TimeIn int
53+
54+
// frequency of spiking inputs at start of TimeRun
55+
TimeHz float64
56+
6657
Dir *tensorfs.Node `display:"-"`
6758
Tabs lab.Tabber `display:"-"`
6859
}
6960

7061
// Config configures all the elements using the standard functions
71-
func (pl *GababPlot) Config(parent *tensorfs.Node, tabs lab.Tabber) {
62+
func (pl *GABABPlot) Config(parent *tensorfs.Node, tabs lab.Tabber) {
7263
pl.Dir = parent.Dir("GabaB")
7364
pl.Tabs = tabs
7465

75-
pl.GABAstd.Defaults()
76-
pl.GABAstd.GiSpike = 1
77-
pl.GABAbv = 0.1
78-
pl.GABAbo = 10
79-
pl.GABAberev = -90
66+
pl.GABAB.Defaults()
67+
pl.GABAB.GiSpike = 1
68+
pl.Vgain = 0.1
69+
pl.Voff = 10
70+
pl.Erev = -90
8071
pl.Vstart = -90
81-
pl.Vend = 0
82-
pl.Vstep = .01
72+
pl.Vend = 10
73+
pl.Vstep = 1
8374
pl.Smax = 30
84-
pl.RiseTau = 45
85-
pl.DecayTau = 50
86-
pl.GsXInit = 1
87-
pl.TimeSteps = 200
75+
pl.TimeSteps = 500
8876
pl.TimeInc = .001
77+
pl.TimeIn = 100
78+
pl.TimeHz = 50
8979
pl.Update()
9080
}
9181

9282
// Update updates computed values
93-
func (pl *GababPlot) Update() {
94-
pl.TauFact = math.Pow(pl.DecayTau/pl.RiseTau, pl.RiseTau/(pl.DecayTau-pl.RiseTau))
95-
pl.MaxTime = ((pl.RiseTau * pl.DecayTau) / (pl.DecayTau - pl.RiseTau)) * math.Log(pl.DecayTau/pl.RiseTau)
83+
func (pl *GABABPlot) Update() {
84+
pl.GABAB.Update()
9685
}
9786

9887
// GVRun plots the conductance G (and other variables) as a function of V.
99-
func (pl *GababPlot) GVRun() { //types:add
88+
func (pl *GABABPlot) GVRun() { //types:add
10089
pl.Update()
10190
dir := pl.Dir.Dir("G_V")
10291

10392
nv := int((pl.Vend - pl.Vstart) / pl.Vstep)
104-
v := 0.0
105-
g := 0.0
10693
for vi := range nv {
107-
v = pl.Vstart + float64(vi)*pl.Vstep
108-
g = float64(pl.GABAstd.Gbar) * (v - pl.GABAberev) / (1 + math.Exp(pl.GABAbv*((v-pl.GABAberev)+pl.GABAbo)))
109-
gs := pl.GABAstd.Gbar * pl.GABAstd.GFromV(chans.VFromBio(float32(v)))
94+
v := pl.Vstart + float64(vi)*pl.Vstep
95+
g := float64(pl.GABAB.Gbar) / (1 + math.Exp(pl.Vgain*((v-pl.Erev)+pl.Voff)))
96+
i := (v - pl.Erev) * g
11097

11198
dir.Float64("V", nv).SetFloat1D(v, vi)
112-
dir.Float64("GgabaB", nv).SetFloat1D(g, vi)
113-
dir.Float64("GgabaBstd", nv).SetFloat1D(float64(gs), vi)
99+
dir.Float64("Ggaba_b", nv).SetFloat1D(g, vi)
100+
dir.Float64("Igaba_b", nv).SetFloat1D(i, vi)
114101
}
115-
metadata.SetDoc(dir.Float64("GgabaBstd"), "std is from code actually used in models")
116102
plot.SetFirstStyler(dir.Float64("V"), func(s *plot.Style) {
117103
s.Role = plot.X
118104
})
119-
ons := []string{"GgabaB"}
105+
ons := []string{"Ggaba_b", "Igaba_b"}
120106
for _, on := range ons {
121107
plot.SetFirstStyler(dir.Float64(on), func(s *plot.Style) {
122108
s.On = true
@@ -128,24 +114,19 @@ func (pl *GababPlot) GVRun() { //types:add
128114
}
129115
}
130116

131-
// GSRun plots conductance over spiking.
132-
func (pl *GababPlot) GSRun() { //types:add
117+
// GSRun plots conductance as function of spiking rate.
118+
func (pl *GABABPlot) GSRun() { //types:add
133119
pl.Update()
134120
dir := pl.Dir.Dir("G_Spike")
135121

136122
nv := int(float64(pl.Smax) / pl.Vstep)
137-
s := 0.0
138-
g := 0.0
139123
for si := range nv {
140-
s = float64(si) * pl.Vstep
141-
g = 1.0 / (1.0 + math.Exp(-(s-7.1)/1.4))
142-
gs := pl.GABAstd.GFromS(float32(s))
124+
s := float64(si) * pl.Vstep
125+
g := 1.0 / (1.0 + math.Exp(-(s-7.1)/1.4))
143126

144127
dir.Float64("S", nv).SetFloat1D(s, si)
145128
dir.Float64("GgabaB_max", nv).SetFloat1D(g, si)
146-
dir.Float64("GgabaBstd_max", nv).SetFloat1D(float64(gs), si)
147129
}
148-
metadata.SetDoc(dir.Float64("GgabaBstd_max"), "std is from code actually used in models")
149130
plot.SetFirstStyler(dir.Float64("S"), func(s *plot.Style) {
150131
s.Role = plot.X
151132
})
@@ -162,37 +143,35 @@ func (pl *GababPlot) GSRun() { //types:add
162143
}
163144

164145
// TimeRun runs the equations over time.
165-
func (pl *GababPlot) TimeRun() { //types:add
146+
func (pl *GABABPlot) TimeRun() { //types:add
166147
pl.Update()
167148
dir := pl.Dir.Dir("G_Time")
168149
nv := pl.TimeSteps
169150

170151
time := 0.0
171152
gs := 0.0
172-
x := pl.GsXInit
173-
gabaBx := float32(pl.GsXInit)
174-
gabaB := float32(0.0)
175-
gi := 0.0 // just goes down
176-
for t := range nv {
153+
x := 0.0
154+
spikeInt := int(1000 / pl.TimeHz)
155+
for ti := range nv {
156+
sin := 0.0
157+
if ti >= 10 && ti < (10+pl.TimeIn) && (ti-10)%spikeInt == 0 {
158+
sin = 1
159+
}
160+
177161
// record starting state first, then update
178-
dir.Float64("Time", nv).SetFloat1D(float64(time), t)
179-
dir.Float64("GabaB", nv).SetFloat1D(float64(gs), t)
180-
dir.Float64("GabaBX", nv).SetFloat1D(float64(x), t)
181-
dir.Float64("GabaBstd", nv).SetFloat1D(float64(gabaB), t)
182-
dir.Float64("GabaBXstd", nv).SetFloat1D(float64(gabaBx), t)
183-
184-
gis := 1.0 / (1.0 + math.Exp(-(gi-7.1)/1.4))
185-
dGs := (pl.TauFact*x - gs) / pl.RiseTau
186-
dXo := -x / pl.DecayTau
162+
dir.Float64("Time", nv).SetFloat1D(time, ti)
163+
dir.Float64("GabaB", nv).SetFloat1D(gs, ti)
164+
dir.Float64("GabaBX", nv).SetFloat1D(x, ti)
165+
166+
gis := 1.0 / (1.0 + math.Exp(-(sin-7.1)/1.4))
167+
dGs := (float64(pl.GABAB.TauFact)*x - gs) / float64(pl.GABAB.RiseTau)
168+
dXo := -x / float64(pl.GABAB.DecayTau)
187169
gs += dGs
188170
x += gis + dXo
189171

190-
var dG, dX float32
191-
pl.GABAstd.BiExp(gabaB, gabaBx, &dG, &dX)
192-
dir.Float64("dG", nv).SetFloat1D(float64(dG), t)
193-
dir.Float64("dX", nv).SetFloat1D(float64(dX), t)
194-
195-
pl.GABAstd.GABAB(float32(gi), &gabaB, &gabaBx)
172+
dir.Float64("dG", nv).SetFloat1D(dGs, ti)
173+
dir.Float64("dX", nv).SetFloat1D(dXo, ti)
174+
dir.Float64("Xmax", nv).SetFloat1D(gis, ti)
196175

197176
time += pl.TimeInc
198177
}
@@ -213,7 +192,7 @@ func (pl *GababPlot) TimeRun() { //types:add
213192
}
214193
}
215194

216-
func (pl *GababPlot) MakeToolbar(p *tree.Plan) {
195+
func (pl *GABABPlot) MakeToolbar(p *tree.Plan) {
217196
tree.Add(p, func(w *core.FuncButton) {
218197
w.SetFunc(pl.GVRun).SetIcon(icons.PlayArrow)
219198
})

chans/gabab.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"cogentcore.org/core/math32"
99
)
1010

11-
//gosl:start chans
11+
//gosl:start
1212

1313
// GABA-B is an inhibitory channel activated by the usual GABA inhibitory neurotransmitter,
1414
// which is coupled to the GIRK G-protein coupled inwardly rectifying potassium (K) channel.
@@ -92,19 +92,17 @@ func (gp *GABABParams) GFromS(s float32) float32 {
9292
return 1.0 / (1.0 + math32.FastExp(-(ss-7.1)/1.4))
9393
}
9494

95-
// BiExp computes bi-exponential update, returns dG and dX deltas to add to g and x
96-
func (gp *GABABParams) BiExp(g, x float32, dG, dX *float32) {
97-
*dG = (gp.TauFact*x - g) * gp.RiseDt
98-
*dX = -x * gp.DecayDt
99-
return
95+
// DeltaG computes the change in conductance based on the current
96+
// conductance g and the spike integration factor x.
97+
func (gp *GABABParams) DeltaG(g, x float32) float32 {
98+
return (gp.TauFact*x - g) * gp.RiseDt
10099
}
101100

102101
// GABAB returns the updated GABA-B / GIRK activation and underlying x value
103102
// based on current values and gi inhibitory conductance (proxy for GABA spikes)
104103
func (gp *GABABParams) GABAB(gi float32, gabaB, gabaBx *float32) {
105-
var dG, dX float32
106-
gp.BiExp(*gabaB, *gabaBx, &dG, &dX)
107-
*gabaBx += gp.GFromS(gi) + dX // gets new input
104+
dG := gp.DeltaG(*gabaB, *gabaBx)
105+
*gabaBx += gp.GFromS(gi) - (*gabaBx)*gp.DecayDt
108106
*gabaB += dG
109107
return
110108
}
@@ -115,4 +113,4 @@ func (gp *GABABParams) GgabaB(gabaB, vm float32) float32 {
115113
return gp.Gbar * gp.GFromV(vm) * (gabaB + gp.Gbase)
116114
}
117115

118-
//gosl:end chans
116+
//gosl:end

sims/bgdorsal/params.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var LayerParams = axon.LayerSheets{
1818
ly.Acts.Noise.Ge = 0.0001 // 0.0001 > others; could just be noise ;)
1919
ly.Acts.Noise.Gi = 0.0001 // 0.0001 perhaps better than others
2020
ly.Learn.RLRate.SigmoidLinear.SetBool(false) // false >> true; orig = true
21+
// ly.Acts.NMDA.Tau = 100 // 100 def >> 200
22+
// ly.Learn.LearnNMDA.Tau = 100 // 100 def >> 200
2123
}},
2224
{Sel: ".PFCLayer", Doc: "pfc",
2325
Set: func(ly *axon.LayerParams) {

sims/equations/equations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type Plots struct {
4545
// The inward rectification is caused by a Mg+ ion block *from the inside* of the neuron,
4646
// which means that these channels are most open when the neuron is hyperpolarized (inactive),
4747
// and thus it serves to keep inactive neurons inactive. Based on Thomson & Destexhe (1999).
48-
GABAB chanplots.GababPlot `new-window:"+" display:"no-inline"`
48+
GABAB chanplots.GABABPlot `new-window:"+" display:"no-inline"`
4949

5050
// Kir is the kIR potassium inwardly rectifying current,
5151
// based on the equations from Lindroos et al (2018).

sims/objrec/params.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ var LayerParams = axon.LayerSheets{
8787
// Base is always applied, and others can be optionally selected to apply on top of that.
8888
var PathParams = axon.PathSheets{
8989
"Base": {
90-
{Sel: "Path", Doc: "yes extra learning factors",
90+
{Sel: "Path", Doc: "",
9191
Set: func(pt *axon.PathParams) {
92+
// pt.Com.MaxDelay = 10 // not much effect
93+
// pt.Com.Delay = 10
9294
pt.Learn.LRate.Base = 0.1 // 0.1 > 0.2 much better behavior overall; just slower initial learning for trace, 0.02 for notrace
9395
pt.Learn.DWt.SubMean = 1 // 1 -- faster if 0 until 20 epc -- prevents sig amount of late deterioration
9496
pt.SWts.Adapt.LRate = 0.0001 // 0.005 == .1 == .01

sims/ra25/params.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ var PathParams = axon.PathSheets{
4444
"Base": {
4545
{Sel: "Path", Doc: "basic path params",
4646
Set: func(pt *axon.PathParams) {
47+
// pt.Com.MaxDelay = 10 // robust to this
48+
// pt.Com.Delay = 10
4749
pt.Learn.LRate.Base = 0.06 // 0.06 for trace, 0.02 for no trace
4850
pt.SWts.Adapt.LRate = 0.1 // .1 >= .2,
4951
pt.SWts.Init.SPct = 0.5 // .5 >= 1 here -- 0.5 more reliable, 1.0 faster..

0 commit comments

Comments
 (0)