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

Outlier detection and robust estimation #22

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
e8f1628
fix edge case
MerlinDumeur Jun 27, 2023
b2d1182
Merge branch 'robust' of github.com:MerlinDumeur/pymultifracs into ro…
MerlinDumeur Jun 27, 2023
b6ab233
Prepared figures
MerlinDumeur Jun 27, 2023
f0cf3dc
Improved robust algorithm
MerlinDumeur Aug 8, 2023
839514b
Merge branch 'robust' of github.com:MerlinDumeur/pymultifracs into ro…
MerlinDumeur Sep 1, 2023
248b35f
fix edge case
MerlinDumeur Jun 27, 2023
9a23e56
Prepared figures
MerlinDumeur Jun 27, 2023
4e9a8a6
Improved robust algorithm
MerlinDumeur Aug 8, 2023
d3cf506
Merge branch 'robust' of github.com:MerlinDumeur/pymultifracs into ro…
MerlinDumeur Sep 1, 2023
9fe0cca
EURASIP modifs
MerlinDumeur Sep 9, 2023
b3aae5f
Tiny fix
MerlinDumeur Sep 11, 2023
29330cc
Added custom width of leader blocks + on the fly rejection of leaders
MerlinDumeur Oct 4, 2023
0ff3844
Fixed beta estimation
MerlinDumeur Oct 5, 2023
f707405
Fixing functions
MerlinDumeur Oct 17, 2023
48c30bf
fix edge case
MerlinDumeur Jun 27, 2023
f4007bd
Prepared figures
MerlinDumeur Jun 27, 2023
805b739
Improved robust algorithm
MerlinDumeur Aug 8, 2023
48723c9
fix edge case
MerlinDumeur Jun 27, 2023
7a3399c
Prepared figures
MerlinDumeur Jun 27, 2023
1c4b122
Improved robust algorithm
MerlinDumeur Aug 8, 2023
2eba38a
EURASIP modifs
MerlinDumeur Sep 9, 2023
f41cdb6
Tiny fix
MerlinDumeur Sep 11, 2023
da8c1af
Added custom width of leader blocks + on the fly rejection of leaders
MerlinDumeur Oct 4, 2023
de84045
Fixed beta estimation
MerlinDumeur Oct 5, 2023
8200a03
Fixing functions
MerlinDumeur Oct 17, 2023
b7c3444
Fixing tests
MerlinDumeur Oct 26, 2023
a11ab88
Merge
MerlinDumeur Oct 26, 2023
a785166
Prepared last method
MerlinDumeur Dec 4, 2023
b1d3f33
Fix cumulant plotting bug
MerlinDumeur Dec 19, 2023
bf2e05c
Fix PSD plotting function
MerlinDumeur Dec 21, 2023
d6f63c9
Fixed robust cumulant estimation
MerlinDumeur Jan 25, 2024
95b244e
Added multifractal spectra with rejected coefficients; individual gam…
MerlinDumeur Feb 23, 2024
6b39772
Plotting function allow shift in gamint
MerlinDumeur Feb 23, 2024
999fd63
plot improvement
MerlinDumeur Feb 29, 2024
51d094a
Pep8 improvement, doc, prepare robust
MerlinDumeur Mar 1, 2024
2ddc566
Fixed debugging
MerlinDumeur Mar 1, 2024
cf5a209
Fixing wavelet function
MerlinDumeur Mar 4, 2024
2b80d83
Faster cumulants
MerlinDumeur Mar 5, 2024
a74f943
Update doc
MerlinDumeur Mar 5, 2024
f0d6524
Fixed type linking
MerlinDumeur Mar 5, 2024
3430416
Modifying API
MerlinDumeur Mar 7, 2024
038475d
Progress on new API
MerlinDumeur Mar 18, 2024
2a5b168
API rework
MerlinDumeur Mar 21, 2024
1225ec1
API rework 2 -- not tested
MerlinDumeur Mar 22, 2024
e1efddb
Fix imports
MerlinDumeur Mar 22, 2024
3f58573
Fixing WT transform and plotting
MerlinDumeur Mar 25, 2024
8bd85d8
Fixed plotting and bootstrapping
MerlinDumeur Mar 26, 2024
8e869f0
Fixing tests
MerlinDumeur Mar 27, 2024
f2cea67
Fixed regression
MerlinDumeur Mar 28, 2024
6a04f8b
Started bivariate analysis
MerlinDumeur Apr 2, 2024
97e9f15
Bivariate sf WIP
MerlinDumeur Apr 2, 2024
df3bf43
Bivariate structure function done
MerlinDumeur Apr 3, 2024
5b73fe5
Restructure dataclasses, add bivariate structure plotting
MerlinDumeur Apr 3, 2024
24dd51a
Added bivariate cumulants
MerlinDumeur Apr 4, 2024
87bc901
Fixing cumulants
MerlinDumeur Apr 5, 2024
517ad58
Fixing cumulants
MerlinDumeur Apr 5, 2024
59d0227
Fixed bivariate -- passing tests
MerlinDumeur Apr 8, 2024
b866240
Bootstrap WIP
MerlinDumeur Apr 8, 2024
f41cdfb
Bootstrap WIP
MerlinDumeur Apr 9, 2024
db5b47e
Bootstrap WIP
MerlinDumeur Apr 9, 2024
4c9a422
Bootstrap test successful
MerlinDumeur Apr 9, 2024
91db93f
Last test fix
MerlinDumeur Apr 10, 2024
0fca2bb
Refresh doc
MerlinDumeur Apr 10, 2024
b54e531
Integrated robust estimation
MerlinDumeur Apr 11, 2024
2d142c4
Doc update, WT analysis fixed, added example notebook
MerlinDumeur Apr 12, 2024
6be815e
Trying to fix CI
MerlinDumeur Apr 12, 2024
9e96f8f
Fixed 3.10 compatibility
MerlinDumeur Apr 13, 2024
72d2319
Fixed CI error, conda -> mamba
MerlinDumeur Apr 14, 2024
6ed5150
Micromamba CI fix
MerlinDumeur Apr 14, 2024
ef96994
CI fix 2
MerlinDumeur Apr 14, 2024
761fddb
Fixing bootstrapping bug
MerlinDumeur Apr 19, 2024
1198bf2
Bootstrap demo notebook
MerlinDumeur May 13, 2024
ffb6513
Benchmarking code improvement
MerlinDumeur May 25, 2024
ecd4f5c
Fixing WT transform for outlier detection
MerlinDumeur May 27, 2024
5a6f9aa
Fixing plot function
MerlinDumeur May 28, 2024
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
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
Expand All @@ -39,39 +39,39 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.8"]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache conda
uses: actions/cache@v2
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('env.yml') }}
- name: Setup python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v2
# - name: Cache conda
# uses: actions/cache@v2
# env:
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key:
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
# hashFiles('env.yml') }}
- name: Setup python ${{ matrix.python-version }} with mamba
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: meta.yml
use-only-tar-bz2: true
activate-environment: pymultifracs
mamba-version: "*"
- name: Testing
run: |
conda install -c conda-forge pytest pytest-xdist pytest-cov
pip install -e .
mamba install numpy scipy pywavelets seaborn numba statsmodels pytest pytest-xdist pytest-cov tqdm joblib
pip install -e .[bootstrap,robust]
pytest -n auto -x --cov=./ --cov-report=xml
- name: Upload coverage
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
4 changes: 2 additions & 2 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
- name: Build doc
shell: bash -el {0}
run: |
conda install -c conda-forge pip sphinx numpydoc pydata-sphinx-theme
python -m pip install .
conda install -c conda-forge pip sphinx numpydoc pydata-sphinx-theme nbsphinx
python -m pip install .[doc]
cd doc
make html
touch _build/html/.nojekyll
Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ Implemented features:
* Computation of (1D) multiresolution quantities: wavelet coefficients, wavelet-leaders and p-leaders
* Computation of structure functions, cumulants and log-cumulants.
* Estimation of the multifractal spectrum.
* Bivariate multifractal analysis.
* Bootstrap-derived confidence intervals and automated scaling range selection.
* Outlier detection.


The code in this package is based on the Wavelet p-Leader and Bootstrap based MultiFractal analysis (PLBMF) `Matlab toolbox <http://www.ens-lyon.fr/PHYSIQUE/Equipe3/MultiFracs/software.html>`_ written by Patrice Abry, Herwig Wendt and colleagues. For a thorough introduction to multifractal analysis, you may access H. Wendt's PhD thesis available in `his webiste <https://www.irit.fr/~Herwig.Wendt/data/ThesisWendt.pdf)>`_.
The initial implementation of the code in this package was based on the Wavelet p-Leader and Bootstrap based MultiFractal analysis (PLBMF) `Matlab toolbox <http://www.ens-lyon.fr/PHYSIQUE/Equipe3/MultiFracs/software.html>`_ written by Patrice Abry, Herwig Wendt and colleagues. For a thorough introduction to multifractal analysis, you may access H. Wendt's PhD thesis available in `his webiste <https://www.irit.fr/~Herwig.Wendt/data/ThesisWendt.pdf)>`_.


For a brief introduction to multifractal analysis, see the file THEORY.ipynb
Expand Down
6 changes: 2 additions & 4 deletions doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{ fullname | escape | underline}}
{{ objname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
.. autoclass:: {{ fullname }}
6 changes: 2 additions & 4 deletions doc/_templates/autosummary/function.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{ fullname | escape | underline }}
{{ objname | escape | underline }}

.. currentmodule:: {{ module }}

.. autofunction:: {{ objname }}
.. autofunction:: {{ fullname }}
157 changes: 148 additions & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
import sys
sys.path.insert(0, os.path.abspath('..'))

import numpy as np
import pymultifracs
import sphinx
import numpydoc

from sphinx.ext.autosummary.generate import AutosummaryRenderer


# -- Project information -----------------------------------------------------

project = 'PyMultiFracs'
copyright = '2020-2023, M. Dumeur, P. Ciuciu, V. van Wassenhove, P. Abry'
author = 'M. Dumeur, P. Ciuciu, V. van Wassenhove, P. Abry'
copyright = '2020-2024, M. Dumeur, P. Ciuciu, V. van Wassenhove, P. Abry'
author = 'M. Dumeur, O. D. Domingues, P. Ciuciu, V. van Wassenhove, P. Abry'

# The full version, including alpha/beta/rc tags
release = '0.2'

release = '0.3'

# -- General configuration ---------------------------------------------------

Expand All @@ -41,20 +47,25 @@
# 'sphinx_autodoc_typehints',
# 'sphinx_gallery.notebook',
# 'sphinx_bootstrap_theme',
# 'nbsphinx',
'nbsphinx',
'sphinx.ext.mathjax']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ['_templates', '_templates/namedtuple.rst']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']

autosummary_generate = True
autodoc_default_options = {'members': True, 'exclude-members': '__init__',
'inherited-members': True}
autodoc_default_options = {
'members': True,
'exclude-members': '__init__',
'inherited-members': True,
}

autodoc_typehints = 'none'

# -- Options for HTML output -------------------------------------------------

Expand Down Expand Up @@ -125,7 +136,7 @@
"numpy": ("https://numpy.org/doc/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy", None),
"matplotlib": ("https://matplotlib.org/stable", None),
'sklearn': ('https://scikit-learn.org/stable', None),
# 'sklearn': ('https://scikit-learn.org/stable', None),
'joblib': ('https://joblib.readthedocs.io/en/latest', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None),
'seaborn': ('https://seaborn.pydata.org/', None),
Expand All @@ -142,6 +153,116 @@
numpydoc_class_members_toctree = False
numpydoc_show_class_members = False

numpydoc_xref_ignore = {
# words
"and",
"between",
"instance",
"instances",
"of",
"default",
"shape",
"or",
"with",
"length",
"pair",
"matplotlib",
"optional",
"kwargs",
"in",
"dtype",
"object",
# shapes
"n_vertices",
"n_faces",
"n_channels",
"m",
"n",
"n_events",
"n_colors",
"n_times",
"obj",
"n_chan",
"n_epochs",
"n_picks",
"n_ch_groups",
"n_dipoles",
"n_ica_components",
"n_pos",
"n_node_names",
"n_tapers",
"n_signals",
"n_step",
"n_freqs",
"wsize",
"Tx",
"M",
"N",
"p",
"q",
"r",
"n_observations",
"n_regressors",
"n_cols",
"n_frequencies",
"n_tests",
"n_samples",
"n_permutations",
"nchan",
"n_points",
"n_features",
"n_parts",
"n_features_new",
"n_components",
"n_labels",
"n_events_in",
"n_splits",
"n_scores",
"n_outputs",
"n_trials",
"n_estimators",
"n_tasks",
"nd_features",
"n_classes",
"n_targets",
"n_slices",
"n_hpi",
"n_fids",
"n_elp",
"n_pts",
"n_tris",
"n_nodes",
"n_nonzero",
"n_events_out",
"n_segments",
"n_orient_inv",
"n_orient_fwd",
"n_orient",
"n_dipoles_lcmv",
"n_dipoles_fwd",
"n_picks_ref",
"n_coords",
"n_meg",
"n_good_meg",
"n_moments",
"n_patterns",
"n_new_events",
# sklearn subclasses
"mapping",
"to",
"any",
# unlinkable
"CoregistrationUI",
"mne_qt_browser.figure.MNEQtBrowser",
# pooch, since its website is unreliable and users will rarely need the links
"pooch.Unzip",
"pooch.Untar",
"pooch.HTTPDownloader",
}

numpydoc_validate = True
numpydoc_validation_checks = {"all"}

# nbsphinx

highlight_language = 'none'
Expand All @@ -153,3 +274,21 @@
"--InlineBackend.figure_formats={'svg', 'pdf'}",
"--InlineBackend.rc={'figure.dpi': 96}",
]

#%% Adjusting the displayed name of functions
# https://stackoverflow.com/a/72658470

# def smart_fullname(fullname):
# parts = fullname.split(".")
# return ".".join(parts[1:])


# def fixed_init(self, app, template_dir=None):
# AutosummaryRenderer.__old_init__(self, app, template_dir)
# self.env.filters["smart_fullname"] = smart_fullname


# AutosummaryRenderer.__old_init__ = AutosummaryRenderer.__init__
# AutosummaryRenderer.__init__ = fixed_init

#%%
9 changes: 9 additions & 0 deletions doc/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
========
Examples
========

.. nbgallery::
:name: nb-gallery
:glob:

notebooks/Demo
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Contents
:caption: Overview:

reference
examples
theory
Loading
Loading