pyriemann.spatialfilters.BilinearFilter

class pyriemann.spatialfilters.BilinearFilter(filters, log=False)

Bilinear spatial filter.

Bilinear spatial filter for SPD matrices allows to define a custom spatial filter \(\mathbf{V}\) for bilinear projection of each covariance matrix \(\mathbf{X}_i\):

\[\mathbf{Xf}_i = \mathbf{V} \mathbf{X}_i \mathbf{V}^T\]

If log parameter is set to true, will return the log of the diagonal:

\[\mathbf{xf}_i = \log ( \mathrm{diag} (\mathbf{Xf}_i) )\]
Parameters:
filtersndarray, shape (n_filters, n_channels)

The filters for bilinear transform.

logbool, default=False

If true, return the log variance, otherwise return the spatially filtered covariance matrices.

Attributes:
filters_ndarray, shape (n_filters, n_channels)

If fit, the filter components used to decompose the data for each event type, concatenated.

__init__(filters, log=False)

Init.

fit(X, y)

Train BilinearFilter spatial filters.

Parameters:
Xndarray, shape (n_trials, n_channels, n_channels)

Set of covariance matrices.

yndarray, shape (n_trials,)

Labels for each trial.

Returns:
selfBilinearFilter instance

The BilinearFilter instance.

fit_transform(X, y)

Fit and transform in a single function.

Parameters:
Xndarray, shape (n_trials, n_channels, n_channels)

Set of covariance matrices.

yndarray, shape (n_trials,)

Labels for each trial.

Returns:
X_newndarray, shape (n_trials, n_filters) or ndarray, shape (n_trials, n_filters, n_filters)

Set of spatially filtered log-variance or covariance, depending on the log input parameter.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_output(*, transform=None)

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X)

Apply spatial filters.

Parameters:
Xndarray, shape (n_trials, n_channels, n_channels)

Set of covariance matrices.

Returns:
X_newndarray, shape (n_trials, n_filters) or ndarray, shape (n_trials, n_filters, n_filters)

Set of spatially filtered log-variance or covariance, depending on the log input parameter.

Examples using pyriemann.spatialfilters.BilinearFilter

Ensemble learning on functional connectivity

Ensemble learning on functional connectivity

One-way Manova

One-way Manova