Skip to content
Snippets Groups Projects
Commit 3635bac5 authored by jasperalbers's avatar jasperalbers
Browse files

update to final NEST 3.0 syntax

parent 44d7357a
No related branches found
No related tags found
1 merge request!19Enable use of NEST 3
...@@ -622,6 +622,7 @@ def connect(simulation, ...@@ -622,6 +622,7 @@ def connect(simulation,
source_area : Area instance source_area : Area instance
Source area of the projection Source area of the projection
""" """
network = simulation.network network = simulation.network
synapses = extract_area_dict(network.synapses, synapses = extract_area_dict(network.synapses,
network.structure, network.structure,
...@@ -635,6 +636,50 @@ def connect(simulation, ...@@ -635,6 +636,50 @@ def connect(simulation,
network.structure, network.structure,
target_area.name, target_area.name,
source_area.name) source_area.name)
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:
for target in target_area.populations: for target in target_area.populations:
for source in source_area.populations: for source in source_area.populations:
conn_spec = {'rule': 'fixed_total_number', conn_spec = {'rule': 'fixed_total_number',
...@@ -654,7 +699,6 @@ def connect(simulation, ...@@ -654,7 +699,6 @@ def connect(simulation,
v = network.params['delay_params']['interarea_speed'] v = network.params['delay_params']['interarea_speed']
s = network.distances[target_area.name][source_area.name] s = network.distances[target_area.name][source_area.name]
mean_delay = s / v mean_delay = s / v
syn_delay = {'distribution': 'normal_clipped', syn_delay = {'distribution': 'normal_clipped',
'low': simulation.params['dt'], 'low': simulation.params['dt'],
'mu': mean_delay, 'mu': mean_delay,
...@@ -663,12 +707,6 @@ def connect(simulation, ...@@ -663,12 +707,6 @@ def connect(simulation,
'delay': syn_delay, 'delay': syn_delay,
'model': 'static_synapse'} 'model': 'static_synapse'}
if network.params['USING_NEST_3']:
nest.Connect(source_area.gids[source],
target_area.gids[target],
conn_spec,
syn_spec)
else:
nest.Connect(tuple(range(source_area.gids[source][0], nest.Connect(tuple(range(source_area.gids[source][0],
source_area.gids[source][1] + 1)), source_area.gids[source][1] + 1)),
tuple(range(target_area.gids[target][0], tuple(range(target_area.gids[target][0],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment