timeflux_rasr.estimators.blending


blending

class timeflux_rasr.estimators.blending.Blending(window_overlap=1, merge=False, windowing=None)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Smooths features temporally to avoid discontinuities by sine-cosine blending interpolation.

This estimator smooths features to avoid discontinuities by blending the redundant samples that has been transformed by different operations. Only samples with the exact same timestamp will be blended. Features with an unique timestamp will be left untouched. Therefore this function is useful only if the two following criteria are met: - there is an overlapping between the features of each consecutive observation - the features have been transformed by different operators or by an adaptive operator.

Parameters
  • window_overlap (int (default=1)) – Number of overlapping features that will be used for blending.

  • merge (bool (default=False)) – If set to True, the output will be a unique 2D matrix when all windows will be collapsed and overlapping samples merged. By default, each window will be blended with the previous window.

  • windowing (bool | None (default=None)) – If None or False, there is no interpolation for the first trial. If True, the first trial will be interpolate to zeros (sinus windowing).

Variables
  • n_channels (int) – The dimension managed by the fitted Blending, e.g. number of electrodes.`

  • last_window (ndarray, shape (Nt, Ne)) – The last window observed during the last call of transform. It will be blended with the first window.

fit(self, X, y=None)[source]
Parameters
  • X (ndarray, shape (n_trials, n_samples, n_channels)) – Training data.

  • y (ndarray, shape (n_trials,) | None, optional) – labels corresponding to each trial, not used (mentioned for sklearn comp)

Returns

self – the fitted Blending estimator.

Return type

Blending instance.

transform(self, X)[source]

Blend signals :param X: Data to clean, already filtered :type X: ndarray, shape (n_trials, n_samples, n_channels)

Returns

Xblended – Cleaned data

Return type

ndarray, shape (n_trials, n_samples, n_channels)

fit_transform(self, X, y=None)[source]
Parameters
  • X (ndarray, shape (n_trials, n_samples, n_channels)) – Training data.

  • y (ndarray, shape (n_trials,) | None, optional) – labels corresponding to each trial, not used (mentioned for sklearn comp)

Returns

X – blended data

Return type

ndarray, shape (n_trials, n_samples, n_channels)