Ejemplo n.º 1
0
def getting_started():
    """
    A simple example to get started.
    Returns:

    """
    stim_start = 150. * b2.ms
    stim_duration = 350 * b2.ms
    print("stimulus start: {}, stimulus end: {}".format(
        stim_start, stim_start + stim_duration))
    results = sim_decision_making_network(N_Excit=341,
                                          N_Inhib=85,
                                          weight_scaling_factor=6.0,
                                          t_stimulus_start=stim_start,
                                          t_stimulus_duration=stim_duration,
                                          coherence_level=+0.90,
                                          w_pos=2.0,
                                          mu0_mean_stimulus_Hz=500 * b2.Hz,
                                          max_sim_time=800. * b2.ms)
    plot_tools.plot_network_activity(results["rate_monitor_A"],
                                     results["spike_monitor_A"],
                                     results["voltage_monitor_A"],
                                     t_min=0. * b2.ms,
                                     avg_window_width=20. * b2.ms,
                                     sup_title="Left")
    plot_tools.plot_network_activity(results["rate_monitor_B"],
                                     results["spike_monitor_B"],
                                     results["voltage_monitor_B"],
                                     t_min=0. * b2.ms,
                                     avg_window_width=20. * b2.ms,
                                     sup_title="Right")

    plt.show()
Ejemplo n.º 2
0
def question_external_poisson_population():
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, \
    spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, w_profile = \
        wm_model.simulate_wm(
            sim_time=800. * b2.ms, poisson_firing_rate=2.2 * b2.Hz, sigma_weight_profile=20., Jpos_excit2excit=1.6)

    plot_tools.plot_network_activity(rate_monitor_excit,
                                     spike_monitor_excit,
                                     voltage_monitor_excit,
                                     t_min=0. * b2.ms)
    plt.show()
Ejemplo n.º 3
0
def question_weight_profile():
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, \
    spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, weight_profile_45 = \
        wm_model.simulate_wm(
            sim_time=800. * b2.ms, poisson_firing_rate=2.3 * b2.Hz, sigma_weight_profile=5., Jpos_excit2excit=6)
    plot_tools.plot_network_activity(rate_monitor_excit,
                                     spike_monitor_excit,
                                     voltage_monitor_excit,
                                     t_min=0. * b2.ms)
    plt.show()
    plt.figure()
    plt.plot(weight_profile_45)
    plt.show()
Ejemplo n.º 4
0
def getting_started():
    b2.defaultclock.dt = 0.1 * b2.ms
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit,\
        rate_monitor_inhib, spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib,\
        weight_profile\
        = simulate_wm(N_excitatory=256, N_inhibitory=64, weight_scaling_factor=8., sim_time=500. * b2.ms,
                      stimulus_center_deg=120, t_stimulus_start=100 * b2.ms, t_stimulus_duration=200 * b2.ms,
                      stimulus_strength=.07 * b2.namp)
    plot_tools.plot_network_activity(rate_monitor_excit,
                                     spike_monitor_excit,
                                     voltage_monitor_excit,
                                     t_min=0. * b2.ms)

    plt.show()
def getting_started():
    """
        A simple example to get started
    """
    rate_monitor, spike_monitor, voltage_monitor, monitored_spike_idx = simulate_brunel_network(
        N_Excit=2000, sim_time=800. * b2.ms)
    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_min=0. * b2.ms,
                                     N_highlighted_spiketrains=3,
                                     avg_window_width=1. * b2.ms)
    plt.show()
Ejemplo n.º 6
0
def question_role_of_inhib_population():
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, w_profile = \
        wm_model.simulate_wm(N_excitatory=1024, N_inhibitory=1, sigma_weight_profile=20,
                             stimulus_center_deg=120, stimulus_width_deg=30, stimulus_strength=0.5 * b2.namp,
                             t_stimulus_start=100 * b2.ms,
                             t_stimulus_duration=100 * b2.ms, sim_time=500. * b2.ms, Jpos_excit2excit=1.6,
                             poisson_firing_rate=1.5 * b2.Hz)
    fig, ax_raster, ax_rate, ax_voltage = plot_tools.plot_network_activity(
        rate_monitor_excit,
        spike_monitor_excit,
        voltage_monitor_excit,
        t_min=0. * b2.ms)
    plt.show()
Ejemplo n.º 7
0
def distractor_at_same_time():
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, w_profile = \
        wm_model.simulate_wm(N_excitatory=1024, N_inhibitory=256, sigma_weight_profile=60,
                             stimulus_center_deg=40, stimulus_width_deg=20, stimulus_strength=0.5 * b2.namp,
                             t_stimulus_start=100 * b2.ms,G_excit2inhib=0.355*b2.nS,
                             t_stimulus_duration=100 * b2.ms, sim_time=500. * b2.ms, Jpos_excit2excit=1.6,
                             poisson_firing_rate=1.5 * b2.Hz, distractor_center_deg=300, distractor_width_deg=20,
                             distractor_strength=0.5 * b2.namp,
                             t_distractor_start=110 * b2.ms, t_distractor_duration=100 * b2.ms)
    fig, ax_raster, ax_rate, ax_voltage = plot_tools.plot_network_activity(
        rate_monitor_excit,
        spike_monitor_excit,
        voltage_monitor_excit,
        t_min=0. * b2.ms)
    plt.show()
Ejemplo n.º 8
0
def question_integration_of_input():
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, w_profile = \
        wm_model.simulate_wm(
            stimulus_center_deg=120, stimulus_width_deg=60, stimulus_strength=0.5 * b2.namp,
            t_stimulus_start=100 * b2.ms,
            t_stimulus_duration=200 * b2.ms, sim_time=500. * b2.ms)
    fig, ax_raster, ax_rate, ax_voltage = plot_tools.plot_network_activity(
        rate_monitor_excit,
        spike_monitor_excit,
        voltage_monitor_excit,
        t_min=0. * b2.ms)

    plt.show()
    rate_monitor_excit, spike_monitor_excit, voltage_monitor_excit, idx_monitored_neurons_excit, rate_monitor_inhib, spike_monitor_inhib, voltage_monitor_inhib, idx_monitored_neurons_inhib, w_profile = \
        wm_model.simulate_wm(
            stimulus_center_deg=120, stimulus_width_deg=30, stimulus_strength=0.5 * b2.namp,
            t_stimulus_start=100 * b2.ms,
            t_stimulus_duration=200 * b2.ms, sim_time=500. * b2.ms)
    fig, ax_raster, ax_rate, ax_voltage = plot_tools.plot_network_activity(
        rate_monitor_excit,
        spike_monitor_excit,
        voltage_monitor_excit,
        t_min=0. * b2.ms)
    plt.show()
def _demo_emergence_of_oscillation():
    poisson_rate = 18 * b2.Hz
    g = 2.5

    rate_monitor, spike_monitor, voltage_monitor, monitored_spike_idx = \
        simulate_brunel_network(N_Excit=6000, random_vm_init=True, poisson_input_rate=poisson_rate,
                                g=g, sim_time=300. * b2.ms, monitored_subset_size=50)
    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_min=0 * b2.ms)
    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_max=50 * b2.ms)
    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_min=250 * b2.ms)
    plt.show()
def _some_example_calls_and_tests():
    from neurodynex3.tools import spike_tools
    poisson_rate = 35 * b2.Hz
    g = 4
    CE = 5000

    delta_t = 0.1 * b2.ms
    delta_f = 5. * b2.Hz
    T_init = 100 * b2.ms
    k = 9

    f_max = 1. / (2. * delta_t)
    N_samples = 2. * f_max / delta_f
    T_signal = N_samples * delta_t
    T_sim = k * T_signal + T_init

    print("Start simulation. T_sim={}, T_signal={}. N_samples={}".format(
        T_sim, T_signal, N_samples))
    b2.defaultclock.dt = delta_t
    stime = T_sim + (
        10 + k
    ) * b2.defaultclock.dt  # add a few extra samples (solves rounding issues)
    rate_monitor, spike_monitor, voltage_monitor, monitored_spike_idx = \
        simulate_brunel_network(
            N_Excit=CE, poisson_input_rate=poisson_rate, g=g, sim_time=stime)

    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_min=0 * b2.ms)
    plot_tools.plot_network_activity(rate_monitor,
                                     spike_monitor,
                                     voltage_monitor,
                                     spike_train_idx_list=monitored_spike_idx,
                                     t_min=T_sim - 80 * b2.ms)
    spike_stats = spike_tools.get_spike_train_stats(spike_monitor,
                                                    window_t_min=150. * b2.ms)
    plot_tools.plot_ISI_distribution(spike_stats,
                                     hist_nr_bins=77,
                                     xlim_max_ISI=100 * b2.ms)

    #     # Power Spectrum
    pop_freqs, pop_ps, average_population_rate = \
        spike_tools.get_population_activity_power_spectrum(
            rate_monitor, delta_f, k, T_init, subtract_mean_activity=True)

    plot_tools.plot_population_activity_power_spectrum(
        pop_freqs, pop_ps, 1000 * b2.Hz, average_population_rate)
    plt.show()

    freq, mean_ps, all_ps, mean_firing_rate, all_mean_firing_freqs = \
        spike_tools.get_averaged_single_neuron_power_spectrum(
            spike_monitor, sampling_frequency=1./delta_t, window_t_min=100.*b2.ms,
            window_t_max=T_sim,  subtract_mean=False, nr_neurons_average=200)
    print("plot_spike_train_power_spectrum")
    plot_tools.plot_spike_train_power_spectrum(
        freq,
        mean_ps,
        all_ps,
        1000 * b2.Hz,
        mean_firing_freqs_per_neuron=all_mean_firing_freqs,
        nr_highlighted_neurons=2)
    plt.show()
    print("done")