Skip to content
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

Merged
merged 10 commits into from Sep 29, 2021
Merged

Add Riemannian Potato Field #142

merged 10 commits into from Sep 29, 2021

Conversation

qbarthelemy
Copy link
Member

@qbarthelemy qbarthelemy commented Sep 22, 2021

This PR:

  • adds the class PotatoField,
  • adds an animated example in the gallery, on artifact detection by Riemannian Potato Field , compared with Riemannian Potato.

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.

# -----------------------
#
# Riemannian potato field (RPF) [1]_ combines several potatoes of low dimension
# , each one being designed to capture specific artifact typically affecting
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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

Comment on lines 262 to 264
###############################################################################

# Plot online detection (a dynamic display is required)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
###############################################################################
# Plot online detection (a dynamic display is required)
###############################################################################
# Plot online detection (a dynamic display is required)

Comment on lines +502 to +503
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin):
class PotatoField(BaseEstimator, TransformerMixin, ClassifierMixin):


Returns
-------
z : ndarray, shape (n_potatoes, n_trials)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
z : ndarray, shape (n_potatoes, n_trials)
z : ndarray, shape (n_trials, n_potatoes)

would be more natural

@@ -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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_PotatoField_fit(get_covmats):
def test_potato_field_fit(get_covmats):

pf.fit([covmats1, covmats2[:1]])


def test_PotatoField_partialfit(get_covmats):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_PotatoField_partialfit(get_covmats):
def test_potato_field_partial_fit(get_covmats):

pf.partial_fit([covmats1, covmats2[:1]])


def test_PotatoField_transform(get_covmats):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_PotatoField_transform(get_covmats):
def test_potato_field_transform(get_covmats):

pf.transform([covmats1, covmats2[:1]])


def test_PotatoField_predictproba(get_covmats):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
axp.set(ylabel='RPF probability of being clean')
axp.set(ylabel='RPF probability of clean EEG')

pyriemann/clustering.py Outdated Show resolved Hide resolved
Comment on lines 607 to 609
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.
Copy link
Member

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 Show resolved Hide resolved
pyriemann/clustering.py Outdated Show resolved Hide resolved
pyriemann/clustering.py Outdated Show resolved Hide resolved
pyriemann/clustering.py Outdated Show resolved Hide resolved
Comment on lines 517 to 518
p_threshold : float (default 0.01)
Threshold on probability to being clean, in (0, 1).
Copy link
Member

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?

Copy link
Member Author

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.

qbarthelemy and others added 2 commits September 29, 2021 18:30
Co-authored-by: Pedro L. C. Rodrigues <pedro.rodrigues01@gmail.com>
@qbarthelemy qbarthelemy merged commit b35873b into pyRiemann:master Sep 29, 2021
@qbarthelemy
Copy link
Member Author

qbarthelemy commented Oct 1, 2021

Yes, it's normal: since it is an online processing, a dynamic display is required.
In you want to see the animation, run the example from a shell.

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) .
Your ideas are welcome!

agramfort added a commit that referenced this pull request Oct 19, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants