Skip to content

Commit

Permalink
Merge pull request #95 from apdavison/300_pointneurons
Browse files Browse the repository at this point in the history
Changes needed to run 300_pointneurons example with PyNN
  • Loading branch information
kaeldai authored Mar 21, 2019
2 parents 9b72ad9 + 4fa7d95 commit ad1d46a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
5 changes: 3 additions & 2 deletions examples/300_pointneurons/circuit_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"edge_types_file": "$NETWORK_DIR/external_internal_edge_types.csv"
}
]
},

}
}
"target_simulator": "NEST"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
edge_type_id target_query source_query delay dynamics_params model_template
100 ei=='e' * 2.0 ExcToExc.json static_synapse
101 ei=='i' * 2.0 ExcToInh.json static_synapse
100 ei=='e' * 2.0 ExcToExc.json nest:static_synapse
101 ei=='i' * 2.0 ExcToInh.json nest:static_synapse
Original file line number Diff line number Diff line change
@@ -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 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
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
5 changes: 4 additions & 1 deletion examples/300_pointneurons/node_sets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"population": "external"
},

"recorded_cells": [0, 80, 160, 240, 270]
"recorded_cells": {
"population": "internal",
"node_id": [0, 80, 160, 240, 270]
}
}
21 changes: 16 additions & 5 deletions examples/300_pointneurons/plot_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from bmtk.utils.cell_vars import CellVarsFile


def plot_vars(file_names, cell_var='v', gid_list=[]):
def plot_vars(file_names, cell_var='v', gid_list=[], t_min=None, t_max=None):
"""Plots variable traces for a SONATA h5 file. If multiple spike files are specified will do a side-by-side
comparsion for each gid.
Expand All @@ -29,11 +29,16 @@ def plot_vars(file_names, cell_var='v', gid_list=[]):
assert(len(file_names) > 0)

# Use bmtk to parse the cell-var files
cell_var_files = [CellVarsFile(fn) for fn in file_names]
cell_var_files = []
for fn in file_names:
try:
cell_var_files.append(CellVarsFile(fn, h5_root="/report/internal"))
except KeyError:
cell_var_files.append(CellVarsFile(fn))

# get first spike file and properties
cvf_base = cell_var_files[0]
xlim = [cvf_base.time_trace[0], cvf_base.time_trace[-1]] # Use the same x-axis across all subplots
xlim = [t_min or cvf_base.time_trace[0], t_max or cvf_base.time_trace[-1]] # Use the same x-axis across all subplots
gid_list = cvf_base.gids if not gid_list else gid_list # if gid_list is None just get all gids in first file
n_cells = len(cvf_base.gids)

Expand Down Expand Up @@ -64,13 +69,19 @@ def plot_vars(file_names, cell_var='v', gid_list=[]):
action='callback',
callback=lambda option, opt, value, parser: setattr(parser.values, option.dest, [int(v) for v in value.split(',')]),
help='comma seperated list of gids to plot')
parser.add_option('--tmin', type=float, dest='t_min', default=None)
parser.add_option('--tmax', type=float, dest='t_max', default=None)
options, args = parser.parse_args()

if len(args) == 0:
# If no file is specified see if there is a output/membrane_potential.h5 file to plot membrane voltage
if not os.path.exists('output/membrane_potential.h5'):
raise Exception('Please specifiy hdf5 file to read in arguments. Exiting!')
else:
plot_vars('output/membrane_potential.h5', cell_var=options.cell_var)
plot_vars('output/membrane_potential.h5', cell_var=options.cell_var, t_min=options.t_min, t_max=options.t_max)
else:
plot_vars(file_names=args, cell_var=options.cell_var, gid_list=options.gids)
plot_vars(file_names=args, cell_var=options.cell_var, gid_list=options.gids, t_min=options.t_min, t_max=options.t_max)
if len(args) == 1:
plt.savefig(args[0].replace(".h5", ".png"))
else:
plt.savefig("comparison_{}.png".format(options.cell_var))
7 changes: 7 additions & 0 deletions examples/300_pointneurons/run_PyNN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pyNN.serialization import import_from_sonata, load_sonata_simulation_plan
import pyNN.nest 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)

0 comments on commit ad1d46a

Please sign in to comment.