Example #1
0
 def setUp(self):
     sim.setup()
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn_rnd = sim.StaticSynapse(weight=0.123, delay=0.5)
     self.syn_a2a = sim.StaticSynapse(weight=0.456, delay=0.4)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.all2all = sim.AllToAllConnector()
Example #2
0
def test():
    if not HAVE_H5PY and HAVE_NEST:
        raise SkipTest

    sim.setup()

    p1 = sim.Population(10,
                        sim.IF_cond_exp(v_rest=-65,
                                        tau_m=lambda i: 10 + 0.1 * i,
                                        cm=RD('normal', (0.5, 0.05))),
                        label="population_one")
    p2 = sim.Population(20,
                        sim.IF_curr_alpha(v_rest=-64,
                                          tau_m=lambda i: 11 + 0.1 * i),
                        label="population_two")

    prj = sim.Projection(p1,
                         p2,
                         sim.FixedProbabilityConnector(p_connect=0.5),
                         synapse_type=sim.StaticSynapse(weight=RD(
                             'uniform', [0.0, 0.1]),
                                                        delay=0.5),
                         receptor_type='excitatory')

    net = Network(p1, p2, prj)

    export_to_sonata(net, "tmp_serialization_test", overwrite=True)

    net2 = import_from_sonata("tmp_serialization_test/circuit_config.json",
                              sim)

    for orig_population in net.populations:
        imp_population = net2.get_component(orig_population.label)
        assert orig_population.size == imp_population.size
        for name in orig_population.celltype.default_parameters:
            assert_array_almost_equal(orig_population.get(name),
                                      imp_population.get(name), 12)

    w1 = prj.get('weight', format='array')
    prj2 = net2.get_component(asciify(prj.label).decode('utf-8') + "-0")
    w2 = prj2.get('weight', format='array')
    assert_array_almost_equal(w1, w2, 12)
Example #3
0
# Build the network
sim.setup()

# spike source
#generate_spike_times = [[0], [500], [1000], [1500], [2000], [2500], [3000],
#                       [3500], [4000], [4500]] #, [5000]]
#spike_source = sim.Population(n_neurons,
#                              sim.SpikeSourceArray(
#                                  spike_times = generate_spike_times))

spike_source = sim.Population(
    n_neurons, sim.SpikeSourceArray(spike_times=[0, 1000, 3000]))

# populations and projections
layer_1 = sim.Population(n_neurons, sim.IF_curr_alpha(), label="layer_1")
'''
layer_2 = sim.Population(n_neurons, sim.IF_curr_alpha(),
                         label = "layer_2")
'''
proj_src_2_l1 = sim.Projection(spike_source, layer_1, sim.OneToOneConnector())
'''
proj_l1_2_l2 = sim.Projection(layer_1, layer_2, 
                              sim.OneToOneConnector())
'''
sim.run(sim_time)

layer_1.record(('spikes', 'v'))
#layer_2.record(['spikes', 'v'])
#layer_1.record(['v', 'spikes'])
#layer_2.record(['v', 'spikes'])
Example #4
0
# http://ec.europa.eu/programmes/horizon2020/en/h2020-section/fet-flagships
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# ---LICENSE-END
"""
This is just an example of a neural network
"""

__author__ = 'Georg Hinkel'

import pyNN.nest as sim

population = sim.Population(3, sim.IF_curr_alpha())
view = population[1:2]
assembly = population + view

# A list of populations is also possible
list = [population, view, [assembly]]
Example #5
0
    if u >= v_thresh:
        spikes.append(1)
    else:
        spikes.append(0)

# Plot
plt.plot(xs, uvec[:wf])
plt.xlabel("ms")
plt.ylabel("mV")
plt.title("Single LIF Neuron (current)")

# %% PYNN Neuron

sim.setup(timestep=0.1, min_delay=0.1, max_delay=10.0)
IF_sim = sim.Population(1,
                        sim.IF_curr_alpha(i_offset=1.0),
                        label="IF_curr_exp")
IF_sim.record('v')

## Parameters
# {'v_rest': -65.0, 'cm': 1.0, 'tau_m': 20.0,
# 'tau_refrac': 0.1, 'tau_syn_E': 0.5, 'tau_syn_I': 0.5,
# 'i_offset': 1.0, 'v_reset': -65.0, 'v_thresh': -50.0}

# Running simulation in MS
sim.run(100.0)

# Data
v_data = IF_sim.get_data()
data = IF_sim.get_data().segments[0]
v = data.filter(name="v")[0]
Example #6
0
weightScale = 1.0  # general weight for all connections between neurons
constantInput = 0.5  # input given to the tonic interneuron layer and to the top-down activated segmentation neurons
inputPoisson = 0  # 1 for a poisson spike source input, 0 for a DC current input
cellParams = {  # parameters for any neuron in the network
    'i_offset': 0.0,  # (nA)
    'tau_m': 10.0,  # (ms)
    'tau_syn_E': 2.0,  # (ms)
    'tau_syn_I': 2.0,  # (ms)
    'tau_refrac': 2.0,  # (ms)
    'v_rest': -70.0,  # (mV)
    'v_reset': -70.0,  # (mV)
    'v_thresh':
    -56.0,  # (mV) -55.0 is NEST standard, -56.0 good for the current setup
    'cm': 0.25
}  # (nF)
cellType = sim.IF_curr_alpha(**cellParams)
connections = {
    # Input and LGN
    'brightInputToLGN': 0.1,  # only useful if inputDC == 1
    'darkInputToLGN': 0.1,  # only useful if inputDC == 1
    'LGN_ToV1Excite': 0.4,  #   400.0
    'LGN_ToV4Excite': 0.28,  #   280.0,

    # V1 layers
    'V1_6To4Excite': 0.001,  #     1.0,
    'V1_6To4Inhib': -0.001,  #    -1.0,
    'V1_4To23Excite': 0.5,  #   500.0,
    'V1_23To6Excite': 0.1,  #   100.0,
    'V1_ComplexExcite': 0.5,  #   500.0,
    'V1_ComplexInhib': -0.5,  #  -500.0,
    'V1_FeedbackExcite': 0.5,  #   500.0,