Ejemplo n.º 1
0
#  Copyright 2020 Forschungszentrum Jülich GmbH and Aix-Marseille Université
# "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0. "

from nest_elephant_tvb.Tvb.modify_tvb.test_interface import tvb_sim
import numpy as np

weight = np.array([[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]])
delay = np.array([[1.5,1.5,1.5,1.5],[1.5,1.5,1.5,1.5],[1.5,1.5,1.5,1.5],[1.5,1.5,1.5,1.5]])
resolution_simulation = 0.1
resolution_monitor = 1.0
time_synchronize = 1.0
proxy_id =  [0,1]
firing_rate = np.array([[20.0,10.0]])*10**-3 # units time in tvb is ms so the rate is in KHz

sim = tvb_sim(weight, delay,proxy_id, resolution_simulation, resolution_monitor,time_synchronize)
time, result = sim(resolution_monitor,[np.array([resolution_simulation]),firing_rate])
for i in range(0,100):
    time,result = sim(time_synchronize,[time+resolution_monitor,np.repeat(firing_rate.reshape(1,2),int(resolution_monitor/resolution_simulation),axis=0)])
print('test succeeds')
Ejemplo n.º 2
0
from nest_elephant_tvb.Tvb.modify_tvb.test_interface import tvb_sim
import numpy as np
import numpy.random as rgn

weight = np.array([[1, 1], [1, 1]])
delay = np.array([[10.0, 10.0], [10.0, 10.0]])
resolution_simulation = 0.1
resolution_monitor = 0.1 * 3
time_synchronize = 0.1 * 3
proxy_id_1 = [0]
proxy_id_2 = [1]

# full simulation
rgn.seed(42)
sim_ref = tvb_sim(weight, delay, [], resolution_simulation, resolution_monitor,
                  time_synchronize)
time, result_ref, s_ref = sim_ref(resolution_monitor, s=True)

# simulation with one proxy
rgn.seed(42)
sim_1 = tvb_sim(weight, delay, proxy_id_1, resolution_simulation,
                resolution_monitor, time_synchronize)
time, result_1, s_1 = sim_1(resolution_monitor,
                            [time, result_ref[:, proxy_id_1][:, :, 0]],
                            s=True)

# simulation_2 with one proxy
rgn.seed(42)
sim_2 = tvb_sim(weight, delay, proxy_id_2, resolution_simulation,
                resolution_monitor, time_synchronize)
time, result_2, s_2 = sim_2(resolution_monitor,
Ejemplo n.º 3
0
init_value = [[0.9], [0.9]]
resolution_simulation = 0.1
# resolution_monitor = 0.1*10.0
# time_synchronize = 0.1*10.0
resolution_monitor = 0.1 * 10.0
time_synchronize = 0.1 * 10.0
nb_init = (int(delay / resolution_simulation)) + 1
initial_condition = np.array(init_value * nb_init).reshape(
    nb_init, 1, weight.shape[0], 1)
proxy_id = [0]

# full simulation
rgn.seed(42)
sim_ref = tvb_sim(weight,
                  delays, [],
                  resolution_simulation,
                  resolution_monitor,
                  time_synchronize,
                  initial_condition=initial_condition)
time, result_ref, s_ref = sim_ref(resolution_monitor, s=True)

# simulation with one proxy
rgn.seed(42)
sim = tvb_sim(weight,
              delays,
              proxy_id,
              resolution_simulation,
              resolution_monitor,
              time_synchronize,
              initial_condition=initial_condition)
time, result, s = sim(resolution_monitor,
                      [time, result_ref[:, proxy_id][:, :, 0]],