edatools

eda_filter

filter_eda(sig, sampling_rate, method='neurokit')[source]

Filters EDA signal using predefined filter parameters.

Parameters:
  • sig (ArrayLike) – EDA signal.

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

  • method (str, optional) – Filtering method. It can be ‘neurokit’ or ‘biosppy’. Defaults to ‘neurokit’.

Raises:

Exception – If the method is not implemented.

Returns:

Filtered EDA signal.

Return type:

ArrayLike

eda_decompose

eda_decompose(eda_signal, sampling_rate, method='highpass')[source]

Decomposes EDA signal into tonic and phasic components.

Parameters:
  • eda_signal (ArrayLike) – EDA signal.

  • sampling_rate (float) – Sampling rate of EDA signal (Hz).

  • method (str, optional) – Method to be used for decomposition. Defaults to “highpass”.

Raises:
  • ValueError – If sampling rate is not greater than 0.

  • Exception – If method is not implemented.

Returns:

A dataframe composed of Phasic and Tonic components of EDA signal

Return type:

pd.DataFrame

eda_features

from_decomposed(signal_phasic, signal_tonic, sampling_rate)[source]

Calculates features over Tonic and Phasic EDA components

Parameters:
  • signal_phasic (ArrayLike) – Phasic component of EDA signal.

  • signal_tonic (ArrayLike) – Tonic component of EDA signal.

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

Returns:

Dictionary of calculated features.

Return type:

dict

from_decomposed_windows(phasic_windows, tonic_windows, sampling_rate, parallel=False, n_jobs=6)[source]

Calculates EDA features over set of decomposed EDA signals.

Parameters:
  • phasic_windows (ArrayLike) – Set of phasic eda signals

  • tonic_windows (ArrayLike) – Set of tonic eda signals

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

  • parallel (bool, optional) – Whether to process parallely. Defaults to False.

  • n_jobs (int, optional) – Number of jobs used in parallel processing. Defaults to 6.

Returns:

EDA features of given windows

Return type:

pd.DataFrame

from_scl(signal)[source]

Calculates features over Tonic EDA signal.

Parameters:

signal (ArrayLike) – Tonic component of EDA signal.

Returns:

SCL features over Tonic EDA signal.

Return type:

dict

from_scr(signal)[source]

Calculates features over Phasic EDA signal.

Parameters:

signal (ArrayLike) – Phasic component of EDA signal.

Returns:

SCR features over Phasic EDA signal.

Return type:

dict

from_signal(signal, sampling_rate=20.0)[source]

Calculates features over EDA signal.

Parameters:
  • signal (ArrayLike) – EDA signal.

  • sampling_rate (float, optional) – Sampling rate of the EDA signal (Hz). Defaults to 20.0 Hz.

Returns:

Dictionary of calculated features.

Return type:

dict

from_windows(eda_windows, sampling_rate=20.0, parallel=False, n_jobs=6)[source]

Calculates EDA features over set of EDA signals.

Parameters:
  • eda_windows (ArrayLike) – Set of EDA signals (Windows).

  • sampling_rate (float, optional) – Sampling rate of the EDA signals (Hz). Defaults to 20.0 Hz.

  • parallel (bool, optional) – Whether to process parallely. Defaults to False.

  • n_jobs (int, optional) – Number of jobs used in parallel processing. Defaults to 6.

Returns:

EDA features of given windows.

Return type:

pd.DataFrame

eda_freqdomain

eda_freq_features(sig, prefix='eda')[source]

Calculates frequency-domain EDA features.

f1sc: Spectral power in the range of 0.1 to 0.2 Hz. f2sc: Spectral power in the range of 0.2 to 0.3 Hz. f3sc: Spectral power in the range of 0.3 to 0.4 Hz. Energy: Sum of the signal power Entropy: S sum of the power in the signal times the log of the power in the signal max_freq: Frequency corresponding to highest power in the signal

Reference: Zangróniz, R., Martínez-Rodrigo, A., Pastor, J.M., López, M.T. and Fernández-Caballero, A., 2017. Electrodermal activity sensor for classification of calm/distress condition. Sensors, 17(10), p.2324.

Parameters:
  • sig (ArrayLike) – EDA signal.

  • prefix (str, optional) – Prefix for the feature. Defaults to “eda”.

Returns:

Dictionary of calculated features.

Return type:

dict

eda_hjorth

eda_hjorth_features(sig, prefix='eda')[source]

Calculates Hjörth features for the EDA signal. For more details, see the https://en.wikipedia.org/wiki/Hjorth_parameters .

Parameters:
  • signal (ArrayLike) – EDA signal.

  • prefix (str, optional) – Prefix for the features. Defaults to “eda”.

  • sig (_SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) –

Returns:

Dictionary of calculated features.

Return type:

dict

eda_peaks

eda_detectpeaks(phasic_signal, sampling_rate)[source]

Detects peaks from phasic component of EDA signal.

Parameters:
  • phasic_signal (ArrayLike) – Phasic EDA signal.

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

Raises:

ValueError – If sampling rate is not greater than 0.

Returns:

Peak array, info

Return type:

Tuple

eda_plot

plot_eda(signals, peaks=None, sampling_rate=None, timestamps=None, timestamp_resolution=None, method='matplotlib', show_peaks=True, figsize=(18.5, 10.5), width=1050, height=600)[source]

Generates plots for EDA signal.

Parameters:
  • signals (dict) – The dictionary of signals to be plotted.

  • peaks (dict, optional) – The dictionary of peaks to be plotted. Defaults to None.

  • sampling_rate (float, optional) – Sampling rate of the signal. Defaults to None.

  • timestamps (ArrayLike, optional) – Timestamp array. Defaults to None.

  • timestamp_resolution (str, optional) – Timestamp resolution. Defaults to None.

  • method (str, optional) – Package to generate plots. It can be ‘matplotlib’ or ‘plotly’. Defaults to ‘matplotlib’.

  • show_peaks (bool, optional) – If True, peaks are plotted. Defaults to True.

  • figsize (tuple, optional) – Figure size for matplotlib. Defaults to (18.5, 10.5) inches.

  • width (float, optional) – Figure width for Plotly. Defaults to 800 pixels.

  • height (float, optional) – Figure height for Plotly. Defaults to 440 pixels.

Raises:
  • ValueError – If timestamps is not None and timestamp resolution is not provided.

  • ValueError – If timestamps array and EDA signal have different lengths.

  • ValueError – If method is not ‘matplotlib’ or ‘plotly’.

eda_signalfeatures

eda_signal_features(signal, prefix='signal')[source]

Calculates EDA features.

rms : Root mean square of the signal acr_length : Arc length of the signal integral : Integral of the signal average_power: Normalized average power of the signal

Parameters:
  • signal (ArrayLike) – EDA signal.

  • prefix (str, optional) – Prefix for the feature. Defaults to “eda”.

Returns:

Dictionary of calculated features.

Return type:

dict

get_feature_names()[source]

eda_statistical

eda_stat_features(signal, prefix='signal')[source]

Calculates statistical EDA features.

mean: Mean of the signal std: Standard deviation of the signal max: Maaximum value of the signal min: Minimum value of the signal range: Range of the signal kurtosis: Kurtosis of the signal skew: Skewness of the signal momentum: The second moment of the signal

Parameters:
  • signal (ArrayLike) – EDA signal.

  • prefix (str, optional) – Prefix for the feature. Defaults to “eda”.

Returns:

Dictionary of calculated features.

Return type:

dict

get_feature_names()[source]
eda_decompose(eda_signal, sampling_rate, method='highpass')[source]

Decomposes EDA signal into tonic and phasic components.

Parameters:
  • eda_signal (ArrayLike) – EDA signal.

  • sampling_rate (float) – Sampling rate of EDA signal (Hz).

  • method (str, optional) – Method to be used for decomposition. Defaults to “highpass”.

Raises:
  • ValueError – If sampling rate is not greater than 0.

  • Exception – If method is not implemented.

Returns:

A dataframe composed of Phasic and Tonic components of EDA signal

Return type:

pd.DataFrame

from_decomposed(signal_phasic, signal_tonic, sampling_rate)[source]

Calculates features over Tonic and Phasic EDA components

Parameters:
  • signal_phasic (ArrayLike) – Phasic component of EDA signal.

  • signal_tonic (ArrayLike) – Tonic component of EDA signal.

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

Returns:

Dictionary of calculated features.

Return type:

dict

from_decomposed_windows(phasic_windows, tonic_windows, sampling_rate, parallel=False, n_jobs=6)[source]

Calculates EDA features over set of decomposed EDA signals.

Parameters:
  • phasic_windows (ArrayLike) – Set of phasic eda signals

  • tonic_windows (ArrayLike) – Set of tonic eda signals

  • sampling_rate (float) – Sampling rate of the EDA signal (Hz).

  • parallel (bool, optional) – Whether to process parallely. Defaults to False.

  • n_jobs (int, optional) – Number of jobs used in parallel processing. Defaults to 6.

Returns:

EDA features of given windows

Return type:

pd.DataFrame

from_signal(signal, sampling_rate=20.0)[source]

Calculates features over EDA signal.

Parameters:
  • signal (ArrayLike) – EDA signal.

  • sampling_rate (float, optional) – Sampling rate of the EDA signal (Hz). Defaults to 20.0 Hz.

Returns:

Dictionary of calculated features.

Return type:

dict

from_windows(eda_windows, sampling_rate=20.0, parallel=False, n_jobs=6)[source]

Calculates EDA features over set of EDA signals.

Parameters:
  • eda_windows (ArrayLike) – Set of EDA signals (Windows).

  • sampling_rate (float, optional) – Sampling rate of the EDA signals (Hz). Defaults to 20.0 Hz.

  • parallel (bool, optional) – Whether to process parallely. Defaults to False.

  • n_jobs (int, optional) – Number of jobs used in parallel processing. Defaults to 6.

Returns:

EDA features of given windows.

Return type:

pd.DataFrame

get_feature_names()[source]