Exemple #1
0
def get_steady_state(net):
    lab_manager.reset_lab(net)
    f, initial_conditions, _ = lab_manager.set_up_lab(net)
    total_time = 100.
    # step 4: run the lab and gather data
    time_sampled_range = [total_time]
    data = lab_manager.run_lab(f, initial_conditions, time_sampled_range)
    return data[-1, :]
Exemple #2
0
def get_data(delta_time):
    """Return the integration solution."""
    # step 2: design an experiment
    T0 = 250.
    TIME_DELAY = delta_time
    ex.delay_pulses_on_layer_0_and_1(net,
                                     t0s=[T0, T0 + TIME_DELAY],
                                     i_max=55.,
                                     w=1.0)
    # step 3: ask our lab manager to set up the lab for the experiment
    f, initial_conditions, neuron_inds = lm.set_up_lab(net)
    # step 4: run the lab and gather data
    data = lm.run_lab(f,
                      initial_conditions,
                      time_sampled_range,
                      integrator='dopri5')
    return data
Exemple #3
0
def stdp_expt(net, dt, ics):  # please put a 1-1 network
    def sigmoid(x):
        return 1. / (1. + np.exp(-x))

    lab_manager.reset_lab(net)
    dts = [dt]
    experiments.delay_pulses_on_layer_0_and_1(net, [50., 50 + dt])
    # step 3: ask our lab manager to set up the lab for the experiment.
    f, _, _ = lab_manager.set_up_lab(net)
    ii = 0
    for edge in net.edges:
        n1, n2 = edge
        syn = net[n1][n2]["synapse"]
        ii = syn.ii
    # step 4: run the lab and gather data
    total_time = 100.
    time_sampled_range = np.arange(0., total_time, 0.1)
    data = lab_manager.run_lab(f, initial_conditions, time_sampled_range)
    #print(ii)
    dw = sigmoid(data[-1, ii]) - sigmoid(data[0, ii])
    return dw, data
Exemple #4
0
def get_stdp_profile(Neuron, Synapse, initial_conditions):
    Neuron = get_InsulatedNeuron(Neuron)
    # run stdp experiment
    stdp_time_range = np.arange(-40, 40, 2)
    stdp_data = np.empty_like(stdp_time_range)
    for i, dt in enumerate(stdp_time_range):
        stdp_data[i], _ = stdp_expt(net, dt, initial_conditions)

    plt.figure()
    plt.plot(stdp_time_range, stdp_data, marker="o")
    plt.grid()


# verify
get_stdp_profile(Neuron, Synapse, initial_conditions)

# A experiment with pulse train
Neuron, Synapse = nm.HHNeuronWithCaJL, nm.PlasticNMDASynapseWithCaJL
neuron_nums = [1, 1]
net = networks.get_multilayer_fc(Neuron, Synapse, neuron_nums)
total_time = 1000.
time_sampled_range = np.arange(0., total_time, 0.1)
f, _, _ = lab_manager.set_up_lab(net)
t0s = np.arange(0, 1000, 50)
experiments.pulse_train_on_layer(net, 0, t0s, i_max=50.)
data = lab_manager.run_lab(f, initial_conditions, time_sampled_range)
lab_manager.show_all_neuron_in_layer(time_sampled_range, data, net, 0)
lab_manager.show_all_neuron_in_layer(time_sampled_range, data, net, 1)
lab_manager.show_all_synaspe_onto_layer(time_sampled_range, data, net, 1)
Exemple #5
0
# Set up the experiment with a constant input current
ex.const_current(AL, num_layers, neuron_inds, current_vals)

#set up the lab
f, initial_conditions, neuron_inds = lm.set_up_lab(AL)

#run for specified time with dt
time_len = 1000.0  #Run for 600 ms
dt = 0.02  # Integration time step 0.02 ms
time_sampled_range = np.arange(0., time_len, dt)

# Run the lab and get output
data = lm.run_lab(f,
                  initial_conditions,
                  time_sampled_range,
                  integrator='dopri5',
                  compile=True)

#save PN data for analysis
V_vec = []
all_neurons = AL.layers[1].nodes()
for (n, neuron) in enumerate(all_neurons):
    ii = neuron.ii
    V_vec.append(data[:, ii])
#np.save('AL_data_62', V_vec)

# This is code generated to plot this specific example. There are other plotting
# functions within the lab_manager file.
#lm.show_all_neuron_in_layer(time_sampled_range,data,AL,1)
import matplotlib
Exemple #6
0
    net, base_rate, i_max=i_max, num_sniffs=num_sniffs,
    time_per_sniff=time_per_sniff)
# # for more than two pre-synaptic neurons, use the following instead
# ex.feed_gaussian_rate_poisson_spikes_DL(
#     net, base_rate, i_max=i_max, num_sniffs=num_sniffs,
#     time_per_sniff=time_per_sniff)

# periodic
# total_time = 1000
# i_max=100.
# base_rate = 0.01
# ratio = 0.95
# ex.feed_periodic_spikes(net, base_rate, ratio, total_time, i_max)


# step 3: ask our lab manager to set up the lab for the experiment.
f, initial_conditions, _ = lm.set_up_lab(net)

# step 4: run the lab and gather data
time_sampled_range = np.arange(0., total_time, 0.1)
data = lm.run_lab(f, initial_conditions, time_sampled_range)

# Time to witness some magic
for layer_idx in range(len(net.layers)):
    lm.show_all_neuron_in_layer(
        time_sampled_range, data, net, layer_idx)

for layer_idx in range(len(net.layers)):
    lm.show_all_dendrite_onto_layer(
        time_sampled_range, data, net, layer_idx, delta_time=None)