eegdash.features.feature_bank.signal#

Signal-Level Feature Extraction#

This module provides temporal and statistical features computed directly from time-series data.

Data Shape Convention#

This module follows a Time-Last convention:

  • Input: (..., time)

  • Output: (...,)

All functions collapse the last dimension (time), returning an ndarray of features corresponding to the leading dimensions (e.g., subjects, channels).

Module Attributes

signal_hjorth_activity(x, /, **kwargs)

Calculate the Hjorth Activity of the signal.

Functions

signal_hilbert_preprocessor(x, /)

Compute the amplitude envelope of the analytic signal.

signal_filter_preprocessor(x, /, *, ...[, ...])

Linear-phase FIR band-pass filter.

signal_decorrelation_time(x, /, *, _metadata)

Calculate the Decorrelation Time of the signal.

signal_hjorth_activity(x, /, **kwargs)

Calculate the Hjorth Activity of the signal.

signal_hjorth_complexity(x, /)

Calculate the Hjorth Complexity of the signal.

signal_hjorth_mobility(x, /)

Calculate the Hjorth Mobility of the signal.

signal_kurtosis(x, /, **kwargs)

Compute the temporal kurtosis of the signal.

signal_line_length(x, /)

Calculate the Mean Signal Line Length.

signal_mean(x, /)

Compute the temporal mean of the signal.

signal_peak_to_peak(x, /, **kwargs)

Calculate the peak-to-peak (maximum range) of the signal.

signal_quantile(x, /[, q])

Compute the q-th quantile of the signal.

signal_root_mean_square(x, /)

Calculate the Root Mean Square (RMS) magnitude.

signal_skewness(x, /, **kwargs)

Compute the temporal skewness of the signal.

signal_std(x, /, **kwargs)

Compute the temporal standard deviation of the signal.

signal_variance(x, /, **kwargs)

Compute the temporal variance of the signal.

signal_zero_crossings(x, /[, threshold])

Count the number of times the signal crosses the zero axis.

eegdash.features.feature_bank.signal.signal_hilbert_preprocessor(x, /)[source]

Compute the amplitude envelope of the analytic signal.

Parameters:

x (ndarray) – Input signal

Returns:

The signal envelope, with the same shape as the input.

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_filter_preprocessor(x, /, *, _metadata, f_min, f_max, num_taps=None)[source]

Linear-phase FIR band-pass filter.

Parameters:
  • x (ndarray) – Input signal

  • f_min (float) – Low cutoff frequency (Hz)

  • f_max (float) – High cutoff frequency (Hz)

  • num_taps (int) – Number of filter taps (must be odd for exact linear phase)

Returns:

The band-pass filtered signal, with the same shape as the input.

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_decorrelation_time(x, /, *, _metadata)[source]

Calculate the Decorrelation Time of the signal.

This function computes the time it takes for the signal to decorrelate, defined as the first time lag where the autocorrelation function drops to zero.

Parameters:

x (ndarray) – The input signal.

Returns:

The time (in seconds or samples) until the signal decorrelates. Shape is x.shape[:-1].

Return type:

ndarray

Notes

This function uses the Wiener-Khinchin Theorem to compute the autocorrelation via the inverse FFT of the power spectrum.

eegdash.features.feature_bank.signal.signal_hjorth_activity(x, /, **kwargs)[source]

Calculate the Hjorth Activity of the signal.

Activity is defined as the variance of the signal itself.

Parameters:

x (ndarray) – The input signal.

Returns:

The Hjorth Activity value. Shape is x.shape[:-1].

Return type:

ndarray

Notes

The activity is calculated using the following formula:

\[\text{Activity}\left(x\left(t\right)\right) = \operatorname{Var}\left(x\left(t\right)\right)\]

References

  • Hjorth, B. (1970). EEG analysis based on time domain properties. Electroencephalography and Clinical Neurophysiology, 29(3), 306-310.

for more details, see the Wikipedia entry.

eegdash.features.feature_bank.signal.signal_hjorth_complexity(x, /)[source]

Calculate the Hjorth Complexity of the signal.

Complexity represents the change in frequency. The parameter compares the signal’s similarity to a pure sine wave, where value of 1 indicates a perfect sine wave.

Parameters:

x (ndarray) – The input signal.

Returns:

The complexity value. Shape is x.shape[:-1].

Return type:

ndarray

See also

signal_hjorth_mobility

Notes

The complexity is calculated using the following formula:

\[\text{Complexity}\left(x\left(t\right)\right) = \frac{\text{Mobility}\left(\frac{\mathrm{d}x\left(t\right)}{\mathrm{dt}}\right)}{\text{Mobility}\left(x\left(t\right)\right)}\]

References

  • Hjorth, B. (1970). EEG analysis based on time domain properties. Electroencephalography and Clinical Neurophysiology, 29(3), 306-310.

For more details, see the Wikipedia entry.

eegdash.features.feature_bank.signal.signal_hjorth_mobility(x, /)[source]

Calculate the Hjorth Mobility of the signal.

Mobility is defined as the standard deviation of the signal’s first derivative normalized by the standard deviation of the signal itself.

Parameters:

x (ndarray) – The input signal.

Returns:

The Hjorth Mobility value. Shape is x.shape[:-1].

Return type:

ndarray

See also

signal_hjorth_activity

Notes

The mobility is calculated using the following formula:

\[\text{Mobility}\left(x\left(t\right)\right) = \sqrt{\frac{\text{Var}\left(\frac{\mathrm{d}x\left(t\right)}{\mathrm{dt}}\right)}{\text{Var}\left(x\left(t\right)\right)}}\]

References

  • Hjorth, B. (1970). EEG analysis based on time domain properties. Electroencephalography and Clinical Neurophysiology, 29(3), 306-310.

for more details, see the Wikipedia entry.

eegdash.features.feature_bank.signal.signal_kurtosis(x, /, **kwargs)[source]

Compute the temporal kurtosis of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • **kwargs (dict) – Additional keyword arguments passed to scipy.stats.kurtosis().

Returns:

The kurtosis of the signal along the temporal axis. Shape is x.shape[:-1]

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_line_length(x, /)[source]

Calculate the Mean Signal Line Length.

Parameters:

x (ndarray) – The input signal.

Returns:

The mean absolute vertical distance between consecutive samples. Shape is x.shape[:-1].

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_mean(x, /)[source]

Compute the temporal mean of the signal.

Parameters:

x (ndarray) – The input signal.

Returns:

The mean of the signal along the temporal axis. Shape is x.shape[:-1].

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_peak_to_peak(x, /, **kwargs)[source]

Calculate the peak-to-peak (maximum range) of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • **kwargs (dict) – Additional keyword arguments passed to numpy.ptp().

Returns:

The peak-to-peak amplitude. Shape is x.shape[:-1].

Return type:

ndarray

Notes

This function wraps numpy.ptp(); see the NumPy documentation for details on additional keyword arguments.

For a theoretical overview of Peak-To-Peak amplitude in signal analysis, see the Wikipedia entry.

eegdash.features.feature_bank.signal.signal_quantile(x, /, q: Number = 0.5, **kwargs)[source]

Compute the q-th quantile of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • q (float or array_like, optional) – The quantile to compute. 0.5 (default) is the median.

  • **kwargs (dict) – Additional keyword arguments passed to numpy.quantile().

Returns:

The quantile values. Shape is x.shape[:-1].

Return type:

ndarray

Notes

This function wraps numpy.quantile(); see the NumPy documentation for details on additional keyword arguments.

eegdash.features.feature_bank.signal.signal_root_mean_square(x, /)[source]

Calculate the Root Mean Square (RMS) magnitude.

Parameters:

x (ndarray) – The input signal.

Returns:

The RMS amplitude of the signal. Shape is x.shape[:-1]

Return type:

ndarray

Notes

For the RMS definition, see the Wikipedia entry.

eegdash.features.feature_bank.signal.signal_skewness(x, /, **kwargs)[source]

Compute the temporal skewness of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • **kwargs (dict) – Additional keyword arguments passed to scipy.stats.skew().

Returns:

The skewness of the signal along the temporal axis. Shape is x.shape[:-1].

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_std(x, /, **kwargs)[source]

Compute the temporal standard deviation of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • **kwargs (dict) – Additional keyword arguments passed to np.std().

Returns:

The standard deviation of the signal along the temporal axis. Shape is x.shape[:-1].

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_variance(x, /, **kwargs)[source]

Compute the temporal variance of the signal.

Parameters:
  • x (ndarray) – The input signal.

  • **kwargs (dict) – Additional keyword arguments passed to np.var().

Returns:

The variance of the signal along the temporal axis. Shape is x.shape[:-1].

Return type:

ndarray

eegdash.features.feature_bank.signal.signal_zero_crossings(x, /, threshold=1e-15)[source]

Count the number of times the signal crosses the zero axis.

This function identifies points where the signal changes sign or enters/leaves a defined noise floor (threshold).

Parameters:
  • x (ndarray) – The input signal.

  • threshold (float, optional) – A small epsilon value to treat values near zero as exactly zero, preventing false counts due to floating-point noise.

Returns:

The count of zero crossings. Shape is x.shape[:-1].

Return type:

ndarray

Notes

For a theoretical overview of zero-crossing rate in signal analysis, see the Wikipedia entry.