Exemplo n.º 1
0
 def __init__(self, network, source, target, parameters,name):
     MozaikComponent.__init__(self,network,parameters)
     self.name = name
     self.source = source
     self.target = target
     weights = []
     
     
     for (i,neuron1) in enumerate(self.target.pop.all()):
         for (j,neuron2) in enumerate(self.source.pop.all()):
     
             or_dist = circular_dist(self.target.get_neuron_annotation(i,'LGNAfferentOrientation'),self.source.get_neuron_annotation(j,'LGNAfferentOrientation'),numpy.pi) / (numpy.pi/2)
             
             if self.parameters.specific_arborization.target_synapses == 'excitatory':
                     phase_dist = circular_dist(self.target.get_neuron_annotation(i,'LGNAfferentPhase'),self.source.get_neuron_annotation(j,'LGNAfferentPhase'),2*numpy.pi) / numpy.pi
             elif self.parameters.specific_arborization.target_synapses == 'inhibitory':
                     phase_dist = (numpy.pi - circular_dist(self.target.get_neuron_annotation(i,'LGNAfferentPhase'),self.source.get_neuron_annotation(j,'LGNAfferentPhase'),2*numpy.pi)) / numpy.pi
             else:
                 logger.error('Unknown type of synapse!')
                 return	
     
             or_gauss = normal_function(or_dist,mean=0,sigma=self.parameters.or_sigma)
             phase_gauss = normal_function(phase_dist,mean=0,sigma=self.parameters.or_sigma)
             w = phase_gauss*or_gauss*or_gauss
             
             weights.append((j,i,w,self.parameters.propagation_constant))
     
     we = numpy.zeros((len(self.source.pop),len(self.target.pop)))
     
     
     pnv_source = []
     pnv_target = []
     for (i,neuron1) in enumerate(self.target.pop.all()):
         pnv_target.append(self.target.get_neuron_annotation(i,'LGNAfferentOrientation'))
     
     for (i,neuron1) in enumerate(self.source.pop.all()):
         pnv_source.append(self.source.get_neuron_annotation(i,'LGNAfferentOrientation'))
     
     
     for (j,i,w,xsj) in weights:
         we[j,i] = w
     
     (angle,mag) = circ_mean(numpy.array([numpy.array(pnv_target).T for i in xrange(0,numpy.shape(we)[0])]),weights=numpy.array(we),low=0,high=numpy.pi,axis=1)            
     
    
                             
     if self.parameters.probabilistic:
         SpecificProbabilisticArborization(network, self.source, self.target, weights,self.parameters.specific_arborization,self.name).connect()
     else:
         SpecificArborization(network, self.source, self.target, weights,self.parameters.specific_arborization,self.name).connect()
Exemplo n.º 2
0
      def __init__(self, network, lgn_on, lgn_off, target, parameters,name):
    	     MozaikComponent.__init__(self, network,parameters)
             import pickle
             self.name = name
             on = lgn_on.pop
             off = lgn_off.pop
             
             on_weights=[] 
             off_weights=[]
             
             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
                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())
                
             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])
                else: 
                   orientation = parameters.orientation_preference.next()[0]

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

                # HACK!!!
                #if j == 0: 
                #   orientation = 0
                #   if target.name=='V1_Exc':
                #      phase = 0
                #   elif target.name=='V1_Inh':
                #      phase = 0
                
                aspect_ratio = parameters.aspect_ratio.next()[0]
                frequency = parameters.frequency.next()[0]
                size = parameters.size.next()[0]
				
                if orientation > numpy.pi:
                   print orientation
                
                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)
                 
                for (i,neuron1) in enumerate(on.all()):
                    if parameters.topological:
                        on_weights.append((i,j,numpy.max((0,gabor(on.positions[0][i],on.positions[1][i],target.pop.positions[0][j],target.pop.positions[1][j],orientation+numpy.pi/2,frequency,phase,size,aspect_ratio))),parameters.delay))
                        off_weights.append((i,j,-numpy.min((0,gabor(off.positions[0][i],off.positions[1][i],target.pop.positions[0][j],target.pop.positions[1][j],orientation+numpy.pi/2,frequency,phase,size,aspect_ratio))),parameters.delay))
                    else:
                        on_weights.append((i,j,numpy.max((0,gabor(on.positions[0][i],on.positions[1][i],0,0,orientation+numpy.pi/2,frequency,phase,size,aspect_ratio))),parameters.delay))
                        off_weights.append((i,j,-numpy.min((0,gabor(off.positions[0][i],off.positions[1][i],0,0,orientation+numpy.pi/2,frequency,phase,size,aspect_ratio))),parameters.delay))
             
             
             if parameters.probabilistic:
                 on_proj =  SpecificProbabilisticArborization(network,lgn_on,target,on_weights,parameters.specific_arborization,'ON_to_[' + target.name + ']')
                 off_proj = SpecificProbabilisticArborization(network,lgn_off,target,off_weights,parameters.specific_arborization,'OFF_to_[' + target.name + ']')
             else:
                 on_proj =  SpecificArborization(network,lgn_on,target,on_weights,parameters.specific_arborization,'ON_to_[' + target.name + ']')
                 off_proj = SpecificArborization(network,lgn_off,target,off_weights,parameters.specific_arborization,'OFF_to_[' + target.name + ']')
             
             on_proj.connect()
             off_proj.connect()