HHTFeatures

class eyefeatures.features.measures.HHTFeatures(max_imfs=-1, features=None, x=None, y=None, aoi=None, pk=None, return_df=True, ignore_errors=False)[source]

Bases: MeasureTransformer

Hilbert-Huang Transform (HHT) Features.

Decomposes the signal (scanpath coordinates) into Intrinsic Mode Functions (IMFs) using Empirical Mode Decomposition (EMD), then extracts statistical features from these IMFs. HHT is well-suited for analyzing non-linear, non-stationary signals.

Parameters:
  • max_imfs (int) – maximum number of intrinsic mode functions (IMFs) to extract. Set to -1 for automatic determination.

  • features (list[str]) – list of features to extract from each IMF. Available options are: ‘mean’, ‘std’, ‘var’, ‘median’, ‘max’, ‘min’, ‘skew’, ‘kurtosis’, ‘entropy’, ‘energy’, ‘dom_freq’.

  • x (str) – X coordinate column name.

  • y (str) – Y coordinate column name.

  • aoi (str) – Area Of Interest column name(-s).

  • pk (list[str]) – primary key.

  • return_df (bool) – whether to return output as DataFrame or numpy array.

  • ignore_errors (bool) – If True, return NaN when feature computation fails; otherwise raise.

Returns:

features extracted from each IMF of the HHT decomposition.

get_feature_names_out(input_features=None)[source]

Returns the names of the features generated by this transformer.

Return type:

list[str]

dominant_freq(imf_data)[source]

Calculates dominant frequency of the IMFs using FFT.

Parameters:

imf_data (ndarray) – intrinsic mode functions (IMFs) data

Returns:

dominant frequency of each IMF

Return type:

list[float]

coarse_grain(imf_data, scale=5)[source]

Calculates coarse-grained std of the IMFs.

Parameters:
  • imf_data (ndarray) – intrinsic mode functions (IMFs) data

  • scale (int)

Returns:

coarse-grained standard deviation of each IMF

Return type:

ndarray

sample_entropy(imf_data, m=1, r=0.2)[source]

Calculates sample entropy of the intrinsic mode functions (IMFs).

Parameters:
  • imf_data (ndarray) – intrinsic mode functions (IMFs) data

  • m (int) – length of sequences to compare

  • r (float) – tolerance for accepting mathces

Returns:

sample entropy of each IMF

Return type:

list[float]

complexity_index(imf_data, m=5, r=0.2, max_scale=2)[source]

Calculates complexity index of the intrinsic mode functions (IMFs).

Parameters:
  • imf_data (ndarray) – intrinsic mode functions (IMFs) data

  • m (int) – length of sequences for sample entropy

  • r (float) – tolerance for sample entropy

  • max_scale (int) – maximum scale for coarse-graining

Returns:

complexity index of each IMF

Return type:

list[float]

calculate_features(data)[source]

Feature extraction from the HHT.

Parameters:

data (DataFrame) – 1D array of the HHT signal

Returns:

list of features extracted from the HHT

Return type:

tuple[list[str], list[float]]