-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding fix to make using NESTML a bit more robust + another NESTML ex…
…ample
- Loading branch information
Showing
17 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"manifest": { | ||
"$BASE_DIR": ".", | ||
"$NETWORK_DIR": "$BASE_DIR/network", | ||
"$MODELS_DIR": "$BASE_DIR/../point_components" | ||
}, | ||
|
||
"components": { | ||
"point_neuron_models_dir": "$MODELS_DIR/cell_models", | ||
"synaptic_models_dir": "$MODELS_DIR/synaptic_models", | ||
"nest_modules": "components/nestml/nestml_izh_module.so" | ||
}, | ||
|
||
"networks": { | ||
"nodes": [ | ||
{ | ||
"nodes_file": "$NETWORK_DIR/cortex_nodes.h5", | ||
"node_types_file": "$NETWORK_DIR/cortex_node_types.csv" | ||
}, | ||
{ | ||
"nodes_file": "$NETWORK_DIR/thalamus_nodes.h5", | ||
"node_types_file": "$NETWORK_DIR/thalamus_node_types.csv" | ||
} | ||
], | ||
"edges": [ | ||
{ | ||
"edges_file": "$NETWORK_DIR/cortex_cortex_edges.h5", | ||
"edge_types_file": "$NETWORK_DIR/cortex_cortex_edge_types.csv", | ||
"enabled": false | ||
}, | ||
{ | ||
"edges_file": "$NETWORK_DIR/thalamus_cortex_edges.h5", | ||
"edge_types_file": "$NETWORK_DIR/thalamus_cortex_edge_types.csv", | ||
"enabled": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"manifest": { | ||
"$BASE_DIR": "${configdir}", | ||
"$NETWORK_DIR": "$BASE_DIR/network", | ||
"$MODELS_DIR": "$BASE_DIR/../point_components", | ||
"$OUTPUT_DIR": "$BASE_DIR/output", | ||
"$INPUT_DIR": "$BASE_DIR/inputs" | ||
}, | ||
|
||
"run": { | ||
"tstop": 3000.0, | ||
"dt": 0.001, | ||
"block_run": false, | ||
"block_size": 1000.0 | ||
}, | ||
|
||
"inputs": { | ||
"thalamus_spikes": { | ||
"input_type": "spikes", | ||
"module": "sonata", | ||
"input_file": "$INPUT_DIR/thalamus_spikes.h5", | ||
"node_set": "thalamus" | ||
} | ||
}, | ||
|
||
"reports": { | ||
}, | ||
|
||
"output": { | ||
"log_file": "log.txt", | ||
"spikes_file": "spikes.h5", | ||
"spikes_file_csv": "spikes.csv", | ||
"output_dir": "$OUTPUT_DIR", | ||
"overwrite_output_dir": true, | ||
"quiet_simulator": true | ||
}, | ||
|
||
"target_simulator":"NEST", | ||
"rebuild_nestml": true, | ||
"network": "config.circuit.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
model custom_izh_neuron: | ||
|
||
state: | ||
v mV = -65 mV # Membrane potential in mV | ||
u real = 0 # Membrane potential recovery variable | ||
|
||
equations: | ||
v' = (.04 * v * v / mV + 5 * v + (140 - u) * mV + (I_e * GOhm)) / ms | ||
u' = a * (b * v - u * mV) / (mV * ms) | ||
|
||
parameters: | ||
a real = .02 # describes time scale of recovery variable | ||
b real = .2 # sensitivity of recovery variable | ||
c mV = -65 mV # after-spike reset value of v | ||
d real = 8. # after-spike reset value of u | ||
|
||
input: | ||
spikes <- spike | ||
I_e pA <- continuous | ||
|
||
output: | ||
spike | ||
|
||
update: | ||
integrate_odes() | ||
|
||
onReceive(spikes): | ||
# add synaptic current | ||
v += spikes * mV * s | ||
|
||
onCondition(v >= 30mV): | ||
# threshold crossing | ||
v = c | ||
u += d | ||
emit_spike() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# import matplotlib.pyplot as plt | ||
import nest | ||
import numpy as np | ||
import os | ||
import re | ||
|
||
from pynestml.codegeneration.nest_code_generator_utils import NESTCodeGeneratorUtils | ||
|
||
|
||
nestml_izh_model = ''' | ||
model custom_izh_neuron: | ||
state: | ||
v mV = -65 mV # Membrane potential in mV | ||
u real = 0 # Membrane potential recovery variable | ||
equations: | ||
v' = (.04 * v * v / mV + 5 * v + (140 - u) * mV + (I_e * GOhm)) / ms | ||
u' = a * (b * v - u * mV) / (mV * ms) | ||
parameters: | ||
a real = .02 # describes time scale of recovery variable | ||
b real = .2 # sensitivity of recovery variable | ||
c mV = -65 mV # after-spike reset value of v | ||
d real = 8. # after-spike reset value of u | ||
input: | ||
spikes <- spike | ||
I_e pA <- continuous | ||
output: | ||
spike | ||
update: | ||
integrate_odes() | ||
onReceive(spikes): | ||
# add synaptic current | ||
v += spikes * mV * s | ||
onCondition(v >= 30mV): | ||
# threshold crossing | ||
v = c | ||
u += d | ||
emit_spike() | ||
''' | ||
|
||
# generate and build code | ||
module_name, neuron_model_name_adapt_curr = NESTCodeGeneratorUtils.generate_code_for( | ||
nestml_izh_model, | ||
module_name='nestml_izh_module', | ||
target_path='components/nestml' | ||
) |
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
examples/point_nestml_izh/network/cortex_cortex_edge_types.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
edge_type_id target_query source_query dynamics_params syn_weight delay model_template | ||
100 * ei=='e' ExcToInh.json 2.0 1.5 static_synapse | ||
101 * ei=='i' InhToExc.json -1.5 1.5 static_synapse |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_type_id ei model_template dynamics_params pop_name model_type | ||
100 e nestml:custom_izh_neuron_nestml iaf_psc_delta_exc.json LIF_exc point_neuron | ||
101 i nestml:custom_izh_neuron_nestml iaf_psc_delta_inh.json LIF_inh point_neuron |
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
examples/point_nestml_izh/network/thalamus_cortex_edge_types.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
edge_type_id target_query source_query dynamics_params syn_weight delay model_template | ||
100 ei=='e' * ExcToExc.json 220.0 1.5 static_synapse | ||
101 ei=='i' * ExcToExc.json 5.0 1.5 static_synapse |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_type_id ei pop_name model_type | ||
100 e input_network virtual |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os, sys | ||
|
||
from bmtk.simulator import pointnet | ||
import nest | ||
|
||
# nest.ResetKernel() | ||
# nest.Install('nestml_39f5da2aef404887ac26009e1449206e_module') | ||
|
||
|
||
# neuron = nest.Create('ornstein_uhlenbeck_noise_neuron') | ||
# print(list(neuron)) | ||
|
||
def run(config_file): | ||
configure = pointnet.Config.from_json(config_file) | ||
configure.build_env() | ||
|
||
network = pointnet.PointNetwork.from_config(configure) | ||
# network.add_nest_module('/local1/workspace/bmtk/examples/point_nestml_izh/components/nestml/') | ||
# network.add_nest_module('nestml_izh_module') | ||
# network.add_nest_module('/local1/workspace/bmtk/examples/point_nestml_izh/components/nestml/nestml_izh_module.so') | ||
|
||
|
||
# nest.Install('nestml_39f5da2aef404887ac26009e1449206e_module') | ||
sim = pointnet.PointSimulator.from_config(configure, network) | ||
sim.run() | ||
|
||
|
||
if __name__ == '__main__': | ||
# Find the appropriate config.json file | ||
run('config.simulation.json') | ||
# run('config.simulation_perturbations.json') |