pyeeg.features.AlignmentHandler.align_word_features

AlignmentHandler.align_word_features(word_features: Dict[int, Dict[str, float]], textgrid: TextGrid, signal_length: int | None = None) Tuple[ndarray, List[str]]

Align word-level features to signal time points.

Builds a sample-by-feature matrix where each row corresponds to one signal sample and each column to one feature. For every word interval, the feature values stored under the interval’s index in word_features are written into the rows covering that interval (in seconds) converted to sample indices at self.sampling_rate. Words without an entry in word_features are skipped and left as zeros. Feature columns are sorted alphabetically.

Parameters:
  • word_features (dict of int -> dict of str -> float) – Mapping from word index (position of the word interval in the word tier) to a dict of feature name -> value for that word.

  • textgrid (TextGrid) – TextGrid providing the word intervals, retrieved via TextGrid.get_word_intervals().

  • signal_length (int, optional) – Number of samples in the output. If None, derived from the TextGrid end time and the sampling rate: int(textgrid.end_time * self.sampling_rate).

Returns:

  • aligned_features (ndarray, shape (n_samples, n_features)) – Sample-level feature matrix. Rows are time points arange(signal_length) / self.sampling_rate; columns are the sorted feature names. Empty (shape (0,)) if no word intervals or no features were found.

  • feature_names (list of str) – Alphabetically sorted names of the aligned features, matching the columns of aligned_features. Empty if no features were found.