New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Riemannian Potato Field #142
Conversation
# ----------------------- | ||
# | ||
# Riemannian potato field (RPF) [1]_ combines several potatoes of low dimension | ||
# , each one being designed to capture specific artifact typically affecting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breaking , here is weird
Online Artifact Detection with Riemannian Potato Field | ||
=============================================================================== | ||
|
||
Example of Riemannian Potato Field [1]_ applied on EEG time-series to detect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of Riemannian Potato Field [1]_ applied on EEG time-series to detect | |
Example of Riemannian Potato Field (RPF) [1]_ applied on EEG time-series to detect |
as you use the acronym below
# | ||
# Detect artifacts/outliers on test set, with an animation to imitate an online | ||
# acquisition, processing and artifact detection of EEG time-series. | ||
# Remak that all these potatoes are semi-dynamic: they are updated when EEG is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Remak that all these potatoes are semi-dynamic: they are updated when EEG is | |
# Remark that all these potatoes are semi-dynamic: they are updated when EEG is |
############################################################################### | ||
|
||
# Plot online detection (a dynamic display is required) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
############################################################################### | |
# Plot online detection (a dynamic display is required) | |
############################################################################### | |
# Plot online detection (a dynamic display is required) |
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin): | |
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin): |
pyriemann/clustering.py
Outdated
|
||
Returns | ||
------- | ||
z : ndarray, shape (n_potatoes, n_trials) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
z : ndarray, shape (n_potatoes, n_trials) | |
z : ndarray, shape (n_trials, n_potatoes) |
would be more natural
tests/test_clustering.py
Outdated
@@ -221,3 +260,57 @@ def test_Potato_specific_labels(get_covmats): | |||
assert_array_equal(np.unique(pt.predict(covmats)), [2, 7]) | |||
# fit with custom positive label | |||
pt.fit(covmats, y=[2] * n_trials) | |||
|
|||
|
|||
def test_PotatoField_fit(get_covmats): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_PotatoField_fit(get_covmats): | |
def test_potato_field_fit(get_covmats): |
tests/test_clustering.py
Outdated
pf.fit([covmats1, covmats2[:1]]) | ||
|
||
|
||
def test_PotatoField_partialfit(get_covmats): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_PotatoField_partialfit(get_covmats): | |
def test_potato_field_partial_fit(get_covmats): |
tests/test_clustering.py
Outdated
pf.partial_fit([covmats1, covmats2[:1]]) | ||
|
||
|
||
def test_PotatoField_transform(get_covmats): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_PotatoField_transform(get_covmats): | |
def test_potato_field_transform(get_covmats): |
tests/test_clustering.py
Outdated
pf.transform([covmats1, covmats2[:1]]) | ||
|
||
|
||
def test_PotatoField_predictproba(get_covmats): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_PotatoField_predictproba(get_covmats): | |
def test_potato_field_predict_proba(get_covmats): |
ax[1].set_ylim([-1.5, 8.5]) | ||
ax[1].legend(loc='upper left') | ||
axp = ax[1].twinx() | ||
axp.set(ylabel='RPF probability of being clean') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axp.set(ylabel='RPF probability of being clean') | |
axp.set(ylabel='RPF probability of clean EEG') |
pyriemann/clustering.py
Outdated
X : list of n_potatoes ndarray of shape (n_trials, n_channels, | ||
n_channels), with same n_trials but different n_channels | ||
list of ndarray of SPD matrices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
pyriemann/clustering.py
Outdated
p_threshold : float (default 0.01) | ||
Threshold on probability to being clean, in (0, 1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you be more precise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I complete the doc.
Co-authored-by: Pedro L. C. Rodrigues <pedro.rodrigues01@gmail.com>
Hi @qbarthelemy, one of the figures is empty in the docs : Is that normal? |
Yes, it's normal: since it is an online processing, a dynamic display is required. That being said, I have tried to plot the animation in the html documentation, but I have not found the way to do not display it twice. See #133 (comment) . |
* adding the sampling.py feature and two examples related to it * cleaning up * correcting pep8 issues * getting rid of the tqdm dependency * Update examples/sampling/plot_riemannian_gaussian.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Remove ignored files * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/datasets.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_riemannian_gaussian.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * taking into account agramfort and qbarthelemy comments * more updates * adding make_outliers function * putting make_* functions into simulated.py for consistency * including corrections and comments * ... * further corrections * ... * flake8 * adding a few tests * flake8 * including reviews; adding a new test * ... * adding warnings * trying to edit API.rst * Add Riemannian Potato Field (#142) * add PotatoField and improve Potato * add example on PotatoField and clean example on Potato * add tests and complete api * minor corrections * minor modifs * commit suggestions * complete doc * complete doc again * Apply suggestions from code review Co-authored-by: Pedro L. C. Rodrigues <pedro.rodrigues01@gmail.com> * complete doc Co-authored-by: Pedro L. C. Rodrigues <pedro.rodrigues01@gmail.com> * remove class templates in api.rst for new functionns * adding things to whatsnew.rst * ... * adding the sampling.py feature and two examples related to it * cleaning up * correcting pep8 issues * getting rid of the tqdm dependency * Update examples/sampling/plot_riemannian_gaussian.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Remove ignored files * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_toy_classification.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/datasets.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/sampling/plot_riemannian_gaussian.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * Update pyriemann/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com> * taking into account agramfort and qbarthelemy comments * more updates * adding make_outliers function * putting make_* functions into simulated.py for consistency * including corrections and comments * ... * further corrections * ... * flake8 * adding a few tests * flake8 * including reviews; adding a new test * ... * adding warnings * trying to edit API.rst * remove class templates in api.rst for new functionns * adding things to whatsnew.rst * ... * adding ValueError tests * solving problem coming from conftest.py * ... * ... * trying to make tests pass? * flake8 * re-add init file * move is_* functions into pyriemann to be reused by pyriemann methods * remove pytest import from utils.test * re-add tests for raise errors * refactor test * revert changes on doc/conf.py * complete tests * updating api.rst * fix whatsnew.rst * Update doc/whatsnew.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com>
This PR:
PotatoField
,Q. Barthélemy, L. Mayaud, D. Ojeda, M. Congedo, "The Riemannian potato field: a tool for online signal quality index of EEG", IEEE TNSRE, 2019, link to pdf.