Example #1
0
def run_sim(ncell):

    print "Cells: ", ncell

    setup0 = time.time()

    sim.setup(timestep=0.1)

    hh_cell_type = sim.HH_cond_exp()

    hh = sim.Population(ncell, hh_cell_type)

    pulse = sim.DCSource(amplitude=0.5, start=20.0, stop=80.0)
    pulse.inject_into(hh)

    hh.record('v')

    setup1 = time.time()

    t0 = time.time()

    sim.run(100.0)

    v = hh.get_data()

    sim.end()

    t1 = time.time()

    setup_total = setup1 - setup0
    run_total = t1 - t0
    print "Setup: ", setup_total
    print "Run: ", run_total
    print "Total sim time: ", setup_total + run_total
    return run_total
Example #2
0
import pyNN.neuron as sim  # can of course replace `nest` with `neuron`, `brian`, etc.
import matplotlib.pyplot as plt
from quantities import nA

sim.setup()

cell = sim.Population(1, sim.HH_cond_exp())
step_current = sim.DCSource(start=20.0, stop=80.0)
step_current.inject_into(cell)

cell.record('v')

for amp in (-0.2, -0.1, 0.0, 0.1, 0.2):
    step_current.amplitude = amp
    sim.run(100.0)
    sim.reset(annotations={"amplitude": amp * nA})

data = cell.get_data()

sim.end()

for segment in data.segments:
    vm = segment.analogsignals[0]
    plt.plot(vm.times, vm, label=str(segment.annotations["amplitude"]))
plt.legend(loc="upper left")
plt.xlabel("Time (%s)" % vm.times.units._dimensionality)
plt.ylabel("Membrane potential (%s)" % vm.units._dimensionality)

plt.show()
Example #3
0
"""

"""

from plot_helper import plot_current_source
import pyNN.neuron as sim

sim.setup()

population = sim.Population(10, sim.IF_cond_exp(tau_m=10.0))
population[3:4].record_v()

pulse = sim.DCSource(amplitude=0.5, start=20.0, stop=80.0)
pulse.inject_into(population[3:7])
pulse._record()

sim.run(100.0)

t, i_inj = pulse._get_data()
v = population.get_data().segments[0].analogsignalarrays[0]

plot_current_source(t,
                    i_inj,
                    v,
                    v_range=(-65.5, -59.5),
                    v_ticks=(-65, -64, -63, -62, -61, -60),
                    i_range=(-0.1, 0.55),
                    i_ticks=(0.0, 0.2, 0.4))