Hi Mahmoud,
Thanks for your help. I think I get them via NEST.
My brain has one input and output layer. It also has two neurons serves as the dopamine modulator. It looks like this:
# from hbp_nrp_cle.brainsim import simulator as sim
import numpy as np
import logging
import nest
import pyNN.nest as sim
from pyNN.nest import *
from hbp_nrp_excontrol.logs import clientLogger
import h5py
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
def create_brain():
"""
Initializes PyNN with the neuronal network that has to be simulated
"""
resolution = [2, 8]
# R-STDP parameters
# Minimum weight value
w_max = 2500.
# Maximum weight value
w_min = -w_max
# Minimum initial random value
w0_min = 0.1
# Maximum initial random value
w0_max = 0.11
# Time constant of reward signal in ms
tau_n = 200.
# Time constant of eligibility trace in ms
tau_c = 1000.
# Factor that dopamine modulator for turning is multiplied with
max_turning_dopamine_factor = 0.0015
# Factor that dopamine modulator for speed is multiplied with
max_speed_dopamine_factor = 0.001
# Constant scaling strength of potentiation
A_plus = 1.
# Constant scaling strength of depression
A_minus = 1.
nest.ResetKernel()
############################
###### CREATE LAYERS #######
############################
INPUT_OUTPUT_PARAMS = {'v_rest': -60.5,
'cm': 0.025,
'tau_m': 10.,
# brain sim time length 1 s -> max rate 100
'tau_refrac': 20.0,
'tau_syn_E': 2.5,
'tau_syn_I': 2.5,
'e_rev_E': 0.0,
'e_rev_I': -75.0,
'v_thresh': -60.0,
'v_reset': -60.5}
all_neurons = sim.Population(20, sim.IF_cond_alpha, INPUT_OUTPUT_PARAMS)
input_layer = sim.PopulationView(all_neurons, slice(0, 16))
dm_layer = sim.PopulationView(all_neurons, slice(16, 18))
output_layer = sim.PopulationView(all_neurons, slice(18, 20))
spike_detector = nest.Create("spike_detector", 2, params={"withtime": True})
vt = nest.Create('volume_transmitter', 2)
############################
###### CONNECT LAYERS ######
############################
nest.CopyModel('stdp_dopamine_synapse', 'syn_left',
{'Wmax': 2500.0,
'Wmin': -2500.0,
'tau_plus': 20.0,
'A_minus': 1.0,
'A_plus': -1.0,
'b': 0.01,
'tau_c': 10.0,
'tau_n': 5.0,
'vt': vt[0]})
nest.CopyModel('stdp_dopamine_synapse', 'syn_right',
{'Wmax': 2500.0,
'Wmin': -2500.0,
'tau_plus': 20.0,
'A_minus': 1.0,
'A_plus': -1.0,
'b': 0.01,
'tau_c': 10.0,
'tau_n': 5.0,
'vt': vt[1]})
syn_con_left = nest.Connect(map(int, input_layer.all_cells),
map(int, output_layer[0:1]), syn_spec={'model': 'syn_left', 'weight': {'distribution': 'uniform', 'low': w0_min, 'high': w0_max}})
syn_con_right = nest.Connect(map(int, input_layer.all_cells),
map(int, output_layer[1:2]),
syn_spec={'model': 'syn_right', 'weight': {'distribution': 'uniform', 'low': w0_min, 'high': w0_max}})
nest.Connect(map(int, dm_layer[0:1]), vt[0:1])
nest.Connect(map(int, dm_layer[1:2]), vt[1:2])
conn_l = nest.GetConnections(target=[output_layer[0]])
weights_l = nest.GetStatus(conn_l, keys="weight")
conn_r = nest.GetConnections(target=[output_layer[1]])
weights_r = nest.GetStatus(conn_r, keys="weight")
cur_time_step = sim.get_time_step()
logger.debug("Synapse Left: " + str(weights_l))
logger.debug("Sim Time Step: " + str(cur_time_step) + " (ms)")
logger.debug("Circuit description: " + str(all_neurons.describe()))
return all_neurons
circuit = create_brain()
I use nest.Connect to connect neurons. Use nest.GetConnections to get synapses. Use nest.GetStatus to get the value of the weights.
Regards,
Zhenshan