def population_rate(data, smooth=Global.config['dt']): """ **Deprecated!!** Takes the recorded spikes of a population and returns a smoothed firing rate for the whole population. *Parameters*: * **data**: the dictionary returned by ``get_record()[pop]['spike']`` * **smooth**: the smoothing time constant (default: dt) """ Global._warning("population_rate() is deprecated, use a Monitor instead.") import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.population_rate(data, smooth)
def population_rate(self, spikes=None, smooth=0.): """ Takes the recorded spikes of a population and returns a smoothed firing rate for the population of recorded neurons. This method is faster than calling ``smoothed_rate`` and then averaging. The first axis is the neuron index, the second is time. *Parameters*: * **spikes**: the dictionary of spikes returned by ``get('spike')``. * **smooth**: smoothing time constant. Default: 0.0 (no smoothing). If `spikes` is left empty, ``get('spike')`` will be called. Beware: this erases the data from memory. Example:: m = Monitor(P[:1000], 'spike') simulate(1000.0) r = m.population_rate(smooth=100.) """ if not 'spike' in self.variables: Global._error('Monitor: spike was not recorded') # Get data if not spikes: data = self.get('spike') else: if 'spike' in spikes.keys(): data = spikes['spike'] else: data = spikes import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.population_rate( { 'data': data, 'start': self._recorded_variables['spike']['start'][-1], 'stop': self._recorded_variables['spike']['stop'][-1] }, smooth )
def population_rate(spikes, smooth=0.0): """ Takes the recorded spikes of a population and returns a smoothed firing rate for the population of recorded neurons. This method is faster than calling ``smoothed_rate`` and then averaging. The first axis is the neuron index, the second is time. *Parameters*: * **spikes**: the dictionary of spikes returned by ``get('spike')``. * **smooth**: smoothing time constant. Default: 0.0 (no smoothing). Example:: m = Monitor(P[:1000], 'spike') simulate(1000.0) spikes = m.get('spike') r = population_rate(smooth=100.) """ # Compute the duration of the recordings t_maxes = [] t_mines = [] for neuron in spikes.keys(): if len(spikes[neuron]) == 0 : continue t_maxes.append(np.max(spikes[neuron])) t_mines.append(np.min(spikes[neuron])) t_max = np.max(t_maxes) t_min = np.min(t_mines) import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.population_rate( { 'data': spikes, 'start':t_min, 'stop': t_max }, smooth )
def smoothed_rate(spikes, smooth=0.): """ Computes the smoothed firing rate of the recorded spiking neurons. The first axis is the neuron index, the second is time. *Parameters*: * **spikes**: the dictionary of spikes returned by ``get('spike')``. If left empty, ``get('spike')`` will be called. Beware: this erases the data from memory. * **smooth**: smoothing time constant. Default: 0.0 (no smoothing). Example:: m = Monitor(P[:1000], 'spike') simulate(1000.0) spikes = m.get('spike') r = smoothed_rate(smooth=100.) """ # Compute the duration of the recordings t_maxes = [] t_mines = [] for neuron in spikes.keys(): if len(spikes[neuron]) == 0 : continue t_maxes.append(np.max(spikes[neuron])) t_mines.append(np.min(spikes[neuron])) t_max = np.max(t_maxes) t_min = np.min(t_mines) import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.smoothed_rate( { 'data': spikes, 'start': t_min, 'stop': t_max }, smooth )
def smoothed_rate(self, spikes=None, smooth=0.): """ Computes the smoothed firing rate of the recorded spiking neurons. The first axis is the neuron index, the second is time. *Parameters*: * **spikes**: the dictionary of spikes returned by ``get('spike')``. If left empty, ``get('spike')`` will be called. Beware: this erases the data from memory. Example:: m = Monitor(P[:1000], 'spike') simulate(1000.0) r = m.smoothed_rate(smooth=100.) """ if not 'spike' in self.variables: Global._error('Monitor: spike was not recorded') exit(0) # Get data if not spikes: data = self.get('spike') else: if 'spike' in spikes.keys(): data = spikes['spike'] else: data = spikes import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.smoothed_rate( { 'data': data, 'start': self._recorded_variables['spike']['start'][-1], 'stop': self._recorded_variables['spike']['stop'][-1] }, smooth )
def smoothed_rate(self, spikes=None, smooth=0.): """ Computes the smoothed firing rate of the recorded spiking neurons. The first axis is the neuron index, the second is time. Example: ```python m = Monitor(P[:1000], 'spike') simulate(1000.0) r = m.smoothed_rate(smooth=100.) ``` :param spikes: the dictionary of spikes returned by ``get('spike')``. If left empty, ``get('spike')`` will be called. Beware: this erases the data from memory. :param smooth: smoothing time constant. Default: 0.0 (no smoothing). """ if not 'spike' in self._variables: Global._error('Monitor: spike was not recorded') # Get data if not spikes: data = self.get('spike') else: if 'spike' in spikes.keys(): data = spikes['spike'] else: data = spikes import ANNarchy.core.cython_ext.Transformations as Transformations return Transformations.smoothed_rate( { 'data': data, 'start': self._last_recorded_variables['spike']['start'][-1], 'stop': self._last_recorded_variables['spike']['stop'][-1] }, smooth)