pyeeg.io.WordLevelFeatures.align_word_features

WordLevelFeatures.align_word_features(srate, wordonset_feature=True, features=('surprisal',), zscore_fun=None, custom_wordfeats=None)

Check that we have the correct number of elements for each features Will output a time series with spike for each word features at times from self.wordonsets. The duration of the output signal is determined from self.duration. Sampling rate needs to be given as a parameter to be able to create the spike time-series.

Parameters:
  • srate (float) – Sampling rate at which to compute spike-like features

  • wordonset_feature (boolean) – Whether to use word onset (always “on” feature) in the feature array (Default: True).

  • features (list) – List of feature names to be used. These feature name must correspond to an attribute of the WordLevelFeatures class.

  • zscore_fun (function or sklearn.preprocessing.StandardScaler-like instance) – Whether to scale and center the word feature values before assigning them to onset sample-time. If method (function) is given, will simply apply the function to the data on the fly. If StandardScaler-like instance is given, then we assume the object has been fitted beforehand to the data and contains mean and variance, thus will use the ‘transform’ method of the instance to scale data. If None, leave as it is. (Default: None)

  • custom_wordfeats (ndarray-like (nfeat x nwords)) – Other word-level features that are not embeded in the class instance. The only requirement is that the number of words must be the same as for the list of word onsets.

Returns:

feat – Array of spikes, with the word feature value at word onsets. ntimes ~ speech_duration * srate

Return type:

ndarray (ntimes, nfeat)

Raises:

AssertionError – If the duration of speech part has not been extracted or if custom word features have wrong length.