Skip to content
Snippets Groups Projects
Unverified Commit fbae2073 authored by Jari Pronold's avatar Jari Pronold Committed by GitHub
Browse files

Merge pull request #4 from jasperalbers/review-nest_2_and_3

Review NEST 3 adaptations
parents eeae09f1 3635bac5
No related branches found
No related tags found
1 merge request!19Enable use of NEST 3
......@@ -69,7 +69,7 @@ technical parameters such as the number of parallel MPI processes and
threads. The simulation uses the network simulator NEST
(https://www.nest-simulator.org). For the simulations in [2, 3], we
used NEST version 2.8.0. The code in this repository runs with a
later release of NEST, version 2.14.0.
later release of NEST, version 2.14.0, as well as NEST 3.0.
`Theory`
......@@ -203,7 +203,7 @@ conveniently run by executing `pytest` in the `tests/` folder:
## Requirements
Python 3, python\_dicthash ([https://github.com/INM-6/python-dicthash](https://github.com/INM-6/python-dicthash)),
correlation\_toolbox ([https://github.com/INM-6/correlation-toolbox](https://github.com/INM-6/correlation-toolbox)),
pandas, numpy, nested_dict, matplotlib (2.1.2), scipy, pytest, NEST 2.14.0
pandas, numpy, nested_dict, matplotlib (2.1.2), scipy, pytest, NEST 2.14.0 or NEST 3.0
Optional: seaborn, Sumatra
......
......@@ -38,7 +38,7 @@ Simulation parameters
"""
sim_params = {
# master seed for random number generators
'master_seed': 0,
'rng_seed': 1,
# simulation step (in ms)
'dt': 0.1,
# simulated time (in ms)
......
......@@ -145,7 +145,7 @@ class Simulation:
Prepare NEST Kernel.
"""
nest.ResetKernel()
master_seed = self.params['master_seed']
rng_seed = self.params['rng_seed']
num_processes = self.params['num_processes']
local_num_threads = self.params['local_num_threads']
vp = num_processes * local_num_threads
......@@ -153,15 +153,18 @@ class Simulation:
'total_num_virtual_procs': vp,
'overwrite_files': True,
'data_path': os.path.join(self.data_dir, 'recordings'),
'print_time': False,
'grng_seed': master_seed,
'rng_seeds': list(range(master_seed + 1,
master_seed + vp + 1))})
'print_time': False})
if self.network.params['USING_NEST_3']:
nest.SetKernelStatus({'rng_seed': rng_seed})
else:
nest.SetKernelStatus({'grng_seed': rng_seed,
'rng_seeds': list(range(rng_seed + 1,
rng_seed + vp + 1))})
self.pyrngs = [np.random.RandomState(s) for s in list(range(
rng_seed + vp + 1, rng_seed + 2 * (vp + 1)))]
nest.SetDefaults(self.network.params['neuron_params']['neuron_model'],
self.network.params['neuron_params']['single_neuron_dict'])
self.pyrngs = [np.random.RandomState(s) for s in list(range(
master_seed + vp + 1, master_seed + 2 * (vp + 1)))]
def create_recording_devices(self):
"""
......@@ -619,6 +622,7 @@ def connect(simulation,
source_area : Area instance
Source area of the projection
"""
network = simulation.network
synapses = extract_area_dict(network.synapses,
network.structure,
......@@ -632,40 +636,77 @@ def connect(simulation,
network.structure,
target_area.name,
source_area.name)
for target in target_area.populations:
for source in source_area.populations:
conn_spec = {'rule': 'fixed_total_number',
'N': int(synapses[target][source])}
syn_weight = {'distribution': 'normal_clipped',
'mu': W[target][source],
'sigma': W_sd[target][source]}
if target_area == source_area:
if 'E' in source:
syn_weight.update({'low': 0.})
mean_delay = network.params['delay_params']['delay_e']
elif 'I' in source:
syn_weight.update({'high': 0.})
mean_delay = network.params['delay_params']['delay_i']
else:
v = network.params['delay_params']['interarea_speed']
s = network.distances[target_area.name][source_area.name]
mean_delay = s / v
syn_delay = {'distribution': 'normal_clipped',
'low': simulation.params['dt'],
'mu': mean_delay,
'sigma': mean_delay * network.params['delay_params']['delay_rel']}
syn_spec = {'weight': syn_weight,
'delay': syn_delay,
'model': 'static_synapse'}
if network.params['USING_NEST_3']:
if network.params['USING_NEST_3']:
for target in target_area.populations:
for source in source_area.populations:
conn_spec = {'rule': 'fixed_total_number',
'N': int(synapses[target][source])}
if target_area == source_area:
if 'E' in source:
w_min = 0.
w_max = np.Inf
mean_delay = network.params['delay_params']['delay_e']
elif 'I' in source:
w_min = np.NINF
w_max = 0.
mean_delay = network.params['delay_params']['delay_i']
else:
w_min = 0.
w_max = np.Inf
v = network.params['delay_params']['interarea_speed']
s = network.distances[target_area.name][source_area.name]
mean_delay = s / v
syn_spec = {
'synapse_model': 'static_synapse',
'weight': nest.math.redraw(
nest.random.normal(mean=W[target][source],
std=W_sd[target][source]),
min=w_min,
max=w_max),
'delay': nest.math.redraw(
nest.random.normal(
mean=mean_delay,
std=(mean_delay *
network.params['delay_params']['delay_rel'])),
min=simulation.params['dt'],
max=np.Inf)
}
nest.Connect(source_area.gids[source],
target_area.gids[target],
conn_spec,
syn_spec)
else:
else:
for target in target_area.populations:
for source in source_area.populations:
conn_spec = {'rule': 'fixed_total_number',
'N': int(synapses[target][source])}
syn_weight = {'distribution': 'normal_clipped',
'mu': W[target][source],
'sigma': W_sd[target][source]}
if target_area == source_area:
if 'E' in source:
syn_weight.update({'low': 0.})
mean_delay = network.params['delay_params']['delay_e']
elif 'I' in source:
syn_weight.update({'high': 0.})
mean_delay = network.params['delay_params']['delay_i']
else:
v = network.params['delay_params']['interarea_speed']
s = network.distances[target_area.name][source_area.name]
mean_delay = s / v
syn_delay = {'distribution': 'normal_clipped',
'low': simulation.params['dt'],
'mu': mean_delay,
'sigma': mean_delay * network.params['delay_params']['delay_rel']}
syn_spec = {'weight': syn_weight,
'delay': syn_delay,
'model': 'static_synapse'}
nest.Connect(tuple(range(source_area.gids[source][0],
source_area.gids[source][1] + 1)),
tuple(range(target_area.gids[target][0],
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment