Пример #1
0
 def test_cylindrical_space(self):
     s = space.Space(periodic_boundaries=((-1.0, 4.0), (-1.0, 4.0), (-1.0,
                                                                     4.0)))
     self.assertEqual(s.distances(self.A, self.B), sqrt(3))
     self.assertEqual(s.distances(self.A, self.D), sqrt(4 + 4 + 1))
     self.assertEqual(s.distances(self.C, self.D), sqrt(4 + 1 + 0))
     self.assertArraysEqual(
         s.distances(self.A, self.ABCD),
         numpy.array([0.0, sqrt(3), sqrt(3),
                      sqrt(4 + 4 + 1)]))
     self.assertArraysEqual(s.distances(self.A, self.ABCD),
                            s.distances(self.ABCD, self.A).T)
     self.assertArraysEqual(
         s.distances(self.C, self.ABCD),
         numpy.array([sqrt(3),
                      sqrt(4 + 4 + 4), 0.0,
                      sqrt(4 + 1 + 0)]))
def create_local_inhibition(layers_dict):
    """
    Creates local inhibitory connections from a neuron to its neighbors in an
    area of a fixed distance. The latency of its neighboring neurons decreases
    linearly with the distance from the spike from 15% to 5%, as described in
    Masquelier's paper. Here we assumed that a weight of -10 inhibits the
    neuron completely and took that as a starting point.
    """
    for size, layers in layers_dict.items():
        print('Create local inhibition for size', size)
        for layer in layers:
            sim.Projection(layer.population,
                           layer.population,
                           sim.DistanceDependentProbabilityConnector(
                               'd < 5', allow_self_connections=False),
                           sim.StaticSynapse(weight='.25 * d - 1.75'),
                           space=space.Space(axes='xy'))
Пример #3
0
    def _connect(self):
        method = self.sim.FixedProbabilityConnector(
            self.parameters.connection_probability,
            allow_self_connections=False,
            safe=True,
            rng=mozaik.pynn_rng)

        self.proj = self.sim.Projection(
            self.source.pop,
            self.target.pop,
            method,
            synapse_type=self.init_synaptic_mechanisms(
                weight=self.parameters.weights * self.weight_scaler,
                delay=self.parameters.delay),
            label=self.name,
            space=space.Space(axes='xy'),
            receptor_type=self.parameters.target_synapses)
Пример #4
0
    def _connect(self):
        method = self.sim.FixedNumberPreConnector(self.parameters.k,
                                                  allow_self_connections=False,
                                                  safe=True,
                                                  rng=mozaik.pynn_rng)

        print("connectors fast FixedKConnector ", method)
        print("connectors fast FixedKConnector ", self.source.pop)
        print("connectors fast FixedKConnector ", self.target.pop)

        self.proj = self.sim.Projection(
            self.source.pop,
            self.target.pop,
            method,
            synapse_type=self.init_synaptic_mechanisms(
                weight=self.parameters.weights * self.weight_scaler,
                delay=self.parameters.delay),
            label=self.name,
            space=space.Space(axes="xy"),
            receptor_type=self.parameters.target_synapses)
Пример #5
0
    def test_generator_for_infinite_space_with_3D_distances(self):
        s = space.Space()

        def f(i):
            return self.ABCD[i]

        def g(j):
            return self.ABCD[j]

        self.assertArraysEqual(
            s.distance_generator(f, g)(0, np.arange(4)),
            np.array([0.0, sqrt(3), sqrt(3), sqrt(29)]))
        assert_array_equal(
            np.fromfunction(s.distance_generator(f, g),
                            shape=(4, 4),
                            dtype=int),
            np.array([(0.0, sqrt(3), sqrt(3), sqrt(29)),
                      (sqrt(3), 0.0, sqrt(12), sqrt(14)),
                      (sqrt(3), sqrt(12), 0.0, sqrt(50.0)),
                      (sqrt(29), sqrt(14), sqrt(50.0), 0.0)]))
Пример #6
0
    def _connect(self):
        # JAHACK, 0.1 as minimal delay should be replaced with the simulations time_step
        if isinstance(self.target, SheetWithMagnificationFactor):
            self.arborization_expression = lambda d: self.arborization_function(
                self.target.dvf_2_dcs(d))
            self.delay_expression = lambda d: self.delay_function(
                self.target.dvf_2_dcs(d))
        else:
            self.arborization_expression = lambda d: self.arborization_function(
                d)
            self.delay_expression = lambda d: self.delay_function(d)

        method = self.sim.DistanceDependentProbabilityConnector(
            self.arborization_expression,
            allow_self_connections=False,
            weights=self.parameters.weights * self.weight_scaler,
            delays=self.delay_expression,
            space=space.Space(axes="xy"),
            safe=True,
            verbose=False,
            n_connections=None,
            rng=mozaik.pynn_rng)
        print("connectors fast DistanceDependentProbabilisticArborization ",
              method)
        print("connectors fast DistanceDependentProbabilisticArborization ",
              self.source.pop)
        print("connectors fast DistanceDependentProbabilisticArborization ",
              self.target.pop)

        self.proj = self.sim.Projection(
            self.source.pop,
            self.target.pop,
            method,
            synapse_type=self.init_synaptic_mechanisms(),
            label=self.name,
            receptor_type=self.parameters.target_synapses)
Пример #7
0
v_random = np.random.rand(N_lgn) * (v_thresh - v_rest) + v_rest
lgn_neurons.initialize(v=v_random)

# Synapses, Connections and Projections
# Synapses
exc_synapse = simulator.StaticSynapse(weight=20.0, delay=0.1)  # The synapses
inh_synapse = simulator.StaticSynapse(weight=10.0, delay=0.1)  # The synapses

# Connectors
# Position dependent probability connector
DDPC = simulator.DistanceDependentProbabilityConnector
exc_connector = DDPC('d < 3')
inh_connector = DDPC('d < 7 and 3 < d')
# Projections

space = space.Space(axes=None,
                    periodic_boundaries=((0, N_retina), (0, N_retina), None))

exc_projection = simulator.Projection(retinal_neurons,
                                      lgn_neurons,
                                      connector=exc_connector,
                                      synapse_type=exc_synapse,
                                      receptor_type='excitatory',
                                      space=space,
                                      label='excitatory connections')

inh_projection = simulator.Projection(retinal_neurons,
                                      lgn_neurons,
                                      connector=inh_connector,
                                      synapse_type=inh_synapse,
                                      receptor_type='inhibitory',
                                      space=space,
    # Use CVode to calculate i_membrane_ for fast LFP calculation
    cvode = h.CVode()
    cvode.active(0)

    # Get the second spatial derivative (the segment current) for the collateral
    cvode.use_fast_imem(1)

    # Set initial values for cell membrane voltages
    v_init = -68

    # Create random distribution for cell membrane noise current
    r_init = RandomDistribution('uniform', (0, Pop_size))

    # Create Spaces for STN Population
    STN_Electrode_space = space.Space(axes='xy')
    STN_space = space.RandomStructure(
        boundary=space.Sphere(2000))  # Sphere with radius 2000um

    # Generate poisson distributed spike time striatal input
    striatal_spike_times = np.load(
        'Striatal_Spike_Times.npy')  # Load spike times from file

    # Generate the cortico-basal ganglia neuron populations
    Cortical_Pop = Population(
        Pop_size,
        Cortical_Neuron_Type(soma_bias_current_amp=0.245),
        structure=STN_space,
        label='Cortical Neurons')  # Better than above (ibias=0.2575)
    Interneuron_Pop = Population(Pop_size,
                                 Interneuron_Type(bias_current_amp=0.070),
Пример #9
0
 def test_really_simple0(self):
     A = numpy.zeros((3, ))
     B = numpy.zeros((3, 5))
     D = connectors.DistanceMatrix(B, space.Space())
     D.set_source(A)
     assert_arrays_equal(D.as_array(), numpy.zeros((5, ), float))