Skip to content

Commit

Permalink
-Improve existing and add new models
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPlotnikov committed Jun 29, 2016
1 parent f1a39d9 commit 664cfd3
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public class NESTCodeGeneratorIntegrationTest extends GenerationBasedTest {

private final List<String> nestmlCondImplicitModels = Lists.newArrayList(
"src/test/resources/codegeneration/iaf_cond_alpha_implicit.nestml",
"src/test/resources/codegeneration/aeif_cond_alpha_implicit.nestml"
"src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml",
"src/test/resources/codegeneration/aeif_cond_alpha_implicit.nestml",
"src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml",
"src/test/resources/codegeneration/hh_psc_alpha.nestml"

);

private final List<String> blueGene = Lists.newArrayList(
Expand Down Expand Up @@ -160,7 +164,7 @@ public void testIzhikevich() {
@Ignore("Don't run this tests on github")
@Test
public void testManually() {
final List<String> modelName = Lists.newArrayList("src/test/resources/codegeneration/hh_psc_alpha.nestml");
final List<String> modelName = Lists.newArrayList("src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml");
modelName.forEach(this::checkCocos);
modelName.forEach(this::invokeCodeGenerator);
final List<ASTNESTMLCompilationUnit> roots = modelName.stream()
Expand Down
99 changes: 99 additions & 0 deletions src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
neuron aeif_cond_exp_implicit:

state:
V_m mV = E_L
w real = 0
alias exp_arg real = (V_m-V_th)/delta_T
alias I_spike real = delta_T*exp(exp_arg)
# alias I_spike = delta_T*exp(min(exp_arg, MAX_EXP_ARG))

# inputs from the inh conductance
GI nS = 0
# inputs from the exc conductance
GE nS = 0
alias I_syn_exc real = GE * ( V_m - E_ex )
alias I_syn_inh real = GI * ( V_m - E_in )
end

equations:
# Implicit
GI' = -GI/tau_syn_in
# shape GE = (e/tau_syn_ex) * t * exp(-1/tau_syn_ex*t)
GE' = -GE/tau_syn_ex
# Equation as defined in NEST model


#NESTML style
# results in worse precision
#V_m' = -1/Tau * (V_m - E_L) - 1/C_m * (Cond_sum(GI, spikeInh)* (V_m-E_in) + Cond_sum(GE, spikeExc) * (V_m-E_ex) - (I_e + I_stim) + w + I_spike)
V_m' = ( -g_L * ( ( V_m - E_L ) - I_spike ) - I_syn_exc - I_syn_inh - w + I_e + I_stim ) / C_m
w' = (a*(V_m - E_L) - w)/tau_w

end

parameter:
# membrane parameters
C_m pF = 281.0 # Membrane Capacitance in pF
t_ref ms = 0.0 # Refractory period in ms
V_reset mV = -60.0 # Reset Potential in mV
g_L nS = 30.0 # Leak Conductance in nS
E_L mV = -70.6 # Leak reversal Potential (aka resting potential) in mV
I_e pA = 0 # Constant Current in pA

# spike adaptation parameters
a nS = 4
b pA = 80.5
alias Tau ms = (1 / g_L) * C_m
delta_T mV = 2.0
tau_w ms = 144.0
V_th mV = -50.4 # Threshold Potential in mV
V_peak mV = 0

# synaptic parameters
E_ex mV = 0 # Excitatory reversal Potential in mV
tau_syn_ex ms = 0.2 # Synaptic Time Constant Excitatory Synapse in ms
E_in mV = -85.0 # Inhibitory reversal Potential in mV
tau_syn_in ms = 2.0 # Synaptic Time Constant for Inhibitory Synapse in ms
# Input current injected by CurrentEvent.
# This variable is used to transport the current applied into the
# _dynamics function computing the derivative of the state vector.
I_stim pA = 0
end

internal:
r integer

# refractory time in steps
RefractoryCounts integer = steps(t_ref)
end

input:
spikeInh <- inhibitory spike
spikeExc <- excitatory spike
currents <- current
end

output: spike

update:
integrate(V_m)

if r > 0: # refractory
r = r - 1
end

if r > 0: # not refractory
V_m = V_reset # clamp potential
elif V_m >= V_peak:
r = RefractoryCounts
V_m = V_reset # clamp potential
w += b
emit_spike()
end

GE += spikeExc.getSum()
GI += spikeInh.getSum()
I_stim = currents.getSum()
end

end
27 changes: 8 additions & 19 deletions src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ neuron iaf_cond_exp_implicit:

state:
# membrane potential
V mV = 0
alias V_m mV = V + 0
V_m mV = E_L
# inputs from the inh conductance
GI nS = 0
# inputs from the exc conductance
Expand All @@ -12,10 +11,9 @@ neuron iaf_cond_exp_implicit:

equations:
# Implicit
GI' = GI' - GI/tau_synI
GE' = GE' -GE/tau_synE

V' = -1/Tau * (V - E_L) - 1/C_m * ( GI * (V-V_reversalI) + GE * (V-V_reversalE) - (I_e + I_stim))
GI' = -GI/tau_synI
GE' = -GE/tau_synE
V_m' = -1/Tau * (V_m - E_L) - 1/C_m * ( GI * (V_m-V_reversalI) + GE * (V_m-V_reversalE) - (I_e + I_stim))
end

parameter:
Expand Down Expand Up @@ -50,17 +48,8 @@ neuron iaf_cond_exp_implicit:
end

internal:
# Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_E real = 1.0 * e / tau_synE

# Impulse to add to DG_INH on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_I real = 1.0 * e / tau_synI

# refractory time in steps
RefractoryCounts integer = steps(t_ref)

r integer
end

Expand All @@ -74,14 +63,14 @@ neuron iaf_cond_exp_implicit:

update:

integrate(V)
integrate(V_m)
if r != 0: # not refractory
r = r - 1
V = V_reset # clamp potential
V_m = V_reset # clamp potential

elif V >= V_th:
elif V_m >= V_th:
r = RefractoryCounts
V = V_reset # clamp potential
V_m = V_reset # clamp potential
emit_spike()

end
Expand Down

0 comments on commit 664cfd3

Please sign in to comment.