Giter Site home page Giter Site logo

leo-rain / entropy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raphaelvallat/entropy

0.0 1.0 0.0 2.44 MB

EntroPy: complexity of (EEG) time-series in Python

Home Page: https://raphaelvallat.com/entropy/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

entropy's Introduction


https://travis-ci.org/raphaelvallat/entropy.svg?branch=master https://ci.appveyor.com/api/projects/status/mukj36n939ftu4io?svg=true
https://github.com/raphaelvallat/entropy/blob/master/docs/pictures/logo.png

EntroPy is a Python 3 package providing several time-efficient algorithms for computing the complexity of one-dimensional time-series. It can be used for example to extract features from EEG signals.

Documentation

Installation

Important

Please note that EntroPy cannot be installed using pip or conda. There is already a package called entropy on the pip repository, which should not be mistaken with the current package.

git clone https://github.com/raphaelvallat/entropy.git entropy/
cd entropy/
pip install -r requirements.txt
python setup.py develop

Dependencies

Functions

Entropy

from entropy import *
import numpy as np
np.random.seed(1234567)
x = np.random.rand(3000)
print(perm_entropy(x, order=3, normalize=True))                 # Permutation entropy
print(spectral_entropy(x, 100, method='welch', normalize=True)) # Spectral entropy
print(svd_entropy(x, order=3, delay=1, normalize=True))         # Singular value decomposition entropy
print(app_entropy(x, order=2, metric='chebyshev'))              # Approximate entropy
print(sample_entropy(x, order=2, metric='chebyshev'))           # Sample entropy
print(lziv_complexity('01111000011001', normalize=True))        # Lempel-Ziv complexity
0.9995858289645746
0.9945519071575192
0.8482185855709181
2.076046899582793
2.192416747827227
0.9425204748625924

Fractal dimension

print(petrosian_fd(x))            # Petrosian fractal dimension
print(katz_fd(x))                 # Katz fractal dimension
print(higuchi_fd(x, kmax=10))     # Higuchi fractal dimension
print(detrended_fluctuation(x))   # Detrended fluctuation analysis
1.0303256054255618
9.496389529050981
1.9914197968462963
0.5082304865081877

Execution time

Here are some benchmarks computed on an average PC (i7-7700HQ CPU @ 2.80 Ghz - 8 Go of RAM).

from entropy import *
import numpy as np
np.random.seed(1234567)
x = np.random.rand(1000)
# Entropy
%timeit perm_entropy(x, order=3, delay=1)
%timeit spectral_entropy(x, 100, method='fft')
%timeit svd_entropy(x, order=3, delay=1)
%timeit app_entropy(x, order=2) # Slow
%timeit sample_entropy(x, order=2) # Numba
# Fractal dimension
%timeit petrosian_fd(x)
%timeit katz_fd(x)
%timeit higuchi_fd(x) # Numba
%timeit detrended_fluctuation(x) # Numba
127 µs ± 3.86 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
150 µs ± 859 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
42.4 µs ± 306 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
4.59 ms ± 62.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.03 ms ± 39.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
16.4 µs ± 251 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
32.4 µs ± 578 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
17.4 µs ± 274 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
755 µs ± 17.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

Development

EntroPy was created and is maintained by Raphael Vallat. Contributions are more than welcome so feel free to contact me, open an issue or submit a pull request!

To see the code or report a bug, please visit the GitHub repository.

Note that this program is provided with NO WARRANTY OF ANY KIND. If you can, always double check the results.

Acknowledgement

Several functions of EntroPy were adapted from:

All the credit goes to the author of these excellent packages.

entropy's People

Contributors

raphaelvallat avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.