pyriemann.clustering.Potato¶
- class pyriemann.clustering.Potato(metric='riemann', threshold=3, n_iter_max=100, pos_label=1, neg_label=0)¶
Artefact detection with the Riemannian Potato.
The Riemannian Potato [1] is a clustering method used to detect artifact in EEG signals. The algorithm iteratively estimates the centroid of clean signal by rejecting every trial that is too far from it.
- Parameters
- metricstring, default=’riemann’
The type of metric used for centroid and distance estimation.
- thresholdfloat, default=3
Threshold on z-score of distance to reject artifacts. It is the number of standard deviations from the mean of distances to the centroid.
- n_iter_maxint, default=100
The maximum number of iteration to reach convergence.
- pos_labelint, default=1
The positive label corresponding to clean data.
- neg_labelint, default=0
The negative label corresponding to artifact data.
See also
Kmeans
MDM
Notes
New in version 0.2.3.
References
- 1
The Riemannian Potato: an automatic and adaptive artifact detection method for online experiments using Riemannian geometry A. Barachant, A Andreev, and M. Congedo. TOBI Workshop lV, Jan 2013, Sion, Switzerland. pp.19-20.
- 2
The Riemannian Potato Field: A Tool for Online Signal Quality Index of EEG Q. Barthélemy, L. Mayaud, D. Ojeda, and M. Congedo. IEEE Transactions on Neural Systems and Rehabilitation Engineering, IEEE Institute of Electrical and Electronics Engineers, 2019, 27 (2), pp.244-255
- Attributes
- covmean_ndarray, shape (n_channels, n_channels)
Centroid of potato.
- __init__(metric='riemann', threshold=3, n_iter_max=100, pos_label=1, neg_label=0)¶
Init.
- fit(X, y=None)¶
Fit the potato from covariance matrices.
Fit the potato from covariance matrices, with an iterative outlier removal to obtain a reliable potato.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- yNone | ndarray, shape (n_matrices,), default=None
Labels corresponding to each matrix: positive (resp. negative) label corresponds to a clean (resp. artifact) matrix. If None, all matrices are considered as clean.
- Returns
- selfPotato instance
The Potato instance.
- fit_transform(X, y=None, **fit_params)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters.
- Returns
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
- 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.
- partial_fit(X, y=None, alpha=0.1)¶
Partially fit the potato from covariance matrices.
This partial fit can be used to update dynamic or semi-dymanic online potatoes with clean EEG.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- yNone | ndarray, shape (n_matrices,), default=None
Labels corresponding to each matrix: positive (resp. negative) label corresponds to a clean (resp. artifact) matrix. If None, all matrices are considered as clean.
- alphafloat, default=0.1
Update rate in [0, 1] for the centroid, and mean and standard deviation of log-distances: 0 for no update, 1 for full update.
- Returns
- selfPotato instance
The Potato instance.
- predict(X)¶
Predict artefact from data.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- Returns
- predndarray of bool, shape (n_matrices,)
The artefact detection: True if the matrix is clean, and False if the matrix contain an artefact.
- predict_proba(X)¶
Return probability of belonging to the potato / being clean.
It is the probability to reject the null hypothesis “clean data”, computing the right-tailed probability from z-score.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- Returns
- probandarray, shape (n_matrices,)
Matrix is considered as normal/clean for high value of proba. It is considered as abnormal/artifacted for low value of proba.
- score(X, y, sample_weight=None)¶
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Test samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True labels for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns
- scorefloat
Mean accuracy of
self.predict(X)
wrt. y.
- 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)¶
Return the normalized log-distance to the centroid (z-score).
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- Returns
- zndarray, shape (n_matrices,)
the normalized log-distance to the centroid.