Пример #1
0
def smoothed_rate(data, smooth=0.0):
    """ 
    **Deprecated!!**

    Takes the recorded spikes of a population and returns a smoothed firing rate.

    *Parameters*:

    * **data**: the dictionary returned by ``get_record()[pop]['spike']``

    * **smooth**: the smoothing time constant (default: 0 ms, not smoothed)
    """
    Global._warning("smoothed_rate() is deprecated, use a Monitor instead.")
    import ANNarchy.core.cython_ext.Transformations as Transformations
    return Transformations.smoothed_rate(data, smooth)
Пример #2
0
def smoothed_rate(data, smooth=0.0):
    """ 
    **Deprecated!!**

    Takes the recorded spikes of a population and returns a smoothed firing rate.

    *Parameters*:

    * **data**: the dictionary returned by ``get_record()[pop]['spike']``

    * **smooth**: the smoothing time constant (default: 0 ms, not smoothed)
    """
    Global._warning("smoothed_rate() is deprecated, use a Monitor instead.")
    import ANNarchy.core.cython_ext.Transformations as Transformations
    return Transformations.smoothed_rate(data, smooth)
Пример #3
0
    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.
        * **smooth**: smoothing time constant. Default: 0.0 (no smoothing).

        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')

        # 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
        )
Пример #4
0
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
    )