How to use the elephant.statistics.isi function in elephant

To help you get started, we’ve selected a few elephant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simetenn / uncertainpy / src / uncertainpy / features / network_features.py View on Github external
neo_spiketrains : list
            A list of Neo spiketrains.

        Returns
        -------
        time : None
        average_isi : float
           The average interspike interval.
        """
        if len(spiketrains) == 0:
            return None, None

        isi = []
        for spiketrain in spiketrains:
            if len(spiketrain) > 1:
                isi.append(np.mean(elephant.statistics.isi(spiketrain)))

        return None, np.mean(isi)
github simetenn / uncertainpy / src / uncertainpy / features / network_features.py View on Github external
The simulation end time.
        neo_spiketrains : list
            A list of Neo spiketrains.

        Returns
        -------
        time : None
        average_local_variation : float
            The average of the local variation for each spiketrain.
        """
        if len(spiketrains) == 0:
            return None, None

        local_variation = []
        for spiketrain in spiketrains:
            isi = elephant.statistics.isi(spiketrain)
            if len(isi) > 1:
                local_variation.append(elephant.statistics.lv(isi))

        return None, np.mean(local_variation)
github simetenn / uncertainpy / src / uncertainpy / features / network_features.py View on Github external
Returns
        -------
        time : array
            The center of each bin.
        binned_isi : array
            The binned interspike intervals.
        """
        if len(spiketrains) == 0:
            return None, None

        binned_isi = []
        bins = np.arange(0, spiketrains[0].t_stop.magnitude + self.isi_bin_size, self.isi_bin_size)

        for spiketrain in spiketrains:
            if len(spiketrain) > 1:
                isi = elephant.statistics.isi(spiketrain)
                binned_isi.append(np.histogram(isi, bins=bins)[0])

            else:
                binned_isi.append(np.zeros(len(bins) - 1))

        centers = bins[1:] - 0.5
        return centers, binned_isi
github simetenn / uncertainpy / src / uncertainpy / features / network_features.py View on Github external
The simulation end time.
        neo_spiketrains : list
            A list of Neo spiketrains.

        Returns
        -------
        time : None
        local_variation : list
            The local variation for each spiketrain.
        """
        if len(spiketrains) == 0:
            return None, None

        local_variation = []
        for spiketrain in spiketrains:
            isi = elephant.statistics.isi(spiketrain)
            if len(isi) > 1:
                local_variation.append(elephant.statistics.lv(isi))
            else:
                local_variation.append(None)

        return None, local_variation
github NeuralEnsemble / elephant / elephant / spike_train_surrogates.py View on Github external
Original implementation by: Emiliano Torre [e.torre@fz-juelich.de]
:copyright: Copyright 2015-2016 by the Elephant team, see `doc/authors.rst`.
:license: Modified BSD, see LICENSE.txt for details.
"""

import numpy as np
import quantities as pq
import neo
from scipy.ndimage import gaussian_filter
import random

try:
    import elephant.statistics as es

    isi = es.isi
except ImportError:
    from .statistics import isi  # Convenience when in elephant working dir.


def dither_spikes(spiketrain, dither, n=1, decimals=None, edges=True):
    """
    Generates surrogates of a spike train by spike dithering.

    The surrogates are obtained by uniformly dithering times around the
    original position. The dithering is performed independently for each
    surrogate.

    The surrogates retain the :attr:`t_start` and :attr:`t_stop` of the
    original `SpikeTrain` object. Spikes moved beyond this range are lost or
    moved to the range's ends, depending on the parameter edge.