示例#1
0
    def initialize_delay_queue(self):
        """Initialiaze a delay queue for the connection.

        The delay attribute of the connection defines the transmission delay of
        the signal from the souce to the target.  Firing rate values from the
        source population are held in a queue, discretized by the timestep, that
        is rolled over once per timestep.  if source is an ExternalPopulation,
        the queue is initialized to the firing rate at t=0; if the source is an
        InternalPopulation, the queue is initialized to zero.
        """

        # Delay vals need to be cleaned up to account for not necessarily being evenly divisible by dt:
        delay_ind_dict = {}
        self.delay_inds = np.array(np.round(self.delay_vals/self.simulation.dt), dtype=np.int)
        for curr_ind, curr_prob in zip(self.delay_inds, self.delay_probs):
            delay_ind_dict.setdefault(curr_ind, []).append(curr_prob)

        self.delay_inds = sorted(delay_ind_dict.keys())
        self.delay_vals = np.array([self.simulation.dt*ii for ii in self.delay_inds])
        self.delay_probs = np.array([np.sum(delay_ind_dict[ii]) for ii in self.delay_inds])
        util.assert_probability_mass_conserved(self.delay_probs)
        
        max_delay_ind = max(self.delay_inds)
        self.delay_probability_vector = np.zeros(max_delay_ind+1)
        self.delay_probability_vector[self.delay_inds] = self.delay_probs
        self.delay_probability_vector = self.delay_probability_vector[::-1]
        
        # Determine delay_queue:
        if self.delay_queue_initial_condition is None:
            self.delay_queue = self.source.initialize_delay_queue(max_delay_ind)
        else:
            self.delay_queue = self.delay_queue_initial_condition
            assert len(self.delay_queue) == len(self.delay_probability_vector)
    
        self.delay_queue = collections.deque(self.delay_queue)
示例#2
0
    def initialize_delay_queue(self):
        """Initialiaze a delay queue for the connection.

        The delay attribute of the connection defines the transmission delay of
        the signal from the souce to the target.  Firing rate values from the
        source population are held in a queue, discretized by the timestep, that
        is rolled over once per timestep.  if source is an ExternalPopulation,
        the queue is initialized to the firing rate at t=0; if the source is an
        InternalPopulation, the queue is initialized to zero.
        """

        # Delay vals need to be cleaned up to account for not necessarily being evenly divisible by dt:
        delay_ind_dict = {}
        self.delay_inds = np.array(np.round(self.delay_vals /
                                            self.simulation.dt),
                                   dtype=np.int)
        for curr_ind, curr_prob in zip(self.delay_inds, self.delay_probs):
            delay_ind_dict.setdefault(curr_ind, []).append(curr_prob)

        self.delay_inds = sorted(delay_ind_dict.keys())
        self.delay_vals = np.array(
            [self.simulation.dt * ii for ii in self.delay_inds])
        self.delay_probs = np.array(
            [np.sum(delay_ind_dict[ii]) for ii in self.delay_inds])
        util.assert_probability_mass_conserved(self.delay_probs)

        max_delay_ind = max(self.delay_inds)
        self.delay_probability_vector = np.zeros(max_delay_ind + 1)
        self.delay_probability_vector[self.delay_inds] = self.delay_probs
        self.delay_probability_vector = self.delay_probability_vector[::-1]

        # Determine delay_queue:
        if self.delay_queue_initial_condition is None:
            if isinstance(self.source, InternalPopulation):
                self.delay_queue = np.core.numeric.ones(
                    max_delay_ind + 1) * self.simulation.get_curr_firing_rate(
                        self.source.gid)
            elif isinstance(self.source, ExternalPopulation):
                self.delay_queue = np.core.numeric.zeros(max_delay_ind + 1)
                for i in range(len(self.delay_queue)):
                    self.delay_queue[i] = self.simulation.get_firing_rate(
                        self.source.gid,
                        self.simulation.t - self.simulation.dt * i)
                self.delay_queue = self.delay_queue[::-1]
            else:
                self.delay_queue = np.core.numeric.zeros(max_delay_ind + 1)
#                 raise Exception('Unrecognized source type: "%s"' % type(self.source))    # pragma: no cover

        else:
            self.delay_queue = self.delay_queue_initial_condition
            assert len(self.delay_queue) == len(self.delay_probability_vector)

        self.delay_queue = collections.deque(self.delay_queue)
示例#3
0
    def initialize_probability(self):
        '''Initialize self.pv to delta-distribution at v=0.'''

        self.p0 = util.discretize_if_needed(self.p0)
        self.pv = util.get_pv_from_p0(self.p0, self.edges)
        util.assert_probability_mass_conserved(self.pv, 1e-15)
示例#4
0
    def initialize_probability(self):
        '''Initialize self.pv to delta-distribution at v=0.'''

        self.p0 = util.discretize_if_needed(self.p0)
        self.pv = util.get_pv_from_p0(self.p0, self.edges)
        util.assert_probability_mass_conserved(self.pv, 1e-15)