Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff exp dev #22

Draft
wants to merge 13 commits into
base: experimental
Choose a base branch
from
Prev Previous commit
Next Next commit
Initial export from new PyNN version to NeuroML
  • Loading branch information
pgleeson committed Apr 2, 2024
commit 60135a550ca8fee1871540c9c2c479aa88a68226
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -32,3 +32,7 @@ NEST_SLI/*.gdf
/PyNN/tests.log
/PyNN/data/2024*
/p0/*
/NeuroML2/*.dat
/PyNN/LEMS_Sim_Microcircuit*.xml
/NeuroML2/*.spikes
/NeuroML2/Microcircuit*.gv
277 changes: 277 additions & 0 deletions NeuroML2/LEMS_Sim_Microcircuit_0_2pcnt.xml

Large diffs are not rendered by default.

58,906 changes: 58,906 additions & 0 deletions NeuroML2/Microcircuit_0_2pcnt.net.nml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions NeuroML2/regenerate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex

cd ../PyNN
python test_neuroml.py

cp *.nml LEMS*ml ../NeuroML2
11 changes: 6 additions & 5 deletions PyNN/network.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ def __init__(self, sim_dict, net_dict, stim_dict=None):
self.data_path = sim_dict['data_path']


def setup_pyNN(self):
def setup_pyNN(self, extra_setup_params):
""" Reset and configure the simulator.

Where the simulator is NEST,
@@ -73,7 +73,8 @@ def setup_pyNN(self):
self.sim.setup(timestep=self.sim_resolution,
threads=self.sim_dict['local_num_threads'],
grng_seed=grng_seed,
rng_seeds=rng_seeds)
rng_seeds=rng_seeds,
**extra_setup_params)
if self.sim.rank() == 0:
print('Master seed: %i ' % master_seed)
print('Number of total processes: %i' % N_tp)
@@ -230,7 +231,7 @@ def create_poisson(self):
for i, target_pop in enumerate(self.pops):
poisson = self.sim.Population(target_pop.size,
self.sim.SpikeSourcePoisson(rate=rate_ext[i]),
label="Input to {}".format(target_pop.label))
label="Input_to_{}".format(target_pop.label))
self.poisson.append(poisson)

def create_dc_generator(self):
@@ -369,7 +370,7 @@ def connect_dc_generator(self):
if self.stim_dict['dc_input']:
self.dc[i].inject_into(target_pop)

def setup(self):
def setup(self, extra_setup_params = {}):
"""
Execute subfunctions of the network.

@@ -378,7 +379,7 @@ def setup(self):
each other and with devices and input nodes.

"""
self.setup_pyNN()
self.setup_pyNN(extra_setup_params)
self.create_populations()
self.create_devices()
self.create_thalamic_input()
74 changes: 44 additions & 30 deletions PyNN/test.py
Original file line number Diff line number Diff line change
@@ -3,10 +3,7 @@
PyNN microcircuit example
---------------------------

Example file to run the microcircuit.

Based on original PyNEST version by Hendrik Rothe, Hannah Bos, Sacha van Albada; May 2016
Adapted for PyNN by Andrew Davison, December 2017
Test file for the microcircuit.

"""

@@ -18,29 +15,46 @@
from stimulus_params import stim_dict
import os


# Initialize the network and pass parameters to it.
tic = time.time()

net_dict['N_scaling'] = 0.1
net_dict['to_record'] = ['spikes', 'v']
sim_dict['data_path'] = os.path.join(os.getcwd(), 'results')


net = network.Network(sim_dict, net_dict, stim_dict)
toc = time.time() - tic
print("Time to initialize the network: %.2f s" % toc)
# Connect all nodes.
tic = time.time()
net.setup()
toc = time.time() - tic
print("Time to create the connections: %.2f s" % toc)
# Simulate.
tic = time.time()
net.simulate()
toc = time.time() - tic
print("Time to simulate: %.2f s" % toc)
tic = time.time()
net.write_data()
toc = time.time() - tic
print("Time to write data: %.2f s" % toc)
def setup(simulator='nest', N_scaling=0.1):
# Initialize the network and pass parameters to it.
tic = time.time()

net_dict['N_scaling'] = N_scaling

net_dict['to_record'] = ['spikes', 'v']
sim_dict['data_path'] = os.path.join(os.getcwd(), 'results')

sim_dict['simulator'] = simulator

net = network.Network(sim_dict, net_dict, stim_dict)
toc = time.time() - tic
print("Time to initialize the network: %.2f s" % toc)

# Connect all nodes.
tic = time.time()
extra_setup_params = {}
if simulator=='neuroml':
extra_setup_params['reference']='Microcircuit_%spcnt'%(str(N_scaling*100).replace('.','_'))

net.setup(extra_setup_params)
toc = time.time() - tic
print("Time to create the connections: %.2f s" % toc)
return net, net_dict, sim_dict


def run(net):

# Simulate.
tic = time.time()
net.simulate()
toc = time.time() - tic
print("Time to simulate: %.2f s" % toc)
tic = time.time()
net.write_data()
toc = time.time() - tic
print("Time to write data: %.2f s" % toc)


if __name__ == "__main__":
net, net_dict, sim_dict = setup(N_scaling=0.1)
run(net)
35 changes: 35 additions & 0 deletions PyNN/test_neuroml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""
PyNN microcircuit example
---------------------------

Export to NeuroML of the microcircuit.

"""

import time
import numpy as np
import network
from network_params import net_dict
from sim_params import sim_dict
from stimulus_params import stim_dict
import os

from test import setup

def export(net):

# Export.
tic = time.time()
print("Exporting...")
net.simulate()
net.sim.end()
toc = time.time() - tic
print("Time to export: %.2f s" % toc)



if __name__ == "__main__":
net, net_dict, sim_dict = setup(simulator='neuroml',
N_scaling=0.002)
export(net)
Loading