Skip to main content

Python implementation of the cvxEDA algorithm

Project description

cvxEDA – Python implementation

This program implements the cvxEDA algorithm for the analysis of electrodermal activity (EDA) using methods of convex optimisation, described in:

A. Greco, G. Valenza, A. Lanata, E. P. Scilingo, and L. Citi
“cvxEDA: a Convex Optimization Approach to Electrodermal Activity Processing”
IEEE Transactions on Biomedical Engineering, 2015
DOI: 10.1109/TBME.2015.2474131

What the algorithm does

It is based on a model which describes EDA as the sum of three terms:

  • phasic component – transient increases reflecting sudomotor bursts;
  • tonic component – slowly varying baseline activity;
  • additive white‑Gaussian‑noise term – captures model prediction errors, measurement noise and artifacts.

The model is physiologically inspired and fully explains EDA through a rigorous methodology based on Bayesian statistics, convex optimisation and sparsity.

Installation

# ── From PyPI (recommended)
pip install cvxeda                                # latest release
pip install "cvxeda==1.0.0"                       # or a specific version

# ── Directly from GitHub
pip install git+https://github.com/lciti/cvxEDA.git         # latest commit
pip install git+https://github.com/lciti/cvxEDA.git@v1.0.0  # or a specific version

# ── From a local clone
git clone https://github.com/youruser/cvxEDA.git  # clone
cd cvxEDA                                         # enter folder
git checkout v1.0.0                               # (optional) pick version
pip install .                                     # install

Quick example

import numpy as np
import cvxeda
import matplotlib.pyplot as plt

# Simulated EDA signal (replace with your own data)
tm = np.linspace(0, 40, 1000)                                           # 40 s at 25 Hz
y = np.convolve(np.sin(.7 * tm) < -.8, np.exp(-.5 * tm[:200]), 'same')  # simple fake signal
y += np.random.randn(len(y))                                            # add noise

yn = (y - y.mean()) / y.std()  # standardise
Fs = 25.0                      # sampling frequency (Hz)

# Run the algorithm
r, p, t, l, d, e, obj = cvxeda.cvxEDA(yn, 1.0 / Fs)

# Plot
tm = np.arange(1, len(y) + 1) / Fs
plt.figure()
plt.plot(tm, yn, label='normalised input')
plt.plot(tm, r,  label='phasic component')
plt.plot(tm, p,  label='sparse SMNA driver')
plt.plot(tm, t,  label='tonic component')
plt.xlabel('Time (s)')
plt.legend()
plt.show()

help(cvxeda.cvxEDA) prints the full function signature and argument description.

License & citation

The code is released under GPL‑3.0 (see LICENSE.txt).

If you use this program in support of published research, please cite the reference above. If you use this code in a software package, please explicitly inform the end users of this copyright notice and ask them to cite the reference above in their published research.

Project repository: https://github.com/lciti/cvxeda

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvxeda-1.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvxeda-1.1.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file cvxeda-1.1.0.tar.gz.

File metadata

  • Download URL: cvxeda-1.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for cvxeda-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bd693fa3369acb926e2380f2d6dbefe303885912b726d2a768d63b6640a26e87
MD5 f811b9776fda24b7b83320f952d1088f
BLAKE2b-256 f336c641f361654e9cb8679f63a0ef1344af3a3f11ae41deb1d2e165577f05f0

See more details on using hashes here.

File details

Details for the file cvxeda-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cvxeda-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for cvxeda-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f49e5a2882d196643ed52df46e02b29e96410a6cba7a1e9ab2d5a14be11fe7d5
MD5 24c6625832c6dfc1f68e270ed031ec32
BLAKE2b-256 6e42e1467263af2e6fba576913c8732ec7e5b3c5823c228055acb8f0ff12a56f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page