Example #1
0
    def __init__(self, sim, num_threads, parameters):
        Model.__init__(self, sim, num_threads, parameters)
        # Load components
        CortexExcL4 = load_component(self.parameters.sheets.l4_cortex_exc.component)
        CortexInhL4 = load_component(self.parameters.sheets.l4_cortex_inh.component)
	


        RetinaLGN = load_component(self.parameters.sheets.retina_lgn.component)
      
        # Build and instrument the network
        self.visual_field = VisualRegion(location_x=self.parameters.visual_field.centre[0],location_y=self.parameters.visual_field.centre[1],size_x=self.parameters.visual_field.size[0],size_y=self.parameters.visual_field.size[1])
        self.input_layer = RetinaLGN(self, self.parameters.sheets.retina_lgn.params)
        cortex_exc_l4 = CortexExcL4(self, self.parameters.sheets.l4_cortex_exc.params)
        cortex_inh_l4 = CortexInhL4(self, self.parameters.sheets.l4_cortex_inh.params)

        # initialize afferent layer 4 projections
        GaborConnector(self,self.input_layer.sheets['X_ON'],self.input_layer.sheets['X_OFF'],cortex_exc_l4,self.parameters.sheets.l4_cortex_exc.AfferentConnection,'V1AffConnection')
        GaborConnector(self,self.input_layer.sheets['X_ON'],self.input_layer.sheets['X_OFF'],cortex_inh_l4,self.parameters.sheets.l4_cortex_inh.AfferentConnection,'V1AffInhConnection')

        # initialize lateral layer 4 projections
	if not self.parameters.only_afferent:
            ModularSamplingProbabilisticConnectorAnnotationSamplesCount(self,'V1L4ExcL4ExcConnection',cortex_exc_l4,cortex_exc_l4,self.parameters.sheets.l4_cortex_exc.L4ExcL4ExcConnection).connect()
            ModularSamplingProbabilisticConnectorAnnotationSamplesCount(self,'V1L4ExcL4InhConnection',cortex_exc_l4,cortex_inh_l4,self.parameters.sheets.l4_cortex_exc.L4ExcL4InhConnection).connect()
            ModularSamplingProbabilisticConnector(self,'V1L4InhL4ExcConnection',cortex_inh_l4,cortex_exc_l4,self.parameters.sheets.l4_cortex_inh.L4InhL4ExcConnection).connect()
            ModularSamplingProbabilisticConnector(self,'V1L4InhL4InhConnection',cortex_inh_l4,cortex_inh_l4,self.parameters.sheets.l4_cortex_inh.L4InhL4InhConnection).connect()
Example #2
0
File: model.py Project: aopy/mozaik
    def __init__(self, sim, num_threads, parameters):
        Model.__init__(self, sim, num_threads, parameters)
        # Load components
        CortexExcL4 = load_component(
            self.parameters.sheets.l4_cortex_exc.component)
        CortexInhL4 = load_component(
            self.parameters.sheets.l4_cortex_inh.component)

        if not self.parameters.only_afferent and self.parameters.l23:
            CortexExcL23 = load_component(
                self.parameters.sheets.l23_cortex_exc.component)
            CortexInhL23 = load_component(
                self.parameters.sheets.l23_cortex_inh.component)

        RetinaLGN = load_component(self.parameters.sheets.retina_lgn.component)

        # Build and instrument the network
        self.visual_field = VisualRegion(
            location_x=self.parameters.visual_field.centre[0],
            location_y=self.parameters.visual_field.centre[1],
            size_x=self.parameters.visual_field.size[0],
            size_y=self.parameters.visual_field.size[1])

        self.input_layer = RetinaLGN(
            self, self.parameters.sheets.retina_lgn.params
        )  # 'pyNN.spiNNaker' has no attribute 'StepCurrentSource'

        cortex_exc_l4 = CortexExcL4(
            self, self.parameters.sheets.l4_cortex_exc.params
        )  # spiNNaker has no attribute EIF_cond_exp_isfa_ista ->Iz

        cortex_inh_l4 = CortexInhL4(
            self, self.parameters.sheets.l4_cortex_inh.params)

        if not self.parameters.only_afferent and self.parameters.l23:
            cortex_exc_l23 = CortexExcL23(
                self, self.parameters.sheets.l23_cortex_exc.params)
            cortex_inh_l23 = CortexInhL23(
                self, self.parameters.sheets.l23_cortex_inh.params)

        # initialize afferent layer 4 projections
        GaborConnector(self, self.input_layer.sheets['X_ON'],
                       self.input_layer.sheets['X_OFF'], cortex_exc_l4,
                       self.parameters.sheets.l4_cortex_exc.AfferentConnection,
                       'V1AffConnection')
        GaborConnector(self, self.input_layer.sheets['X_ON'],
                       self.input_layer.sheets['X_OFF'], cortex_inh_l4,
                       self.parameters.sheets.l4_cortex_inh.AfferentConnection,
                       'V1AffInhConnection')

        # initialize lateral layer 4 projections
        if not self.parameters.only_afferent:

            ModularSamplingProbabilisticConnectorAnnotationSamplesCount(
                self, 'V1L4ExcL4ExcConnection', cortex_exc_l4, cortex_exc_l4,
                self.parameters.sheets.l4_cortex_exc.L4ExcL4ExcConnection
            ).connect()
            ModularSamplingProbabilisticConnectorAnnotationSamplesCount(
                self, 'V1L4ExcL4InhConnection', cortex_exc_l4, cortex_inh_l4,
                self.parameters.sheets.l4_cortex_exc.L4ExcL4InhConnection
            ).connect()

            ModularSamplingProbabilisticConnector(
                self, 'V1L4InhL4ExcConnection', cortex_inh_l4, cortex_exc_l4,
                self.parameters.sheets.l4_cortex_inh.L4InhL4ExcConnection
            ).connect()
            ModularSamplingProbabilisticConnector(
                self, 'V1L4InhL4InhConnection', cortex_inh_l4, cortex_inh_l4,
                self.parameters.sheets.l4_cortex_inh.L4InhL4InhConnection
            ).connect()

            if self.parameters.l23:
                # if False:
                # initialize afferent layer 4 to layer 2/3 projection
                ModularSamplingProbabilisticConnector(
                    self, 'V1L4ExcL23ExcConnection', cortex_exc_l4,
                    cortex_exc_l23, self.parameters.sheets.l23_cortex_exc.
                    L4ExcL23ExcConnection).connect()
                ModularSamplingProbabilisticConnector(
                    self, 'V1L4ExcL23InhConnection', cortex_exc_l4,
                    cortex_inh_l23, self.parameters.sheets.l23_cortex_inh.
                    L4ExcL23InhConnection).connect()

                ModularSamplingProbabilisticConnector(
                    self, 'V1L23ExcL23ExcConnection', cortex_exc_l23,
                    cortex_exc_l23, self.parameters.sheets.l23_cortex_exc.
                    L23ExcL23ExcConnection).connect()
                ModularSamplingProbabilisticConnector(
                    self, 'V1L23ExcL23InhConnection', cortex_exc_l23,
                    cortex_inh_l23, self.parameters.sheets.l23_cortex_exc.
                    L23ExcL23InhConnection).connect()
                ModularSamplingProbabilisticConnector(
                    self, 'V1L23InhL23ExcConnection', cortex_inh_l23,
                    cortex_exc_l23, self.parameters.sheets.l23_cortex_inh.
                    L23InhL23ExcConnection).connect()
                ModularSamplingProbabilisticConnector(
                    self, 'V1L23InhL23InhConnection', cortex_inh_l23,
                    cortex_inh_l23, self.parameters.sheets.l23_cortex_inh.
                    L23InhL23InhConnection).connect()
                if self.parameters.feedback:
                    ModularSamplingProbabilisticConnector(
                        self, 'V1L23ExcL4ExcConnection', cortex_exc_l23,
                        cortex_exc_l4, self.parameters.sheets.l23_cortex_exc.
                        L23ExcL4ExcConnection).connect()
                    ModularSamplingProbabilisticConnector(
                        self, 'V1L23ExcL4InhConnection', cortex_exc_l23,
                        cortex_inh_l4, self.parameters.sheets.l23_cortex_exc.
                        L23ExcL4InhConnection).connect()
Example #3
0
    def __init__(self, network, lgn_on, lgn_off, target, parameters, name):
        from numpy import random
        random.seed(1023)
        BaseComponent.__init__(self, network, parameters)
        self.name = name

        t_size = target.size_in_degrees()
        or_map = None
        if self.parameters.or_map:

            f = open(self.parameters.or_map_location, 'r')
            or_map = pickle.load(f) * numpy.pi
            #or_map = pickle.load(f)*numpy.pi*2
            #or_map = numpy.cos(or_map) + 1j*numpy.sin(or_map)

            coords_x = numpy.linspace(-t_size[0] / 2.0, t_size[0] / 2.0,
                                      numpy.shape(or_map)[0])
            coords_y = numpy.linspace(-t_size[1] / 2.0, t_size[1] / 2.0,
                                      numpy.shape(or_map)[1])

            X, Y = numpy.meshgrid(coords_x, coords_y)

            or_map = NearestNDInterpolator(zip(X.flatten(), Y.flatten()),
                                           or_map.flatten())
            #or_map = CloughTocher2DInterpolator(zip(X.flatten(), Y.flatten()),
            #                               or_map.flatten())

        phase_map = None
        if self.parameters.phase_map:
            f = open(self.parameters.phase_map_location, 'r')
            phase_map = pickle.load(f)
            coords_x = numpy.linspace(-t_size[0] / 2.0, t_size[0] / 2.0,
                                      numpy.shape(phase_map)[0])
            coords_y = numpy.linspace(-t_size[1] / 2.0, t_size[1] / 2.0,
                                      numpy.shape(phase_map)[1])
            X, Y = numpy.meshgrid(coords_x, coords_y)
            phase_map = NearestNDInterpolator(zip(X.flatten(), Y.flatten()),
                                              phase_map.flatten())

        for (j, neuron2) in enumerate(target.pop.all()):
            if or_map:
                orientation = or_map(target.pop.positions[0][j],
                                     target.pop.positions[1][j])

                #orientation = (numpy.angle(or_map(target.pop.positions[0][j],
                #                     target.pop.positions[1][j]))+numpy.pi)/2.0

            else:
                orientation = parameters.orientation_preference.next()

            if phase_map:
                phase = phase_map(target.pop.positions[0][j],
                                  target.pop.positions[1][j])
            else:
                phase = parameters.phase.next()

            aspect_ratio = parameters.aspect_ratio.next()
            frequency = parameters.frequency.next()
            size = parameters.size.next()

            assert orientation < numpy.pi

            target.add_neuron_annotation(j,
                                         'LGNAfferentOrientation',
                                         orientation,
                                         protected=True)
            target.add_neuron_annotation(j,
                                         'LGNAfferentAspectRatio',
                                         aspect_ratio,
                                         protected=True)
            target.add_neuron_annotation(j,
                                         'LGNAfferentFrequency',
                                         frequency,
                                         protected=True)
            target.add_neuron_annotation(j,
                                         'LGNAfferentSize',
                                         size,
                                         protected=True)
            target.add_neuron_annotation(j,
                                         'LGNAfferentPhase',
                                         phase,
                                         protected=True)
            target.add_neuron_annotation(j,
                                         'aff_samples',
                                         self.parameters.num_samples.next(),
                                         protected=True)

            if self.parameters.topological:
                target.add_neuron_annotation(j,
                                             'LGNAfferentX',
                                             target.pop.positions[0][j] +
                                             parameters.rf_jitter.next(),
                                             protected=True)
                target.add_neuron_annotation(j,
                                             'LGNAfferentY',
                                             target.pop.positions[1][j] +
                                             parameters.rf_jitter.next(),
                                             protected=True)
            else:
                target.add_neuron_annotation(j,
                                             'LGNAfferentX',
                                             parameters.rf_jitter.next(),
                                             protected=True)
                target.add_neuron_annotation(j,
                                             'LGNAfferentY',
                                             parameters.rf_jitter.next(),
                                             protected=True)

        ps = ParameterSet({
            'target_synapses': 'excitatory',
            'weight_functions': {
                'f1': {
                    'component': 'mozaik.connectors.vision.GaborArborization',
                    'params': {
                        'ON': True,
                    }
                }
            },
            'delay_functions': self.parameters.delay_functions,
            'weight_expression':
            'f1',  # a python expression that can use variables f1..fn where n is the number of functions in weight_functions, and fi corresponds to the name given to a ModularConnectorFunction in weight_function ParameterSet. It determines how are the weight functions combined to obtain the weights
            'delay_expression': self.parameters.delay_expression,
            'short_term_plasticity': self.parameters.short_term_plasticity,
            'base_weight': self.parameters.base_weight,
            'num_samples': 0,
            'annotation_reference_name': 'aff_samples',
        })

        ModularSamplingProbabilisticConnectorAnnotationSamplesCount(
            network, name + 'On', lgn_on, target, ps).connect()
        ps['weight_functions.f1.params.ON'] = False
        ps['base_weight'] = self.parameters.base_weight * self.parameters.off_bias
        ModularSamplingProbabilisticConnectorAnnotationSamplesCount(
            network, name + 'Off', lgn_off, target, ps).connect()