raphaelvallat/antropy

AntroPy: entropy and complexity of (EEG) time-series in Python

What it solves

When you have a time-series (like an EEG, ECG, or EMG recording) and need compact numeric features that describe its structure, randomness, or complexity, AntroPy provides ready-made measures. Instead of implementing each algorithm from scratch, you get a single package that computes entropy measures (permutation, spectral, sample, approximate, etc.) and fractal-dimension estimates (Petrosian, Katz, Higuchi, detrended fluctuation analysis) in a few function calls.

How it works

AntroPy exposes a set of functions, each implementing a well-known algorithm from the signal-processing literature. For example:

  • perm_entropy captures ordinal patterns in the signal.
  • spectral_entropy uses FFT or the Welch method to compute power-spectrum entropy.
  • sample_entropy and app_entropy quantify regularity.
  • higuchi_fd estimates the slope of log curve-length vs log interval.

Most functions accept 1-D or N-D arrays, with an axis argument so you can process multi-channel data (e.g. 4 EEG channels) in a single call. Internally, several functions are compiled with Numba for speed, so the first call may have a short one-time compilation cost, but subsequent calls are fast. The package also handles normalization options and returns standard interpretable values (e.g. 0 = regular, 1 = random for permutation entropy).

Who it's for

Researchers, data scientists, and engineers working with time-series data, especially in physiological signal analysis (EEG, ECG, EMG) or signal-processing research. It is also useful for anyone who needs to extract feature vectors from time-series for machine-learning pipelines or exploratory analysis.

Highlights

  • Covers a broad set of entropy and fractal-dimension algorithms in one package.
  • Optimized with Numba: many functions run in microseconds for short signals and milliseconds for longer ones (benchmarks provided in the README).
  • Supports N-D arrays with an axis argument, simplifying multi-channel feature extraction.
  • Easy installation via pip, uv, or conda (requires Python 3.10+).
  • Includes detrended fluctuation analysis (DFA) for estimating the Hurst / scaling exponent.
  • Functions like sample_entropy, higuchi_fd, and detrended_fluctuation are Numba-compiled for speed.

Related

  • Project
  • Project
  • Project
  • Project