diff --git a/.gitignore b/.gitignore index 030f3f6..9f91684 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,27 @@ examples/**/output/config.json .cache **/mechanisms/x86_64 .ipynb_checkpoints/ +/examples/sim_tests/intfire/*/test/x86_64 +/examples/sim_tests/intfire/*/test/LEMS*.xml +/examples/sim_tests/intfire/*/test/*.dat +/examples/sim_tests/intfire/*/test/report*txt +/examples/sim_tests/intfire/*/test/*spikes +/examples/sim_tests/intfire/*/test/*.net.nml +/examples/sim_tests/intfire/*/test/*_nrn.py +/examples/sim_tests/intfire/*/test/*.mod +/examples/sim_tests/intfire/*/test/output/*h5 +/examples/sim_tests/intfire/*/test/output/log.txt +/examples/sim_tests/intfire/*/test/output/*dat +/examples/checkouth5.sh +/examples/300_pointneurons/*.mod +/examples/300_pointneurons/LEMS_Sim_sim.xml +/examples/300_pointneurons/*_nrn.py +/examples/300_pointneurons/*spikes +/examples/300_pointneurons/output/*.dat +/examples/300_pointneurons/report.txt +/examples/300_pointneurons/*.dat +/examples/300_pointneurons/x86_64 +/examples/300_pointneurons/comparison_V_m.png +/examples/300_pointneurons/sim.net.nml +/examples/300_pointneurons/output/membrane_potential.h5 +/examples/300_pointneurons/output/spikes.h5 diff --git a/examples/300_cells/analyze_output.py b/examples/300_cells/analyze_output.py new file mode 100644 index 0000000..9e14e0a --- /dev/null +++ b/examples/300_cells/analyze_output.py @@ -0,0 +1,12 @@ +import sys +from bmtk.analyzer.visualization.spikes import plot_spikes + + +sys.path.append("../sim_tests/shared_components/scripts") + +from analyze_output_utils import plot_data + +if __name__ == '__main__': + + plot_data('output/membrane_potential.h5', 'mV', 'Membrane Potential', show_already=True, max_num_traces=12) + plot_spikes('network/internal_nodes.h5', 'network/internal_node_types.csv', 'output/spikes.h5', group_key='model_name') \ No newline at end of file diff --git a/examples/300_cells/plot_spikes.py b/examples/300_cells/plot_spikes.py new file mode 100644 index 0000000..4582a5b --- /dev/null +++ b/examples/300_cells/plot_spikes.py @@ -0,0 +1,15 @@ +from bmtk.analyzer.visualization.spikes import plot_spikes +import sys + +title = None +if len(sys.argv)>1: + title = 'Simulator: %s'%sys.argv[1] + +# Note: depends on https://github.com/AllenInstitute/bmtk/pull/73 +plot_spikes('network/internal_nodes.h5', + 'network/internal_node_types.csv', + 'output/spikes.h5', + group_key='model_name', + legend=False, + title=title, + font_size=13) diff --git a/examples/300_cells/simulation_config.json b/examples/300_cells/simulation_config.json index 1400f71..6de34e2 100755 --- a/examples/300_cells/simulation_config.json +++ b/examples/300_cells/simulation_config.json @@ -22,7 +22,7 @@ "v_init": -80 }, - "node_sets_file": "node_sets.json", + "node_sets_file": "$BASE_DIR/node_sets.json", "inputs": { "external_spike_trains": { diff --git a/examples/300_intfire/network/tw_node_types.csv b/examples/300_intfire/network/tw_node_types.csv index a76afaf..bac750d 100644 --- a/examples/300_intfire/network/tw_node_types.csv +++ b/examples/300_intfire/network/tw_node_types.csv @@ -1,2 +1,2 @@ -node_type_id model_type ei location model_name +node_type_id model_type ei model_name location 100 virtual e TW TW diff --git a/examples/300_intfire/network/v1_node_types.csv b/examples/300_intfire/network/v1_node_types.csv index 900fe10..8064083 100644 --- a/examples/300_intfire/network/v1_node_types.csv +++ b/examples/300_intfire/network/v1_node_types.csv @@ -1,3 +1,3 @@ -node_type_id ei model_name location model_template model_type dynamics_params -100 e LIF_exc VisL4 nrn:IntFire1 point_process IntFire1_exc_1.json -101 i LIF_inh VisL4 nrn:IntFire1 point_process IntFire1_inh_1.json +node_type_id ei location model_template model_type dynamics_params model_name +100 e VisL4 nrn:IntFire1 point_process IntFire1_exc_1.json LIF_exc +101 i VisL4 nrn:IntFire1 point_process IntFire1_inh_1.json LIF_inh diff --git a/examples/300_intfire/simulation_config.json b/examples/300_intfire/simulation_config.json index 3454de9..99839b3 100644 --- a/examples/300_intfire/simulation_config.json +++ b/examples/300_intfire/simulation_config.json @@ -1,7 +1,8 @@ { "manifest": { - "$OUTPUT_DIR": "./output", - "$INPUT_DIR": "./inputs", + "$BASE_DIR": ".", + "$OUTPUT_DIR": "$BASE_DIR/output", + "$INPUT_DIR": "$BASE_DIR/inputs", "$COMPONENT_DIR": "../shared_components" }, @@ -16,7 +17,7 @@ "target_simulator":"NEURON", - "node_sets_file": "node_sets.json", + "node_sets_file": "$BASE_DIR/node_sets.json", "conditions": { "celsius": 34.0, diff --git a/examples/300_intfire/test_pynn.py b/examples/300_intfire/test_pynn.py new file mode 100644 index 0000000..de6a856 --- /dev/null +++ b/examples/300_intfire/test_pynn.py @@ -0,0 +1,7 @@ +from pyNN.serialization import import_from_sonata, load_sonata_simulation_plan +import pyNN.neuron as sim + +simulation_plan = load_sonata_simulation_plan("simulation_config.json") +simulation_plan.setup(sim) +net = import_from_sonata("circuit_config.json", sim) +simulation_plan.execute(net) diff --git a/examples/300_pointneurons/build_network.py b/examples/300_pointneurons/build_network.py index ee8a562..4710a25 100644 --- a/examples/300_pointneurons/build_network.py +++ b/examples/300_pointneurons/build_network.py @@ -134,18 +134,14 @@ def n_connections(src, trg, prob=0.5, min_syns=2, max_syns=7): cm = external.add_edges(target=internal.nodes(ei='e'), source=external.nodes(), connection_rule=lambda *_: np.random.binomial(1, .7), dynamics_params='ExcToExc.json', - model_template='static_synapse', - # syn_weight=50.0, - delay=2.0) + model_template='static_synapse') cm.add_properties('syn_weight', rule=50.0, dtypes=np.float) cm = external.add_edges(target=internal.nodes(ei='i'), source=external.nodes(), connection_rule=lambda *_: np.random.binomial(1, .7), dynamics_params='ExcToInh.json', - model_template='static_synapse', - # syn_weight=75.0, - delay=2.0) + model_template='static_synapse') cm.add_properties('syn_weight', rule=65.0, dtypes=np.float) diff --git a/examples/300_pointneurons/network/external_internal_edge_types.csv b/examples/300_pointneurons/network/external_internal_edge_types.csv index c3fa238..a190ae8 100644 --- a/examples/300_pointneurons/network/external_internal_edge_types.csv +++ b/examples/300_pointneurons/network/external_internal_edge_types.csv @@ -1,3 +1,3 @@ -edge_type_id target_query source_query delay dynamics_params model_template -100 ei=='e' * 2.0 ExcToExc.json nest:static_synapse -101 ei=='i' * 2.0 ExcToInh.json nest:static_synapse +edge_type_id target_query source_query dynamics_params model_template +100 ei=='e' * ExcToExc.json static_synapse +101 ei=='i' * ExcToInh.json static_synapse diff --git a/examples/300_pointneurons/network/external_internal_edges.h5 b/examples/300_pointneurons/network/external_internal_edges.h5 index 344d118..643c0b3 100644 Binary files a/examples/300_pointneurons/network/external_internal_edges.h5 and b/examples/300_pointneurons/network/external_internal_edges.h5 differ diff --git a/examples/300_pointneurons/network/external_nodes.h5 b/examples/300_pointneurons/network/external_nodes.h5 index d3375c6..2375de2 100644 Binary files a/examples/300_pointneurons/network/external_nodes.h5 and b/examples/300_pointneurons/network/external_nodes.h5 differ diff --git a/examples/300_pointneurons/network/internal_internal_edge_types.csv b/examples/300_pointneurons/network/internal_internal_edge_types.csv index 6ea7f24..02a5c35 100644 --- a/examples/300_pointneurons/network/internal_internal_edge_types.csv +++ b/examples/300_pointneurons/network/internal_internal_edge_types.csv @@ -1,5 +1,5 @@ edge_type_id target_query source_query delay dynamics_params model_template -100 ei=='e' ei=='e' 2.0 ExcToExc.json nest:static_synapse -101 ei=='i' ei=='e' 2.0 ExcToInh.json nest:static_synapse -102 ei=='e' ei=='i' 2.0 InhToExc.json nest:static_synapse -103 ei=='i' ei=='i' 2.0 InhToInh.json nest:static_synapse +100 ei=='e' ei=='e' 2.0 ExcToExc.json static_synapse +101 ei=='i' ei=='e' 2.0 ExcToInh.json static_synapse +102 ei=='e' ei=='i' 2.0 InhToExc.json static_synapse +103 ei=='i' ei=='i' 2.0 InhToInh.json static_synapse diff --git a/examples/300_pointneurons/network/internal_internal_edges.h5 b/examples/300_pointneurons/network/internal_internal_edges.h5 index 3c6390b..5373d4a 100644 Binary files a/examples/300_pointneurons/network/internal_internal_edges.h5 and b/examples/300_pointneurons/network/internal_internal_edges.h5 differ diff --git a/examples/300_pointneurons/network/internal_nodes.h5 b/examples/300_pointneurons/network/internal_nodes.h5 index d039746..9442600 100644 Binary files a/examples/300_pointneurons/network/internal_nodes.h5 and b/examples/300_pointneurons/network/internal_nodes.h5 differ diff --git a/examples/300_pointneurons/output/membrane_potential.h5 b/examples/300_pointneurons/output/membrane_potential.h5 deleted file mode 100644 index 8d26757..0000000 Binary files a/examples/300_pointneurons/output/membrane_potential.h5 and /dev/null differ diff --git a/examples/300_pointneurons/output/spikes.h5 b/examples/300_pointneurons/output/spikes.h5 deleted file mode 100644 index 06da4dc..0000000 Binary files a/examples/300_pointneurons/output/spikes.h5 and /dev/null differ diff --git a/examples/300_pointneurons/plot_potential.py b/examples/300_pointneurons/plot_potential.py index b60fae1..ae6d3d1 100644 --- a/examples/300_pointneurons/plot_potential.py +++ b/examples/300_pointneurons/plot_potential.py @@ -33,7 +33,8 @@ def plot_vars(file_names, cell_var='v', gid_list=[], t_min=None, t_max=None): for fn in file_names: try: cell_var_files.append(CellVarsFile(fn, h5_root="/report/internal")) - except KeyError: + except KeyError as e: + print('Exception: %s'%e) cell_var_files.append(CellVarsFile(fn)) # get first spike file and properties @@ -47,6 +48,14 @@ def plot_vars(file_names, cell_var='v', gid_list=[], t_min=None, t_max=None): for i, cvf in enumerate(cell_var_files): # plot all traces ax[subplot].plot(cvf.time_trace, cvf.data(gid, cell_var), label=file_names[i]) + time_steps = cvf.time_trace + data = cvf.data(gid, cell_var) + fn = 'output/gid_%s.dat'%gid + f = open(fn,'w') + print('Writing %i points to %s'%(len(time_steps), fn)) + for ti in range(len(time_steps)): + f.write('%s\t%s\n'%(time_steps[ti]/1000,data[ti]/1000)) + f.close() ax[subplot].yaxis.set_label_position("right") ax[subplot].set_ylabel('gid {}'.format(gid), fontsize='xx-small') @@ -58,6 +67,10 @@ def plot_vars(file_names, cell_var='v', gid_list=[], t_min=None, t_max=None): # Use the last plot to get the legend handles, labels = ax[subplot].get_legend_handles_labels() fig.legend(handles, labels, loc='upper right') + + for cvf in cell_var_files: + # Note: depends on: https://github.com/AllenInstitute/bmtk/pull/73 + cvf.close() plt.show() diff --git a/examples/300_pointneurons/plot_spikes.py b/examples/300_pointneurons/plot_spikes.py index 999c3a9..4582a5b 100644 --- a/examples/300_pointneurons/plot_spikes.py +++ b/examples/300_pointneurons/plot_spikes.py @@ -1,3 +1,15 @@ from bmtk.analyzer.visualization.spikes import plot_spikes +import sys -plot_spikes('network/internal_nodes.h5', 'network/internal_node_types.csv', 'output/spikes.h5', group_key='model_name') +title = None +if len(sys.argv)>1: + title = 'Simulator: %s'%sys.argv[1] + +# Note: depends on https://github.com/AllenInstitute/bmtk/pull/73 +plot_spikes('network/internal_nodes.h5', + 'network/internal_node_types.csv', + 'output/spikes.h5', + group_key='model_name', + legend=False, + title=title, + font_size=13) diff --git a/examples/300_pointneurons/run_PyNN.py b/examples/300_pointneurons/run_PyNN.py index 0b1acdd..68632fa 100644 --- a/examples/300_pointneurons/run_PyNN.py +++ b/examples/300_pointneurons/run_PyNN.py @@ -4,4 +4,4 @@ simulation_plan = load_sonata_simulation_plan("simulation_config.json") simulation_plan.setup(sim) net = import_from_sonata("circuit_config.json", sim) -simulation_plan.execute(net) +simulation_plan.execute(net) \ No newline at end of file diff --git a/examples/300_pointneurons/run_pynml.jnmlnrn.sh b/examples/300_pointneurons/run_pynml.jnmlnrn.sh new file mode 100755 index 0000000..b183c52 --- /dev/null +++ b/examples/300_pointneurons/run_pynml.jnmlnrn.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim config.json -neuron diff --git a/examples/300_pointneurons/simulation_config.json b/examples/300_pointneurons/simulation_config.json index 0f7e15f..89ead2a 100755 --- a/examples/300_pointneurons/simulation_config.json +++ b/examples/300_pointneurons/simulation_config.json @@ -7,7 +7,7 @@ "run": { "tstop": 1500.0, - "dt": 0.001, + "dt": 0.01, "nsteps_block": 5000 }, @@ -20,7 +20,7 @@ "v_init": -80 }, - "node_sets_file": "node_sets.json", + "node_sets_file": "$BASE_DIR/node_sets.json", "inputs": { "external_spike_trains": { diff --git a/examples/5_cells_iclamp/network/biophysical_node_types.csv b/examples/5_cells_iclamp/network/biophysical_node_types.csv index d348ebd..a060da7 100755 --- a/examples/5_cells_iclamp/network/biophysical_node_types.csv +++ b/examples/5_cells_iclamp/network/biophysical_node_types.csv @@ -1,6 +1,6 @@ -node_type_id model_processing model_type model_template morphology ei model_name -104 aibs_perisomatic biophysical nml:Cell_473862421.cell.nml Pvalb_469628681_m i PV2 -100 aibs_perisomatic biophysical nml:Cell_472363762.cell.nml Scnn1a_473845048_m e Scnn1a -101 aibs_perisomatic biophysical nml:Cell_473863510.cell.nml Rorb_325404214_m e Rorb -102 aibs_perisomatic biophysical nml:Cell_473863035.cell.nml Nr5a1_471087815_m e Nr5a1 -103 aibs_perisomatic biophysical nml:Cell_472912177.cell.nml Pvalb_470522102_m i PV1 +node_type_id ei model_processing morphology model_template model_type model_name +104 i aibs_perisomatic Pvalb_469628681_m nml:Cell_473862421.cell.nml biophysical PV2 +100 e aibs_perisomatic Scnn1a_473845048_m nml:Cell_472363762.cell.nml biophysical Scnn1a +101 e aibs_perisomatic Rorb_325404214_m nml:Cell_473863510.cell.nml biophysical Rorb +102 e aibs_perisomatic Nr5a1_471087815_m nml:Cell_473863035.cell.nml biophysical Nr5a1 +103 i aibs_perisomatic Pvalb_470522102_m nml:Cell_472912177.cell.nml biophysical PV1 diff --git a/examples/5_cells_iclamp/simulation_config.json b/examples/5_cells_iclamp/simulation_config.json index ad58620..2f5b39c 100644 --- a/examples/5_cells_iclamp/simulation_config.json +++ b/examples/5_cells_iclamp/simulation_config.json @@ -23,7 +23,7 @@ "v_init": -80 }, - "node_sets_file": "node_sets.json", + "node_sets_file": "$BASE_DIR/node_sets.json", "inputs": { "current_clamp_1": { diff --git a/examples/9_cells/network/cortex_node_types.csv b/examples/9_cells/network/cortex_node_types.csv index 5971e71..b3a2427 100644 --- a/examples/9_cells/network/cortex_node_types.csv +++ b/examples/9_cells/network/cortex_node_types.csv @@ -1,4 +1,4 @@ -node_type_id ei model_processing model_type model_template morphology dynamics_params model_name -100 e aibs_perisomatic biophysical nml:nml/Cell_472363762.cell.nml Scnn1a_473845048_m NONE Scnn1a -101 e aibs_perisomatic biophysical nml:nml/Cell_473863510.cell.nml Rorb_325404214_m NONE Rorb -102 e aibs_perisomatic biophysical nml:nml/Cell_473863035.cell.nml Nr5a1_471087815_m NONE Nr5a1 +node_type_id ei model_processing model_type model_template morphology dynamics_params model_name +100 e aibs_perisomatic biophysical nml:nml/Cell_472363762.cell.nml Scnn1a_473845048_m NONE Scnn1a +101 e aibs_perisomatic biophysical nml:nml/Cell_473863510.cell.nml Rorb_325404214_m NONE Rorb +102 e aibs_perisomatic biophysical nml:nml/Cell_473863035.cell.nml Nr5a1_471087815_m NONE Nr5a1 diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/bmtk_build/build_network.py b/examples/sim_tests/intfire/one_cell_iclamp_nest/bmtk_build/build_network.py new file mode 100644 index 0000000..935b1c7 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/bmtk_build/build_network.py @@ -0,0 +1,26 @@ +#!/bin/env python + +# Sonata Simulator Test Suite +# 1-cell circuit, integrate and fire cell, current clamp input + +# Authors: Padraig Gleeson @ UCL + +from bmtk.builder import NetworkBuilder + +net = NetworkBuilder("one_cell_iclamp") + +pos_x, pos_y = [0,0] + +template = 'nest:iaf_psc_alpha' + +net.add_nodes(N=1, pop_name='LIF_exc', location='VisL4', ei='e', + model_type='point_process', # use point_process to indicate we are using point model cells + model_template=template, + x=pos_x, y=pos_y, + dynamics_params='473863035_point.json') + + +net.build() +net.save(output_dir='../input/network') + +print 'Built: %s'%net.name diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/circuit_config.json b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/circuit_config.json new file mode 100644 index 0000000..7983bda --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/circuit_config.json @@ -0,0 +1,24 @@ +{ + "manifest": { + "$NETWORK_DIR": "../input/network", + "$COMPONENT_DIR": "../../../shared_components" + }, + + "components": { + "synaptic_models_dir": "$COMPONENT_DIR/synaptic_models", + "mechanisms_dir":"$COMPONENT_DIR/mechanisms", + "point_neuron_models_dir": "$COMPONENT_DIR/point_neuron_models_dir" + }, + + "networks": { + "nodes": [ + { + "nodes_file": "$NETWORK_DIR/one_cell_iclamp_nodes.h5", + "node_types_file": "$NETWORK_DIR/one_cell_iclamp_node_types.csv" + } + ] + }, + + + "target_simulator": "NEST" +} diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/config.json b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/config.json new file mode 100644 index 0000000..890caa3 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/config.json @@ -0,0 +1,4 @@ +{ + "network": "./circuit_config.json", + "simulation": "./simulation_config.json" +} diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_node_types.csv b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_node_types.csv new file mode 100644 index 0000000..8783e2a --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_node_types.csv @@ -0,0 +1,2 @@ +node_type_id ei model_type pop_name location model_template x y dynamics_params +100 e point_process LIF_exc VisL4 nest:iaf_psc_alpha 0 0 473863035_point.json diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_nodes.h5 b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_nodes.h5 new file mode 100644 index 0000000..ac9bfb1 Binary files /dev/null and b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/network/one_cell_iclamp_nodes.h5 differ diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/node_sets.json b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/node_sets.json new file mode 100644 index 0000000..baa3154 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/node_sets.json @@ -0,0 +1,5 @@ +{ + "point_nodes": { + "model_type": "point_process" + } +} diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/input/simulation_config.json b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/simulation_config.json new file mode 100644 index 0000000..387269f --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/input/simulation_config.json @@ -0,0 +1,57 @@ +{ + "manifest": { + "$OUTPUT_DIR": "../test/output", + "$INPUT_DIR": "../input" + }, + + "run": { + "tstop": 1000.0, + "dt": 0.01, + "spike_threshold": -15, + "nsteps_block": 10000 + }, + + "target_simulator":"NEST", + + "network": "$INPUT_DIR/circuit_config.json", + + "conditions": { + "celsius": 34.0, + "v_init": -80 + }, + + "node_sets_file": "$INPUT_DIR/node_sets.json", + + "mechanisms_dir": "../shared_components_mechanisms", + + + "inputs": { + "current_clamp_1": { + "input_type": "current_clamp", + "module": "IClamp", + "node_set": "point_nodes", + "amp": 190.0, + "delay": 100.0, + "duration": 800.0 + } + }, + + "output":{ + "output_dir": "$OUTPUT_DIR", + "log_file": "log.txt", + "spikes_file": "spikes.h5", + "spikes_sort_order": "time" + }, + + "reports": { + + "membrane_potential": { + "cells": "point_nodes", + "variable_name": "V_m", + "module": "multimeter_report", + "sections": "soma", + "enabled": true + } + + } +} diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/test/analyze_output.py b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/analyze_output.py new file mode 100644 index 0000000..508c1c2 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/analyze_output.py @@ -0,0 +1,9 @@ +import sys + +sys.path.append("../../../shared_components/scripts") + +from analyze_output_utils import plot_data + +if __name__ == '__main__': + + plot_data('output/membrane_potential.h5', 'mV', 'Membrane Potential') \ No newline at end of file diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_bmtk.sh b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_bmtk.sh new file mode 100755 index 0000000..bcb2854 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_bmtk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +rm -rf output +rm -rf __pycache__ +# python -m trace --trace ../shared_components/scripts/run_bionet.py ../input/config.json +python ../../../shared_components/scripts/run_bionet.py NEST ../input/config.json + +pytest -vvs diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.jnml.sh b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.jnml.sh new file mode 100755 index 0000000..8e4d810 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.jnml.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -jnml diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.neuron.sh b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.neuron.sh new file mode 100755 index 0000000..54c7337 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynml.neuron.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -neuron diff --git a/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynn.py b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynn.py new file mode 100644 index 0000000..51ecfe1 --- /dev/null +++ b/examples/sim_tests/intfire/one_cell_iclamp_nest/test/run_pynn.py @@ -0,0 +1,8 @@ +from pyNN.serialization import import_from_sonata, load_sonata_simulation_plan +import pyNN.nest as sim + +simulation_plan = load_sonata_simulation_plan("../input/simulation_config.json") +simulation_plan.setup(sim) +net = import_from_sonata("../input/circuit_config.json", sim) + +simulation_plan.execute(net) \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/bmtk_build/build_network.py b/examples/sim_tests/intfire/ten_cells_iclamp_nest/bmtk_build/build_network.py new file mode 100644 index 0000000..b0e699b --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/bmtk_build/build_network.py @@ -0,0 +1,65 @@ +#!/bin/env python + +# Sonata Simulator Test Suite +# 10-cell circuit, integrate and fire cells, 2 populations, current clamp input to one + +# Authors: Padraig Gleeson @ UCL + +import numpy as np +from neuron import h +from bmtk.builder import NetworkBuilder + +net = NetworkBuilder("ten_cells_iclamp") # ten aot 10, as NeuroML doesn't like ids that start with a digit... + +def generate_positions(N, x0=0.0, x1=300.0, y0=0.0, y1=100.0): + X = np.random.uniform(x0, x1, N) + Y = np.random.uniform(y0, y1, N) + return X, Y + +per_pop = 5 + +pos_x, pos_y = generate_positions(per_pop) + +template = 'nest:iaf_psc_alpha' + +net.add_nodes(N=per_pop, pop_name='LIF_exc', location='VisL4', ei='e', + model_type='point_process', # use point_process to indicate were are using point model cells + model_template=template, + x=pos_x, y=pos_y, + dynamics_params='472363762_point.json') + +pos_x, pos_y = generate_positions(per_pop) + +net.add_nodes(N=per_pop, pop_name='LIF_inh', location='VisL4', ei='i', + model_type='point_process', # use point_process to indicate were are using point model cells + model_template=template, + x=pos_x, y=pos_y, + dynamics_params='472363762_point.json') + + +def recurrent_connections(src_cells, trg_cell, n_syns): + + # Increasing numbers of synapses per target cell... + #print(trg_cell) + #print(dir(trg_cell)) + #print('--- %s'%trg_cell._node_params) + synapses = [20 * n_syns* (trg_cell.node_id-per_pop)] *len(src_cells) + return synapses + + +net.add_edges(source={'ei': 'e'}, target={'ei': 'i', 'model_type': 'point_process'}, + iterator='all_to_one', + connection_rule=recurrent_connections, + connection_params={'n_syns': 1}, + syn_weight=10, + weight_function='wmax', + delay=2.0, + dynamics_params='ExcToInh.json', + model_template='static_synapse') + + +net.build() +net.save(output_dir='../input/network') + +print 'Built: %s'%net.name + diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/circuit_config.json b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/circuit_config.json new file mode 100644 index 0000000..b73ec46 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/circuit_config.json @@ -0,0 +1,29 @@ +{ + "manifest": { + "$NETWORK_DIR": "../input/network", + "$COMPONENT_DIR": "../../../shared_components" + }, + + "components": { + "morphologies_dir": "$COMPONENT_DIR/morphologies", + "synaptic_models_dir": "$COMPONENT_DIR/synaptic_models", + "mechanisms_dir":"$COMPONENT_DIR/mechanisms", + "point_neuron_models_dir": "$COMPONENT_DIR/point_neuron_models_dir" + }, + + "networks": { + "nodes": [ + { + "nodes_file": "$NETWORK_DIR/ten_cells_iclamp_nodes.h5", + "node_types_file": "$NETWORK_DIR/ten_cells_iclamp_node_types.csv" + } + ], + + "edges": [ + { + "edges_file": "$NETWORK_DIR/ten_cells_iclamp_ten_cells_iclamp_edges.h5", + "edge_types_file": "$NETWORK_DIR/ten_cells_iclamp_ten_cells_iclamp_edge_types.csv" + } + ] + } +} \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/config.json b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/config.json new file mode 100644 index 0000000..890caa3 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/config.json @@ -0,0 +1,4 @@ +{ + "network": "./circuit_config.json", + "simulation": "./simulation_config.json" +} diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_node_types.csv b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_node_types.csv new file mode 100644 index 0000000..4f0a45f --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_node_types.csv @@ -0,0 +1,3 @@ +node_type_id ei pop_name location model_template model_type dynamics_params +100 e LIF_exc VisL4 nest:iaf_psc_alpha point_process 472363762_point.json +101 i LIF_inh VisL4 nest:iaf_psc_alpha point_process 472363762_point.json diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_nodes.h5 b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_nodes.h5 new file mode 100644 index 0000000..094ea26 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_nodes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edge_types.csv b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edge_types.csv new file mode 100644 index 0000000..1f10453 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edge_types.csv @@ -0,0 +1,2 @@ +edge_type_id target_query source_query delay weight_function syn_weight dynamics_params model_template +100 model_type=='point_process'&ei=='i' ei=='e' 2.0 wmax 10 ExcToInh.json static_synapse diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edges.h5 b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edges.h5 new file mode 100644 index 0000000..18953c3 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/network/ten_cells_iclamp_ten_cells_iclamp_edges.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/node_sets.json b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/node_sets.json new file mode 100644 index 0000000..48b4c5d --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/node_sets.json @@ -0,0 +1,9 @@ +{ + "point_nodes": { + "model_type": "point_process" + }, + "pre_nodes": { + "model_type": "point_process", + "ei": "e" + } +} diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/simulation_config.json b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/simulation_config.json new file mode 100644 index 0000000..0f1313e --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/input/simulation_config.json @@ -0,0 +1,53 @@ +{ + "manifest": { + "$OUTPUT_DIR": "../test/output", + "$INPUT_DIR": "../input" + }, + + "run": { + "tstop": 1000.0, + "dt": 0.01, + "spike_threshold": -15, + "nsteps_block": 10000 + }, + + "target_simulator":"NEST", + + "conditions": { + "celsius": 34.4, + "v_init": -80 + }, + + "node_sets_file": "$INPUT_DIR/node_sets.json", + + "inputs": { + "current_clamp_1": { + "input_type": "current_clamp", + "module": "IClamp", + "node_set": "pre_nodes", + "amp": 190.0, + "delay": 100.0, + "duration": 800.0 + } + }, + + "output":{ + "output_dir": "$OUTPUT_DIR", + "log_file": "log.txt", + "spikes_file": "spikes.h5", + "spikes_sort_order": "time" + }, + + "reports": { + + "membrane_potential": { + "cells": "point_nodes", + "variable_name": "V_m", + "module": "multimeter_report", + "sections": "soma", + "enabled": true + } + + } + +} diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/analyze_output.py b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/analyze_output.py new file mode 100644 index 0000000..a4eec1b --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/analyze_output.py @@ -0,0 +1,12 @@ +import sys +from bmtk.analyzer.visualization.spikes import plot_spikes + + +sys.path.append("../../../shared_components/scripts") + +from analyze_output_utils import plot_data + +if __name__ == '__main__': + + plot_data('output/membrane_potential.h5', 'mV', 'Membrane Potential', show_already=True) + plot_spikes('../input/network/ten_cells_iclamp_nodes.h5', '../input/network/ten_cells_iclamp_node_types.csv', 'output/spikes.h5') \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_bmtk.sh b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_bmtk.sh new file mode 100755 index 0000000..bcb2854 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_bmtk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +rm -rf output +rm -rf __pycache__ +# python -m trace --trace ../shared_components/scripts/run_bionet.py ../input/config.json +python ../../../shared_components/scripts/run_bionet.py NEST ../input/config.json + +pytest -vvs diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.jnml.sh b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.jnml.sh new file mode 100755 index 0000000..8e4d810 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.jnml.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -jnml diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.neuron.sh b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.neuron.sh new file mode 100755 index 0000000..54c7337 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynml.neuron.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -neuron diff --git a/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynn.py b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynn.py new file mode 100644 index 0000000..51ecfe1 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_iclamp_nest/test/run_pynn.py @@ -0,0 +1,8 @@ +from pyNN.serialization import import_from_sonata, load_sonata_simulation_plan +import pyNN.nest as sim + +simulation_plan = load_sonata_simulation_plan("../input/simulation_config.json") +simulation_plan.setup(sim) +net = import_from_sonata("../input/circuit_config.json", sim) + +simulation_plan.execute(net) \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/build_network.py b/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/build_network.py new file mode 100644 index 0000000..5ea68b0 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/build_network.py @@ -0,0 +1,55 @@ +import os +import numpy as np + +from bmtk.builder.networks import NetworkBuilder + + +net_pre = NetworkBuilder("pre") +net_post = NetworkBuilder("post") + +num_pre_post = 5 + + +def generate_positions(N, x0=0.0, x1=300.0, y0=0.0, y1=100.0): + X = np.random.uniform(x0, x1, N) + Y = np.random.uniform(y0, y1, N) + return X, Y + +net_pre.add_nodes(N=num_pre_post, pop_name='VirtualCells', ei='e', location='TW', model_type='virtual') + +pos_x, pos_y = generate_positions(num_pre_post) +net_post.add_nodes(N=num_pre_post, pop_name='Exc', location='VisL4', ei='e', + model_type='point_process', # use point_process to indicate were are using point model cells + model_template='nest:iaf_psc_alpha', # Tell the simulator to use the NEURON built-in IntFire1 type cell + x=pos_x, y=pos_y, + dynamics_params='472363762_point.json') + + + +def recurrent_connections(src_cells, trg_cell, n_syns): + + synapses = [n_syns*(np.random.random() > 0.5) for i in range(len(src_cells))] + + return synapses + + + +pre_post = net_pre.add_edges(source=net_pre.nodes(), target=net_post.nodes(pop_name='Exc'), + iterator='all_to_one', + connection_rule=recurrent_connections, + connection_params={'n_syns': 1}, + model_template='static_synapse', + weight_function='wmax', + delay=0.1, + dynamics_params='ExcToExc.json') + +pre_post.add_properties('syn_weight', rule=25, dtypes=np.float) + +net_pre.build() +net_pre.save(output_dir='../input/network') + +net_post.build() +net_post.save(output_dir='../input/network') + + +print 'done' \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/generate_spikes.py b/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/generate_spikes.py new file mode 100644 index 0000000..401e7e1 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/bmtk_build/generate_spikes.py @@ -0,0 +1,5 @@ +import os +from bmtk.utils.io.spike_trains import PoissonSpikesGenerator + +psg = PoissonSpikesGenerator(range(5), 10.0, tstop=200.0) +psg.to_hdf5('../input/external_spike_trains.h5') diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/circuit_config.json b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/circuit_config.json new file mode 100644 index 0000000..db5f0c5 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/circuit_config.json @@ -0,0 +1,36 @@ +{ + "manifest": { + "$NETWORK_DIR": "../input/network", + "$COMPONENT_DIR": "../../../shared_components/nest_models" + }, + + "components": { + "morphologies_dir": "$COMPONENT_DIR/morphologies", + "synaptic_models_dir": "$COMPONENT_DIR/synaptic_models", + "mechanisms_dir":"$COMPONENT_DIR/mechanisms", + "point_neuron_models_dir": "$COMPONENT_DIR/cell_models" + }, + + "networks": { + "nodes": [ + { + "nodes_file": "$NETWORK_DIR/pre_nodes.h5", + "node_types_file": "$NETWORK_DIR/pre_node_types.csv" + }, + { + "nodes_file": "$NETWORK_DIR/post_nodes.h5", + "node_types_file": "$NETWORK_DIR/post_node_types.csv" + } + ], + + "edges": [ + { + "edges_file": "$NETWORK_DIR/pre_post_edges.h5", + "edge_types_file": "$NETWORK_DIR/pre_post_edge_types.csv" + } + ] + }, + + "target_simulator": "NEST" +} + diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/config.json b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/config.json new file mode 100644 index 0000000..890caa3 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/config.json @@ -0,0 +1,4 @@ +{ + "network": "./circuit_config.json", + "simulation": "./simulation_config.json" +} diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/external_spike_trains.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/external_spike_trains.h5 new file mode 100644 index 0000000..d6a09f7 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/external_spike_trains.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_node_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_node_types.csv new file mode 100644 index 0000000..ce7494e --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_node_types.csv @@ -0,0 +1,2 @@ +node_type_id ei pop_name location model_template model_type dynamics_params +100 e Exc VisL4 nest:iaf_psc_alpha point_process 472363762_point.json diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_nodes.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_nodes.h5 new file mode 100644 index 0000000..a459ce1 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/post_nodes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_node_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_node_types.csv new file mode 100644 index 0000000..b4a880c --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_node_types.csv @@ -0,0 +1,2 @@ +node_type_id model_type ei location pop_name +100 virtual e TW VirtualCells diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_nodes.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_nodes.h5 new file mode 100644 index 0000000..a0268dc Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_nodes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edge_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edge_types.csv new file mode 100644 index 0000000..ec56c67 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edge_types.csv @@ -0,0 +1,2 @@ +edge_type_id target_query source_query delay weight_function dynamics_params model_template +100 pop_name=='Exc' * 0.1 wmax ExcToExc.json static_synapse diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edges.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edges.h5 new file mode 100644 index 0000000..c4031f5 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/network/pre_post_edges.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/node_sets.json b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/node_sets.json new file mode 100644 index 0000000..e2293e4 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/node_sets.json @@ -0,0 +1,20 @@ +{ + "point_nodes": { + "model_type": "point_process" + }, + "e_nodes": { + "model_type": "point_process", + "ei": "e" + }, + "pre": { + "population": "pre" + }, + "post": { + "population": "post" + }, + "recorded_cells": { + "population": "post", + "node_id": [0, 1, 2, 3, 4] + } + +} \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/input/simulation_config.json b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/simulation_config.json new file mode 100644 index 0000000..dd03aa1 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/input/simulation_config.json @@ -0,0 +1,50 @@ +{ + "manifest": { + "$OUTPUT_DIR": "../test/output", + "$INPUT_DIR": "../input" + }, + + "run": { + "tstop": 400.0, + "dt": 0.001, + "nsteps_block": 5000 + }, + + "target_simulator":"NEST", + + "conditions": { + "celsius": 34.0, + "v_init": -80 + }, + + "node_sets_file": "$INPUT_DIR/node_sets.json", + + "inputs": { + "external_spike_trains": { + "input_type": "spikes", + "module": "h5", + "input_file": "$INPUT_DIR/external_spike_trains.h5", + "node_set": "pre" + } + }, + + + "output":{ + "output_dir": "$OUTPUT_DIR", + "log_file": "log.txt", + "spikes_file": "spikes.h5", + "spikes_sort_order": "time" + }, + + + "reports": { + "membrane_potential": { + "cells": "recorded_cells", + "variable_name": "V_m", + "module": "multimeter_report", + "sections": "soma", + "enabled": true + } + } + +} \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/test/analyze_output.py b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/analyze_output.py new file mode 100644 index 0000000..2f81b17 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/analyze_output.py @@ -0,0 +1,13 @@ +import sys +from bmtk.analyzer.visualization.spikes import plot_spikes + + +sys.path.append("../../../shared_components/scripts") + +from analyze_output_utils import plot_data + +if __name__ == '__main__': + + plot_data('output/membrane_potential.h5', 'mV', 'Membrane Potential', show_already=True) + #plot_spikes('../input/network/pre_nodes.h5', '../input/network/pre_node_types.csv', 'output/spikes.h5') + #plot_spikes('../input/network/post_nodes.h5', '../input/network/post_node_types.csv', 'output/spikes.h5') \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_bmtk.sh b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_bmtk.sh new file mode 100755 index 0000000..bcb2854 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_bmtk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +rm -rf output +rm -rf __pycache__ +# python -m trace --trace ../shared_components/scripts/run_bionet.py ../input/config.json +python ../../../shared_components/scripts/run_bionet.py NEST ../input/config.json + +pytest -vvs diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.jnml.sh b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.jnml.sh new file mode 100755 index 0000000..8e4d810 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.jnml.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -jnml diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.neuron.sh b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.neuron.sh new file mode 100755 index 0000000..54c7337 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynml.neuron.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pynml-sonata sim ../input/config.json -neuron diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynn.py b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynn.py new file mode 100644 index 0000000..51ecfe1 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nest/test/run_pynn.py @@ -0,0 +1,8 @@ +from pyNN.serialization import import_from_sonata, load_sonata_simulation_plan +import pyNN.nest as sim + +simulation_plan = load_sonata_simulation_plan("../input/simulation_config.json") +simulation_plan.setup(sim) +net = import_from_sonata("../input/circuit_config.json", sim) + +simulation_plan.execute(net) \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/bmtk_build/build_network.py b/examples/sim_tests/intfire/ten_cells_spikes_nrn/bmtk_build/build_network.py new file mode 100644 index 0000000..9d36180 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/bmtk_build/build_network.py @@ -0,0 +1,136 @@ +import os +import numpy as np + +from bmtk.builder.networks import NetworkBuilder + + +net_pre = NetworkBuilder("pre") +net_post = NetworkBuilder("post") + + +net_pre.add_nodes(N=5, pop_name='VirtualCells', ei='e', location='TW', model_type='virtual') + +net_post.add_nodes(N=5, pop_name='Exc', location='VisL4', ei='e', + model_type='point_process', # use point_process to indicate were are using point model cells + model_template='nrn:IntFire1', # Tell the simulator to use the NEURON built-in IntFire1 type cell + dynamics_params='IntFire1_exc_1.json') + + + + +def recurrent_connections(src_cells, trg_cell, n_syns): + if np.random.random() > .5: + synapses = [n_syns]*len(src_cells) + else: + synapses = [None]*len(src_cells) + return synapses + +def recurrent_connections_low(src_cells, trg_cell, n_syns): + + synapses = [n_syns*(np.random.random() > .1) for i in range(len(src_cells))] + + return synapses + +def recurrent_connections_low2(src_cells, trg_cell, n_syns): + + synapses = [n_syns*(np.random.random() > .1) for i in range(len(src_cells))] + + return synapses + + +net_pre.add_edges(source=net_pre.nodes(), target=net_post.nodes(pop_name='Exc'), + iterator='all_to_one', + connection_rule=recurrent_connections_low, + connection_params={'n_syns': 1}, + syn_weight=5, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousExc.json') +''' + ''' + + +''' +net.add_edges(source={'ei': 'i'}, target={'ei': 'i', 'model_type': 'point_process'}, + iterator='all_to_one', + connection_rule=recurrent_connections, + connection_params={'n_syns': 10}, + syn_weight=0.01, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousInh.json') + + + +net.add_edges(source={'ei': 'i'}, target={'ei': 'e', 'model_type': 'point_process'}, + iterator='all_to_one', + connection_rule=recurrent_connections, + connection_params={'n_syns': 10}, + syn_weight=0.15, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousInh.json') + + +net.add_edges(source={'ei': 'e'}, target={'pop_name': 'LIF_inh'}, + iterator='all_to_one', + connection_rule=recurrent_connections, + connection_params={'n_syns': 10}, + syn_weight=0.3, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousExc.json') + + +net.add_edges(source={'ei': 'e'}, target={'pop_name': 'LIF_exc'}, + iterator='all_to_one', + connection_rule=recurrent_connections_low2, + connection_params={'n_syns': 1}, + syn_weight=0.002, + weight_function='wmax', + delay=2.0, + dynamics_params='instanteneousExc.json') +''' + + + + +def generate_positions(N, x0=0.0, x1=300.0, y0=0.0, y1=100.0): + X = np.random.uniform(x0, x1, N) + Y = np.random.uniform(y0, y1, N) + return X, Y + + +''' +tw = NetworkBuilder("tw") +tw.add_nodes(N=30, pop_name='TW', ei='e', location='TW', model_type='virtual') + +tw.add_edges(source=tw.nodes(), target=net.nodes(pop_name='LIF_exc'), + iterator='all_to_one', + connection_rule=recurrent_connections_low, + connection_params={'n_syns': 1}, + syn_weight=0.5, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousExc.json') + + +tw.add_edges(source=tw.nodes(), target=net.nodes(pop_name='LIF_inh'), + connection_rule=1, + syn_weight=0.2, + weight_function='wmax', + delay=0.0, + dynamics_params='instanteneousExc.json') + +tw.build() +tw.save(output_dir='../input/network')''' + + +net_pre.build() +net_pre.save(output_dir='../input/network') + +net_post.build() +net_post.save(output_dir='../input/network') + + +print 'done' \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/circuit_config.json b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/circuit_config.json new file mode 100644 index 0000000..5e135eb --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/circuit_config.json @@ -0,0 +1,33 @@ +{ + "manifest": { + "$NETWORK_DIR": "../input/network", + "$COMPONENT_DIR": "../../../shared_components" + }, + + "components": { + "synaptic_models_dir": "$COMPONENT_DIR/synaptic_models", + "mechanisms_dir":"$COMPONENT_DIR/mechanisms", + "point_neuron_models_dir": "$COMPONENT_DIR/point_neuron_models_dir" + }, + + "networks": { + "nodes": [ + { + "nodes_file": "$NETWORK_DIR/pre_nodes.h5", + "node_types_file": "$NETWORK_DIR/pre_node_types.csv" + }, + { + "nodes_file": "$NETWORK_DIR/post_nodes.h5", + "node_types_file": "$NETWORK_DIR/post_node_types.csv" + } + ], + + "edges": [ + { + "edges_file": "$NETWORK_DIR/pre_post_edges.h5", + "edge_types_file": "$NETWORK_DIR/pre_post_edge_types.csv" + } + ] + } +} + diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/config.json b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/config.json new file mode 100644 index 0000000..890caa3 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/config.json @@ -0,0 +1,4 @@ +{ + "network": "./circuit_config.json", + "simulation": "./simulation_config.json" +} diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_node_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_node_types.csv new file mode 100644 index 0000000..78d1f83 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_node_types.csv @@ -0,0 +1,2 @@ +node_type_id ei pop_name location model_template model_type dynamics_params +100 e Exc VisL4 nrn:IntFire1 point_process IntFire1_exc_1.json diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_nodes.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_nodes.h5 new file mode 100644 index 0000000..936b7ce Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/post_nodes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_node_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_node_types.csv new file mode 100644 index 0000000..b4a880c --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_node_types.csv @@ -0,0 +1,2 @@ +node_type_id model_type ei location pop_name +100 virtual e TW VirtualCells diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_nodes.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_nodes.h5 new file mode 100644 index 0000000..2a24af3 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_nodes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edge_types.csv b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edge_types.csv new file mode 100644 index 0000000..52ca28a --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edge_types.csv @@ -0,0 +1,2 @@ +edge_type_id target_query source_query delay weight_function syn_weight dynamics_params +100 pop_name=='Exc' * 0.0 wmax 5 instanteneousExc.json diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edges.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edges.h5 new file mode 100644 index 0000000..74d78c7 Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/network/pre_post_edges.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/node_sets.json b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/node_sets.json new file mode 100644 index 0000000..753820e --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/node_sets.json @@ -0,0 +1,9 @@ +{ + "point_nodes": { + "model_type": "point_process" + }, + "e_nodes": { + "model_type": "point_process", + "ei": "e" + } +} \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/simulation_config.json b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/simulation_config.json new file mode 100644 index 0000000..26c7800 --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/simulation_config.json @@ -0,0 +1,52 @@ +{ + "manifest": { + "$OUTPUT_DIR": "./output", + "$INPUT_DIR": "../input" + }, + + "run": { + "tstop": 3000.0, + "dt": 0.1, + "dL": 20.0, + "spike_threshold": -15, + "nsteps_block": 5000, + "overwrite_output_dir": true + }, + + "target_simulator":"NEURON", + + "conditions": { + "celsius": 34.0, + "v_init": -80 + }, + + "node_sets_file": "$INPUT_DIR/node_sets.json", + + "inputs": { + "virtual_nodes_spikes": { + "input_type": "spikes", + "module": "h5", + "input_file": "$INPUT_DIR/tw_spikes.h5", + "node_set": "pre" + } + }, + + + "output":{ + "output_dir": "$OUTPUT_DIR", + "log_file": "log.txt", + "spikes_file": "spikes.h5", + "spikes_sort_order": "time" + }, + + + "reports": { + "membrane_potential": { + "cells": "point_nodes", + "variable_name": "m", + "module": "membrane_report", + "sections": "soma" + } + } + +} \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/tw_spikes.h5 b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/tw_spikes.h5 new file mode 100644 index 0000000..82a029d Binary files /dev/null and b/examples/sim_tests/intfire/ten_cells_spikes_nrn/input/tw_spikes.h5 differ diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/analyze_output.py b/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/analyze_output.py new file mode 100644 index 0000000..efd4fbe --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/analyze_output.py @@ -0,0 +1,13 @@ +import sys +from bmtk.analyzer.visualization.spikes import plot_spikes + + +sys.path.append("../../../shared_components/scripts") + +from analyze_output_utils import plot_data + +if __name__ == '__main__': + + #plot_data('output/membrane_potential.h5', 'mV', 'Membrane Potential', show_already=True) + plot_spikes('../input/network/pre_nodes.h5', '../input/network/pre_node_types.csv', 'output/spikes.h5') + plot_spikes('../input/network/post_nodes.h5', '../input/network/post_node_types.csv', 'output/spikes.h5') \ No newline at end of file diff --git a/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/run_bmtk.sh b/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/run_bmtk.sh new file mode 100755 index 0000000..f6f175e --- /dev/null +++ b/examples/sim_tests/intfire/ten_cells_spikes_nrn/test/run_bmtk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +rm -rf output +rm -rf __pycache__ +# python -m trace --trace ../shared_components/scripts/run_bionet.py ../input/config.json +python ../../../shared_components/scripts/run_bionet.py NEURON ../input/config.json + +pytest -vvs diff --git a/examples/sim_tests/shared_components/configs/config.json b/examples/sim_tests/shared_components/configs/config.json new file mode 100755 index 0000000..890caa3 --- /dev/null +++ b/examples/sim_tests/shared_components/configs/config.json @@ -0,0 +1,4 @@ +{ + "network": "./circuit_config.json", + "simulation": "./simulation_config.json" +} diff --git a/examples/sim_tests/shared_components/mechanisms/modfiles/vecevent.mod b/examples/sim_tests/shared_components/mechanisms/modfiles/vecevent.mod new file mode 100644 index 0000000..503dfd2 --- /dev/null +++ b/examples/sim_tests/shared_components/mechanisms/modfiles/vecevent.mod @@ -0,0 +1,71 @@ +: Vector stream of events + +NEURON { + ARTIFICIAL_CELL VecStim +} + +ASSIGNED { + index + etime (ms) + space +} + +INITIAL { + index = 0 + element() + if (index > 0) { + net_send(etime - t, 1) + } +} + +NET_RECEIVE (w) { + if (flag == 1) { + net_event(t) + element() + if (index > 0) { + net_send(etime - t, 1) + } + } +} + +VERBATIM +extern double* vector_vec(); +extern int vector_capacity(); +extern void* vector_arg(); +ENDVERBATIM + +PROCEDURE element() { +VERBATIM + { void* vv; int i, size; double* px; + i = (int)index; + if (i >= 0) { + vv = *((void**)(&space)); + if (vv) { + size = vector_capacity(vv); + px = vector_vec(vv); + if (i < size) { + etime = px[i]; + index += 1.; + }else{ + index = -1.; + } + }else{ + index = -1.; + } + } + } +ENDVERBATIM +} + +PROCEDURE play() { +VERBATIM + void** vv; + vv = (void**)(&space); + *vv = (void*)0; + if (ifarg(1)) { + *vv = vector_arg(1); + } +ENDVERBATIM +} + + diff --git a/examples/sim_tests/shared_components/nest_models/cell_models/472363762_point.json b/examples/sim_tests/shared_components/nest_models/cell_models/472363762_point.json new file mode 100644 index 0000000..e6154b1 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/cell_models/472363762_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 44.9, + "C_m": 239.0, + "t_ref": 3.0, + "E_L": -78.0, + "V_th": -43.0, + "V_reset": -55.0 +} diff --git a/examples/sim_tests/shared_components/nest_models/cell_models/472912177_point.json b/examples/sim_tests/shared_components/nest_models/cell_models/472912177_point.json new file mode 100644 index 0000000..30b9822 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/cell_models/472912177_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 22.2, + "C_m": 180.0, + "t_ref": 3.0, + "E_L": -82.0, + "V_th": -35.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/nest_models/cell_models/473862421_point.json b/examples/sim_tests/shared_components/nest_models/cell_models/473862421_point.json new file mode 100644 index 0000000..6d7e76a --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/cell_models/473862421_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 12.5, + "C_m": 78.0, + "t_ref": 3.0, + "E_L": -73.0, + "V_th": -37.0, + "V_reset": -55.0 +} diff --git a/examples/sim_tests/shared_components/nest_models/cell_models/473863035_point.json b/examples/sim_tests/shared_components/nest_models/cell_models/473863035_point.json new file mode 100644 index 0000000..db8e5e4 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/cell_models/473863035_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 22.1, + "C_m": 117.0, + "t_ref": 3.0, + "E_L": -78.0, + "V_th": -47.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/nest_models/cell_models/473863510_point.json b/examples/sim_tests/shared_components/nest_models/cell_models/473863510_point.json new file mode 100644 index 0000000..348c569 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/cell_models/473863510_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 11.5, + "C_m": 53.0, + "t_ref": 3.0, + "E_L": -72.0, + "V_th": -25.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToExc.json b/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToExc.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToExc.json @@ -0,0 +1,2 @@ +{ +} diff --git a/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToInh.json b/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToInh.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/synaptic_models/ExcToInh.json @@ -0,0 +1,2 @@ +{ +} diff --git a/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToExc.json b/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToExc.json new file mode 100644 index 0000000..bfd870e --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToExc.json @@ -0,0 +1,3 @@ +{ +} + diff --git a/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToInh.json b/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToInh.json new file mode 100644 index 0000000..bfd870e --- /dev/null +++ b/examples/sim_tests/shared_components/nest_models/synaptic_models/InhToInh.json @@ -0,0 +1,3 @@ +{ +} + diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/472363762_point.json b/examples/sim_tests/shared_components/point_neuron_models_dir/472363762_point.json new file mode 100644 index 0000000..e6154b1 --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/472363762_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 44.9, + "C_m": 239.0, + "t_ref": 3.0, + "E_L": -78.0, + "V_th": -43.0, + "V_reset": -55.0 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/472912177_point.json b/examples/sim_tests/shared_components/point_neuron_models_dir/472912177_point.json new file mode 100644 index 0000000..30b9822 --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/472912177_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 22.2, + "C_m": 180.0, + "t_ref": 3.0, + "E_L": -82.0, + "V_th": -35.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/473862421_point.json b/examples/sim_tests/shared_components/point_neuron_models_dir/473862421_point.json new file mode 100644 index 0000000..6d7e76a --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/473862421_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 12.5, + "C_m": 78.0, + "t_ref": 3.0, + "E_L": -73.0, + "V_th": -37.0, + "V_reset": -55.0 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/473863035_point.json b/examples/sim_tests/shared_components/point_neuron_models_dir/473863035_point.json new file mode 100644 index 0000000..db8e5e4 --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/473863035_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 22.1, + "C_m": 117.0, + "t_ref": 3.0, + "E_L": -78.0, + "V_th": -47.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/473863510_point.json b/examples/sim_tests/shared_components/point_neuron_models_dir/473863510_point.json new file mode 100644 index 0000000..348c569 --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/473863510_point.json @@ -0,0 +1,9 @@ +{ + "I_e": 0.0, + "tau_m": 11.5, + "C_m": 53.0, + "t_ref": 3.0, + "E_L": -72.0, + "V_th": -25.0, + "V_reset": -50.0 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_exc_1.json b/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_exc_1.json new file mode 100644 index 0000000..6a58d3b --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_exc_1.json @@ -0,0 +1,5 @@ +{ + "tau": 0.024, + "type": "NEURON_IntFire1", + "refrac": 0.003 +} diff --git a/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_inh_1.json b/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_inh_1.json new file mode 100644 index 0000000..0da2f1f --- /dev/null +++ b/examples/sim_tests/shared_components/point_neuron_models_dir/IntFire1_inh_1.json @@ -0,0 +1,5 @@ +{ + "tau": 0.007, + "type": "NEURON_IntFire1", + "refrac": 0.003 +} diff --git a/examples/sim_tests/shared_components/scripts/analyze_output_utils.py b/examples/sim_tests/shared_components/scripts/analyze_output_utils.py new file mode 100644 index 0000000..99437df --- /dev/null +++ b/examples/sim_tests/shared_components/scripts/analyze_output_utils.py @@ -0,0 +1,66 @@ + +import h5py +import numpy as np +import matplotlib.pyplot as plt + + +def plot_data(reports_file, y_axis, title, show_already=True, max_num_traces=None): + print('Plotting data on %s (%s) from file: %s'%(title, y_axis, reports_file)) + cellvar_h5 = h5py.File(reports_file, 'r') + + + try: + top_level = cellvar_h5['/mapping'] + pop_prefixes = {'GLOBAL':'/'} + except: + pop_prefixes = {} + for pop in cellvar_h5['/report'].keys(): + pop_prefixes = {pop:'/report/%s/'%pop} + + for pop in pop_prefixes: + + gids = np.array(cellvar_h5['%smapping/gids'%pop_prefixes[pop]]) + + soma_locs = np.array(cellvar_h5['%smapping/index_pointer'%pop_prefixes[pop]]) # location of soma + t_start = cellvar_h5['%smapping/time'%pop_prefixes[pop]][0] + t_stop = cellvar_h5['%smapping/time'%pop_prefixes[pop]][1] + dt = cellvar_h5['%smapping/time'%pop_prefixes[pop]][2] + time_steps = np.linspace(t_start, t_stop, 1+(t_stop-t_start)/float(dt)) + print('Time steps %s -> %s, dt: %s (%s points)'%(t_start,t_stop,dt, len(time_steps))) + + n_plots = len(gids) + if max_num_traces: + n_plots = min(max_num_traces, n_plots) + data_table = np.array(cellvar_h5['%sdata'%pop_prefixes[pop]]) + f, axarr = plt.subplots(n_plots, 1) + f.suptitle(title) + for i, (gid, soma_index) in enumerate(zip(gids, soma_locs)): + if i