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

[ENH] Add support for AAHC clustering #92

Merged
merged 25 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
03e061e
implemented Atomize and Agglomerate Hierachical Clustering (AAHL)
Oct 25, 2022
192f75e
- added AAHC to sphinx documentation
Oct 28, 2022
c67f3a8
aahc: changed initialization of first PC to weighted sum of old and n…
Oct 28, 2022
66aaded
Update pycrostates/cluster/__init__.py
rkobler Oct 31, 2022
6074a7f
Update doc in pycrostates/cluster/aahc.py
rkobler Oct 31, 2022
62dc4a1
Update doc in pycrostates/cluster/aahc.py
rkobler Oct 31, 2022
7c69bf8
Update doc in pycrostates/cluster/aahc.py
rkobler Oct 31, 2022
a3f7afc
- BUGFIX in pycrostates/cluster/aahc.py:
Nov 1, 2022
1161e8e
Updates in pycrostates.cluster.[kmeans|aahc].py
Nov 1, 2022
29fa0e5
Update in pycrostates/cluster/aahc.py
Nov 1, 2022
814a949
updated changelog
Nov 1, 2022
352cf1d
resolve merge conflicts
mscheltienne Nov 1, 2022
869017b
fixed sphinx warning in doc/source/dev/changes/ratest.rst
Nov 1, 2022
f5e5e4e
fixed AAHC related pylint and pydoc warnings
Nov 1, 2022
149e1ee
fixed some more linting warnings
Nov 2, 2022
6ecd666
Changed AAHCluster interface
Nov 2, 2022
29c1d64
Changes in clustering interfaces
Nov 4, 2022
06bff24
Update pycrostates/cluster/tests/test_aahc.py
rkobler Nov 4, 2022
8b12166
Update pycrostates/cluster/tests/test_aahc.py
rkobler Nov 4, 2022
7489d0b
Update pycrostates/cluster/tests/test_aahc.py
rkobler Nov 4, 2022
dcf7252
Changes in pycrostats/cluster/tests/test_aahc.py
Nov 4, 2022
920b578
remove duplicate docstrings
mscheltienne Nov 4, 2022
d628ee4
Remove n_jobs from _BaseCluster.fit
vferat Nov 4, 2022
f6a74f7
Fix style
vferat Nov 4, 2022
aa4ef4d
fix docstring
mscheltienne Nov 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ @article{MICHEL2018577
year = {2018}
}

@article{Murray2008,
author = {Murray, Micah M. and Brunet, Denis and Michel, Christoph M.},
doi = {10.1007/s10548-008-0054-5},
journal = {Brain Topography},
number = {4},
pages = {249--264},
title = {Topographic {ERP} {Analyses}: {A} {Step}-by-{Step} {Tutorial} {Review}},
volume = {20},
year = {2008}
}

@inproceedings{Roweis1997,
author = {Roweis, Sam},
booktitle = {Advances in Neural Information Processing Systems},
editor = {M. Jordan and M. Kearns and S. Solla},
publisher = {MIT Press},
title = {EM Algorithms for PCA and SPCA},
url = {https://proceedings.neurips.cc/paper/1997/file/d9731321ef4e063ebbee79298fa36f56-Paper.pdf},
volume = {10},
year = {1997}
}

@article{Silhouettes,
author = {Peter J. Rousseeuw},
doi = {10.1016/0377-0427(87)90125-7},
Expand Down
1 change: 1 addition & 0 deletions docs/source/api/cluster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Cluster
:toctree: generated/

ModKMeans
AAHCluster
1 change: 1 addition & 0 deletions docs/source/dev/changes/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Current 0.3.0.dev
Enhancements
~~~~~~~~~~~~
- Improve changelog. (:pr:`86` by `Victor Férat`_)
- Support for AAHC clustering (:pr:`92` by `Reinmar Kobler`_)

Bugs
~~~~
Expand Down
2 changes: 2 additions & 0 deletions docs/source/dev/changes/names.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _Victor Férat: https://github.com/vferat

.. _Mathieu Scheltienne: https://github.com/mscheltienne

.. _Reinmar Kobler: https://github.com/rkobler
3 changes: 2 additions & 1 deletion pycrostates/cluster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:class:`~pycrostates.segmentation.EpochsSegmentation` depending on the dataset
to segment."""

from .aahc import AAHCluster # noqa: F401
from .kmeans import ModKMeans # noqa: F401

__all__ = ("ModKMeans",)
__all__ = ("ModKMeans", "AAHCluster")
14 changes: 8 additions & 6 deletions pycrostates/cluster/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
from ..segmentation import EpochsSegmentation, RawSegmentation
from ..utils import _corr_vectors
from ..utils._checks import (
_check_n_jobs,
_check_picks_uniqueness,
_check_reject_by_annotation,
_check_tmin_tmax,
_check_type,
_check_value,
)
from ..utils._docs import fill_doc
from ..utils._logs import logger, verbose
from ..utils._logs import _set_verbose, logger
from ..utils._logs import verbose as verbose_decorator
from ..utils.mixin import ChannelsMixin, ContainsMixin, MontageMixin
from ..viz import plot_cluster_centers

Expand Down Expand Up @@ -192,7 +192,8 @@ def fit(
tmin: Optional[Union[int, float]] = None,
tmax: Optional[Union[int, float]] = None,
reject_by_annotation: bool = True,
n_jobs: int = 1,
*,
verbose: Optional[str] = None,
) -> NDArray[float]:
"""Compute cluster centers.

Expand All @@ -213,12 +214,13 @@ def fit(
%(tmin_raw)s
%(tmax_raw)s
%(reject_by_annotation_raw)s
%(n_jobs)s
%(verbose)s
"""
from ..io import ChData, ChInfo

_set_verbose(verbose)

self._check_unfitted()
n_jobs = _check_n_jobs(n_jobs)
_check_type(inst, (BaseRaw, BaseEpochs, ChData), item_name="inst")
if isinstance(inst, (BaseRaw, BaseEpochs)):
tmin, tmax = _check_tmin_tmax(inst, tmin, tmax)
Expand Down Expand Up @@ -554,7 +556,7 @@ def save(self, fname: Union[str, Path]):
self._check_fit()
_check_type(fname, ("path-like",), "fname")

@verbose
@verbose_decorator
def predict(
self,
inst: Union[BaseRaw, BaseEpochs],
Expand Down
Loading