예제 #1
0
def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm_params = {
        "record_to": ["memory"],
        "withgid": True,
        "withtime": True,
        "interval": 0.1
    }
    vm = nest.Create("voltmeter", params=vm_params)
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    from nest import visualization
    allnodes = pg + nest.GetLeaves(pop1)[0] + nest.GetLeaves(pop2)[0] + vm
    visualization.plot_network(allnodes, "test_csa.png")

    if havePIL:
        im = Image.open("test_csa.png")
        im.show()

    from nest import voltage_trace
    voltage_trace.from_device(vm)
예제 #2
0
def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm_params = {"record_to": ["memory"], "withgid": True,
                 "withtime": True, "interval": 0.1}
    vm = nest.Create("voltmeter", params=vm_params)
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    from nest import visualization
    allnodes = pg + nest.GetLeaves(pop1)[0] + nest.GetLeaves(pop2)[0] + vm
    visualization.plot_network(allnodes, "test_csa.png")

    if havePIL:
        im = Image.open("test_csa.png")
        im.show()

    from nest import voltage_trace
    voltage_trace.from_device(vm)
def checkConninMV():
    nest.ResetKernel()
    nest.SetKernelStatus({
        "resolution": timestep,
        "overwrite_files": True,
        "rng_seeds": seed,
        "print_time": True,
        "local_num_threads": num_threads
    })

    nest.CopyModel("iaf_cond_alpha", "d21", d2_params)
    #nest.CopyModel("izhikevich", "d1", d1_params_iz)
    nest.CopyModel("iaf_cond_alpha", "d22", d2_params)
    #nest.CopyModel("izhikevich", "d2", d2_params_iz)

    d21 = nest.Create("d21", 1)
    d22 = nest.Create("d22", 1)
    nest.SetStatus(d22, {'I_e': 27.})  # Has to be tuned so that d2 is at -80
    # nest.SetStatus(d1,{'I_e':69.}) # Has to be tuned so that d1 is at -80
    dc = nest.Create("dc_generator", 1)
    sd = nest.Create("spike_detector", 2)
    mult = nest.Create("multimeter",
                       1,
                       params={
                           "withgid": True,
                           "withtime": True,
                           "record_from": ["V_m"]
                       })

    nest.Connect(d21, [sd[0]])
    nest.Connect(d22, [sd[1]])
    nest.Connect(dc, d21)
    # nest.Connect(dc,d2)
    # nest.Connect(mult,d1)
    nest.Connect(mult, d22)
    nest.Connect(d21, d22, syn_spec={'weight': jd2d2})
    nest.SetStatus(dc, params={"amplitude": 250.})

    nest.Simulate(1000.)
    evs_d1 = nest.GetStatus([sd[0]])[0]["events"]["senders"]
    ts_d1 = nest.GetStatus([sd[0]])[0]["events"]["times"]

    V_m = nest.GetStatus(mult)[0]["events"]["V_m"]
    ts = nest.GetStatus(mult)[0]["events"]["times"]
    inds = np.where(ts > 400.)
    Vmmin = np.min(V_m[inds])
    print "conn_strength", Vmmin + 80.
    # pl.figure(1)
    # rplt.from_device(sd)
    pl.figure(2)
    voltage_trace.from_device(mult)
    pl.plot(ts_d1, np.ones(len(ts_d1)) * -80., 'r|', markersize=10)
    pl.show()
예제 #4
0
def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    # This does not work yet, as the implementation does not yet
    # support nested subnets.
    #
    #pop1 = nest.LayoutNetwork("iaf_neuron", [4,4])
    #pop2 = nest.LayoutNetwork("iaf_neuron", [4,4])

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm = nest.Create("voltmeter",
                     params={
                         "record_to": ["memory"],
                         "withgid": True,
                         "withtime": True,
                         "interval": 0.1
                     })
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    # Not yet supported in NEST
    #from nest import visualization
    #allnodes = [pg, nest.GetLeaves(pop1)[0], nest.GetLeaves(pop2)[0], vm]
    #visualization.plot_network(allnodes, "test_csa.png", "png", plot_modelnames=True

    #if havePIL:
    #    im = Image.open("test_csa.png")
    #    im.show()

    from nest import voltage_trace
    voltage_trace.from_device(vm)
예제 #5
0
def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    # This does not work yet, as the implementation does not yet
    # support nested subnets.
    #
    # pop1 = nest.LayoutNetwork("iaf_neuron", [4,4])
    # pop2 = nest.LayoutNetwork("iaf_neuron", [4,4])

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm = nest.Create("voltmeter", params={"record_to": ["memory"], "withgid": True, "withtime": True, "interval": 0.1})
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    # Not yet supported in NEST
    # from nest import visualization
    # allnodes = [pg, nest.GetLeaves(pop1)[0], nest.GetLeaves(pop2)[0], vm]
    # visualization.plot_network(allnodes, "test_csa.png", "png", plot_modelnames=True

    # if havePIL:
    #    im = Image.open("test_csa.png")
    #    im.show()

    from nest import voltage_trace

    voltage_trace.from_device(vm)
예제 #6
0
the neurons of the pre-synaptic population.
"""

pg = nest.Create("poisson_generator", params={"rate": 100000.0})
nest.Connect(pg, pre, "all_to_all")

"""
To measure and record the membrane potentials of the neurons, we
create a `voltmeter` and connect it to all post-synaptic nodes.
"""

vm = nest.Create("voltmeter")
nest.Connect(vm, post, "all_to_all")

"""
We save the whole connection graph of the network as a PNG image
using the `plot_network` function of the `visualization` submodule of
PyNEST.
"""

allnodes = pg + pre + post + vm
visualization.plot_network(allnodes, "csa_example_graph.png")

"""
Finally, we simulate the network for 50 ms. The voltage traces of
the post-synaptic nodes are plotted.
"""

nest.Simulate(50.0)
voltage_trace.from_device(vm)
예제 #7
0
"""
To stimulate the network, we create a `poisson_generator` and set it
up to fire with a rate of 100000 spikes per second. It is connected to
the neurons of the pre-synaptic population.
"""

pg = nest.Create("poisson_generator", params={"rate": 100000.0})
nest.Connect(pg, pre, "all_to_all")
"""
To measure and record the membrane potentials of the neurons, we
create a `voltmeter` and connect it to all post-synaptic nodes.
"""

vm = nest.Create("voltmeter")
nest.Connect(vm, post, "all_to_all")
"""
We save the whole connection graph of the network as a PNG image
using the `plot_network` function of the `visualization` submodule of
PyNEST.
"""

allnodes = pg + pre + post + vm
visualization.plot_network(allnodes, "csa_example_graph.png")
"""
Finally, we simulate the network for 50 ms. The voltage traces of
the post-synaptic nodes are plotted.
"""

nest.Simulate(50.0)
voltage_trace.from_device(vm)
예제 #8
0
nest.Connect(voltmeter, sero_neuron)

dt = 10
T = 150
weight = None
time = []
sero_dyn = []
results_folder = ""

if nest.GetStatus(neuron2)[0]['local']:
    sum_time = 0
    for t in range(0, T + dt, dt):
        nest.Simulate(t)
        sum_time += t
        conns = nest.GetConnections(neuron1, synapse_model="sero")
        n = nest.GetStatus(conns)[0]['n']
        time.append(sum_time)
        sero_dyn.append(n)

    nest.raster_plot.from_device(sd, hist=True, hist_binwidth=100.)
    pl.savefig(results_folder + "spikes_" + str(t) + ".png")
    pl.close()
    plot.from_device(voltmeter, timeunit="s")
    pl.savefig(results_folder + "voltage_" + str(t) + ".png")
    pl.close()

    plt.plot(time, sero_dyn)
    plt.xlabel('Time (ms)')
    plt.title('Serotonin concentration dynamics')
    plt.savefig(results_folder + "sero_dynamic_" + str(t) + ".png")
예제 #9
0
    raise

# Tab delimiter in a string
dlm = '\t'
# Next line symbol
nl = '\n'

# Set-up file header: time[ms], connection weight, serotonin concentration, eligibility trace
fname.write('time'+ dlm + 'weight' + dlm + 'n' + dlm + 'c' + nl)

def get_neuron1_prop(property_name):
    return str(nest.GetStatus(nest.FindConnections(neuron1, synapse_model="sero"))[0][property_name])

# Run simualtion
weight = None
for t in np.arange(0, T + dt, dt):
    if nest.GetStatus(neuron2)[0]['local']:
        data = str(t) + dlm + get_neuron1_prop('weight') + dlm + get_neuron1_prop('n') + dlm + get_neuron1_prop('c') + nl
        fname.write(data)
        nest.Simulate(dt)
        print '///////////////////////////////// ' + str(t/T * 100) + ' % completed'

if nest.GetStatus(neuron2)[0]['local']:
    print("weight = " + str(weight) + " pA")
    fname.close()

print("Eligibility trace = " + get_neuron1_prop('c'))
print("Serotonin conc-on = " + get_neuron1_prop('n'))

plot.from_device(voltmeter, timeunit="s")
plot.show()
예제 #10
0
times = events["times"]
Vm = events["V_m"]
Vm_exp = Vm[np.where(senders == n_exp)]
Vm_cond = Vm[np.where(senders == n_cond)]

Vm_exp_b4 = Vm[np.logical_and(times < 199, senders == n_exp)]
Vm_cond_b4 = Vm[np.logical_and(times < 199, senders == n_cond)]
print "Amplitudes of psc_exp and cond_exp before spike"
print np.mean(Vm_exp_b4), np.mean(Vm_cond_b4)
print "Amplitudes of psc_exp and cond_exp after spike"
print max(Vm_exp), max(Vm_cond)
print "PSP sizes for psc_exp and cond_exp after spike"
print np.mean(Vm_exp_b4) - max(Vm_exp), np.mean(Vm_cond_b4) - max(Vm_cond)
print np.argmax(Vm_exp), np.argmax(Vm_cond)

vt.from_device(mm)
vt.show()

# V_m baseline for I_e = 300 / 200:         -58.
# V_m baseline for I_e = -300 / -200:       -82.

# SOLUTION
# With +ve background
#Amplitudes of psc_exp and cond_exp before spike
#-62.4800000189 -62.5000288791
#Amplitudes of psc_exp and cond_exp after spike
#-62.4746501618 -62.4529781256
#PSP sizes for psc_exp and cond_exp after spike
#-0.00534985715843 -0.0470507534623

# Without +ve background
def calcFI():

    #amplitudesList = np.arange(3.5,4.5,0.1)
    amplitudesList = np.arange(100, 500, 50.)

    listD1 = []
    listD2 = []

    for amp in amplitudesList:

        nest.ResetKernel()
        nest.SetKernelStatus({
            "resolution": timestep,
            "overwrite_files": True,
            "rng_seeds": seed,
            "print_time": True,
            "local_num_threads": num_threads
        })

        nest.CopyModel("iaf_cond_alpha", "d1", d1_params)
        #nest.CopyModel("izhikevich", "d1", d1_params_iz)
        nest.CopyModel("iaf_cond_alpha", "d2", d2_params)
        #nest.CopyModel("izhikevich", "d2", d2_params_iz)

        d1 = nest.Create("d1", 1)
        d2 = nest.Create("d2", 1)
        dc = nest.Create("dc_generator", 1)
        sd = nest.Create("spike_detector", 2)
        mult = nest.Create("multimeter",
                           1,
                           params={
                               "withgid": True,
                               "withtime": True,
                               "record_from": ["V_m"]
                           })

        nest.Connect(d1, [sd[0]])
        nest.Connect(d2, [sd[1]])
        nest.Connect(dc, d1)
        nest.Connect(dc, d2)
        nest.Connect(mult, d1)
        nest.Connect(mult, d2)

        nest.SetStatus(dc, params={"amplitude": amp})
        nest.Simulate(10000.)
        evs_d1 = nest.GetStatus([sd[0]])[0]["events"]["senders"]
        ts_d1 = nest.GetStatus([sd[0]])[0]["events"]["times"]

        evs_d2 = nest.GetStatus([sd[1]])[0]["events"]["senders"]
        ts_d2 = nest.GetStatus([sd[1]])[0]["events"]["times"]

        listD1.append(len(ts_d1) / 10.0)
        listD2.append(len(ts_d2) / 10.0)

        # voltage_trace.from_device(mult)
        # pl.show()

    FI = dict()
    FI["d1"] = listD1
    FI["d2"] = listD2
    pickle.dump(FI, open("../../data/FI.pickle", "w"))
    pl.figure()
    pl.text(70, 62, "A", fontweight='bold', fontsize=15)
    pl.plot(amplitudesList, listD1, 'bo-', label='D1', linewidth=1.5)
    pl.plot(amplitudesList, listD2, 'go-', label='D2', linewidth=1.5)
    pl.legend(loc='best')
    pl.xlabel("Amplitude(pA)", fontweight='bold', fontsize=14)
    pl.ylabel("Firing rate (sps)", fontweight='bold', fontsize=14)
    for x in pl.gca().get_xticklabels():
        x.set_fontweight('bold')
        x.set_fontsize(10)
    for x in pl.gca().get_yticklabels():
        x.set_fontweight('bold')
        x.set_fontsize(10)

    pl.savefig("../../data/FI.pdf")

    print "d1", FI["d1"], "d2", FI["d2"], amplitudesList
    pl.figure()
    voltage_trace.from_device(mult)
    pl.show()