biosppy.signals.eda

biosppy.signals.eda

This module provides methods to process Electrodermal Activity (EDA) signals, also known as Galvanic Skin Response (GSR).

copyright:
  1. 2015-2026 by Instituto de Telecomunicacoes

license:

BSD 3-clause, see LICENSE for more details.

Functions

basic_scr([signal])

Basic method to extract Skin Conductivity Responses (SCR) from an EDA signal.

biosppy_decomposition([signal, ...])

Extracts EDL and EDR signals using either a smoothing filter or onsets' interpolation.

cvx_decomposition([signal, sampling_rate, ...])

Performs EDA decomposition using the cvxEDA algorithm [Figner2011].

eda([signal, sampling_rate, units, path, ...])

Process a raw EDA signal and extract relevant signal features using default parameters.

eda_events([signal, sampling_rate, method])

Returns characteristic EDA events.

emotiphai_eda([signal, sampling_rate, ...])

Returns characteristic EDA events.

kbk_scr([signal, sampling_rate, min_amplitude])

KBK method to extract Skin Conductivity Responses (SCR) from an EDA signal.

rec_times([signal, sampling_rate, onsets, peaks])

Returns EDA recovery times.

biosppy.signals.eda.basic_scr(signal=None)[source]

Basic method to extract Skin Conductivity Responses (SCR) from an EDA signal.

Follows the approach in [Gamb08].

Parameters:

signal (array) – Input filtered EDA signal.

Returns:

  • onsets (array) – Indices of the SCR onsets.

  • peaks (array) – Indices of the SCR peaks.

  • amplitudes (array) – SCR pulse amplitudes.

References

[Gamb08]

Hugo Gamboa, “Multi-modal Behavioral Biometrics Based on HCI and Electrophysiology”, PhD thesis, Instituto Superior T{‘e}cnico, 2008

biosppy.signals.eda.biosppy_decomposition(signal=None, sampling_rate=1000.0, method='smoother', onsets=None, **kwargs)[source]

Extracts EDL and EDR signals using either a smoothing filter or onsets’ interpolation.

Parameters:
  • signal (array) – Input filtered EDA signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • method (str, optional) – Method to compute the edl signal: “smoother” to compute a smoothing filter; “onsets” to obtain edl by onsets’ interpolation.

  • onsets (array, optional) – List of onsets for the interpolation method.

  • kwargs (dict, optional) – window_size : Size of the smoother kernel (seconds).

Returns:

  • edl (array) – Electrodermal level (EDL) signal.

  • edr (array) – Electrodermal response (EDR) signal.

References

[KiBK04]

K.H. Kim, S.W. Bang, and S.R. Kim, “Emotion recognition system

using short-term monitoring of physiological signals”, Med. Biol. Eng. Comput., vol. 42, pp. 419-427, 2004

biosppy.signals.eda.cvx_decomposition(signal=None, sampling_rate=1000.0, tau0=2.0, tau1=0.7, delta_knot=10.0, alpha=0.0008, gamma=0.01, solver=None, options={'reltol': 1e-09})[source]

Performs EDA decomposition using the cvxEDA algorithm [Figner2011].

This function was originally developed by Luca Citi and Alberto Greco [cvxEDA]. You can find the original code and repository at: https://github.com/lciti/cvxEDA

If you use this function in your work, please cite the original authors as follows: A Greco, G Valenza, A Lanata, EP Scilingo, and L Citi “cvxEDA: a Convex Optimization Approach to Electrodermal Activity Processing” IEEE Transactions on Biomedical Engineering, 2015.

This function is used under the terms of the GNU General Public License v3.0 (GPLv3). You should comply with the GPLv3 if you use this code.

Copyright (C) 2014-2015 Luca Citi, Alberto Greco

Parameters:
  • signal (array) – Observed EDA signal (we recommend normalizing it: y = zscore(y))

  • sampling_rate (int, float) – Sampling frequency (Hz).

  • tau0 (float) – Slow time constant of the Bateman function

  • tau1 (float) – Fast time constant of the Bateman function

  • delta_knot (float) – Time between knots of the tonic spline function

  • alpha (float) – Penalization for the sparse SMNA driver

  • gamma (float) – Penalization for the tonic spline coefficients

  • solver (ndarray) – Sparse QP solver to be used, see cvxopt.solvers.qp

  • options (dict) – solver options, see: http://cvxopt.org/userguide/coneprog.html#algorithm-parameters

Returns:

  • edr (array) – Phasic component

  • smna (array) – Sparse SMNA driver of phasic component

  • edl (array) – Tonic component

  • tonic_coeff (array) – Coefficients of tonic spline

  • linear_drift (array) – Offset and slope of the linear drift term

  • res (array) – Model residuals

  • obj (array) – Value of objective function being minimized (eq 15 of paper)

References

[cvxEDA]

A Greco, G Valenza, A Lanata, EP 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

[Figner2011] (1,2)

Figner, Bernd & Murphy, Ryan. (2011). Using skin

conductance in judgment and decision making research. A Handbook of Process Tracing Methods for Decision Research.

Notes

License notice: The cvxEDA function is distributed under the GNU General Public License v3.0 (GPLv3). For details, see https://www.gnu.org/licenses/gpl-3.0.en.html

This code is provided as-is, without any warranty or support from the original authors.

Changes from original code: - ‘y’ -> ‘signal’ - ‘delta’ -> 1. / ‘sampling_rate’

biosppy.signals.eda.eda(signal=None, sampling_rate=1000.0, units=None, path=None, show=True, min_amplitude=0.1, size=0.9)[source]

Process a raw EDA signal and extract relevant signal features using default parameters.

Parameters:
  • signal (array) – Raw EDA signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • units (str, optional) – The units of the input signal. If specified, the plot will have the y-axis labeled with the corresponding units.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show a summary plot.

  • min_amplitude (float, optional) – Minimum threshold by which to exclude SCRs.

  • size (float, optional) – Size of the filter applied to exluced SCRs.

Returns:

  • ts (array) – Signal time axis reference (seconds).

  • filtered (array) – Filtered EDA signal.

  • edr (array) – Electrodermal response (EDR) signal.

  • edl (array) – Electrodermal level (EDL) signal.

  • onsets (array) – Indices of SCR pulse onsets.

  • peaks (array) – Indices of the SCR peaks.

  • amplitudes (array) – SCR pulse amplitudes.

biosppy.signals.eda.eda_events(signal=None, sampling_rate=1000.0, method='emotiphai', **kwargs)[source]

Returns characteristic EDA events.

Parameters:
  • signal (array) – Input signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • method (str, optional) – Method to compute eda events: ‘emotiphai’, ‘kbk’ or ‘basic’.

  • kwargs (dict, optional) – Method parameters.

Returns:

  • onsets (array) – Signal EDR events onsets.

  • peaks (array) – Signal EDR events peaks.

  • amps (array) – Signal EDR events Amplitudes.

  • phasic_rate (array) – Signal EDR events rate in 60s.

  • rise_times (array) – Rise times, i.e. onset-peak time difference.

  • half_rec (array) – Half Recovery times, i.e. time between peak and 63% amplitude.

  • six_rec (array) – 63 % recovery times, i.e. time between peak and 50% amplitude.

biosppy.signals.eda.emotiphai_eda(signal=None, sampling_rate=1000.0, min_amplitude=0.1, filt=True, size=1.0)[source]

Returns characteristic EDA events.

Parameters:
  • signal (array) – Input signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • min_amplitude (float, optional) – Minimum threshold by which to exclude SCRs.

  • filt (bool, optional) – Whether to filter signal to remove noise and low amplitude events.

  • size (float) – Size of the filter in seconds

Returns:

  • onsets (array) – Indices of the SCR onsets.

  • peaks (array) – Indices of the SCR peaks.

  • amplitudes (array) – SCR pulse amplitudes.

biosppy.signals.eda.kbk_scr(signal=None, sampling_rate=1000.0, min_amplitude=0.1)[source]

KBK method to extract Skin Conductivity Responses (SCR) from an EDA signal.

Follows the approach by Kim et al. [KiBK04].

Parameters:
  • signal (array) – Input filtered EDA signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • min_amplitude (float, optional) – Minimum threshold by which to exclude SCRs.

Returns:

  • onsets (array) – Indices of the SCR onsets.

  • peaks (array) – Indices of the SCR peaks.

  • amplitudes (array) – SCR pulse amplitudes.

References

[KiBK04]

K.H. Kim, S.W. Bang, and S.R. Kim, “Emotion recognition system using short-term monitoring of physiological signals”, Med. Biol. Eng. Comput., vol. 42, pp. 419-427, 2004

biosppy.signals.eda.rec_times(signal=None, sampling_rate=1000.0, onsets=None, peaks=None)[source]

Returns EDA recovery times.

Parameters:
  • signal (array) – Input signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • onsets (array) – Indices of the SCR onsets.

  • peaks (array) – Indices of the SCR peaks.

Returns:

  • half_rec (list) – Half Recovery times, i.e. time between peak and 50% amplitude.

  • six_rec (list) – 63 % recovery times, i.e. time between peak and 63% amplitude.