mdu 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. mdu-0.0.1/LICENSE +21 -0
  2. mdu-0.0.1/PKG-INFO +100 -0
  3. mdu-0.0.1/README.md +39 -0
  4. mdu-0.0.1/pyproject.toml +64 -0
  5. mdu-0.0.1/setup.cfg +4 -0
  6. mdu-0.0.1/src/mdu/__init__.py +0 -0
  7. mdu-0.0.1/src/mdu/cross_val/chrono.py +73 -0
  8. mdu-0.0.1/src/mdu/forecast/forecaster.py +400 -0
  9. mdu-0.0.1/src/mdu/forecast/simulate.py +86 -0
  10. mdu-0.0.1/src/mdu/mne/__init__.py +0 -0
  11. mdu-0.0.1/src/mdu/mne/dbs/stim_switch.py +74 -0
  12. mdu-0.0.1/src/mdu/mne/events.py +36 -0
  13. mdu-0.0.1/src/mdu/mne/ica/__init__.py +0 -0
  14. mdu-0.0.1/src/mdu/mne/ica/assets/ica_styles.css +139 -0
  15. mdu-0.0.1/src/mdu/mne/ica/ica_selection_app.py +318 -0
  16. mdu-0.0.1/src/mdu/mne/ica/ica_utils/__init__.py +0 -0
  17. mdu-0.0.1/src/mdu/mne/ica/ica_utils/shared.py +638 -0
  18. mdu-0.0.1/src/mdu/mne/ica/resampler_plotting.py +111 -0
  19. mdu-0.0.1/src/mdu/mne/ica/simple_app.py +369 -0
  20. mdu-0.0.1/src/mdu/plotly/__init__.py +0 -0
  21. mdu-0.0.1/src/mdu/plotly/dist_plotting.py +841 -0
  22. mdu-0.0.1/src/mdu/plotly/html_grids.py +344 -0
  23. mdu-0.0.1/src/mdu/plotly/ml.py +56 -0
  24. mdu-0.0.1/src/mdu/plotly/mne_plotting.py +404 -0
  25. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/__init__.py +0 -0
  26. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/epoch_image.py +474 -0
  27. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/psd.py +194 -0
  28. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/shared.py +132 -0
  29. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/time_series.py +229 -0
  30. mdu-0.0.1/src/mdu/plotly/mne_plotting_utils/topoplot.py +454 -0
  31. mdu-0.0.1/src/mdu/plotly/multiline.py +357 -0
  32. mdu-0.0.1/src/mdu/plotly/resampler_compat.py +97 -0
  33. mdu-0.0.1/src/mdu/plotly/shared.py +764 -0
  34. mdu-0.0.1/src/mdu/plotly/stats.py +1455 -0
  35. mdu-0.0.1/src/mdu/plotly/styling.py +131 -0
  36. mdu-0.0.1/src/mdu/plotly/template.py +68 -0
  37. mdu-0.0.1/src/mdu/plotly/time_series.py +128 -0
  38. mdu-0.0.1/src/mdu/stats/residuals.py +203 -0
  39. mdu-0.0.1/src/mdu/utils/__init__.py +0 -0
  40. mdu-0.0.1/src/mdu/utils/converters.py +88 -0
  41. mdu-0.0.1/src/mdu/utils/logging.py +98 -0
  42. mdu-0.0.1/src/mdu.egg-info/PKG-INFO +100 -0
  43. mdu-0.0.1/src/mdu.egg-info/SOURCES.txt +57 -0
  44. mdu-0.0.1/src/mdu.egg-info/dependency_links.txt +1 -0
  45. mdu-0.0.1/src/mdu.egg-info/requires.txt +57 -0
  46. mdu-0.0.1/src/mdu.egg-info/top_level.txt +1 -0
  47. mdu-0.0.1/tests/test_cluster_permutation.py +155 -0
  48. mdu-0.0.1/tests/test_converters.py +225 -0
  49. mdu-0.0.1/tests/test_cross_val.py +31 -0
  50. mdu-0.0.1/tests/test_events.py +193 -0
  51. mdu-0.0.1/tests/test_forecasting.py +227 -0
  52. mdu-0.0.1/tests/test_logging.py +265 -0
  53. mdu-0.0.1/tests/test_ml.py +140 -0
  54. mdu-0.0.1/tests/test_mne_plotting_utils_shared.py +229 -0
  55. mdu-0.0.1/tests/test_plotly_shared.py +335 -0
  56. mdu-0.0.1/tests/test_resampler_compat.py +105 -0
  57. mdu-0.0.1/tests/test_significance_indicators.py +147 -0
  58. mdu-0.0.1/tests/test_template.py +144 -0
  59. mdu-0.0.1/tests/test_time_series.py +174 -0
mdu-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthias Dold
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
mdu-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: mdu
3
+ Version: 0.0.1
4
+ Summary: Default utilities I use for electrophys analysis
5
+ Author-email: Matthias Dold <matthias.dold@gmx.de>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy>=2.2.6
11
+ Requires-Dist: scipy>=1.15.3
12
+ Requires-Dist: pandas>=2.3.3
13
+ Requires-Dist: matplotlib>=3.10.8
14
+ Requires-Dist: plotly>=6.6.0
15
+ Requires-Dist: mne>=1.11.0
16
+ Requires-Dist: statsmodels>=0.14.6
17
+ Requires-Dist: tqdm>=4.67.3
18
+ Requires-Dist: loguru>=0.7.0
19
+ Requires-Dist: polars>=1.38.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=9.0.2; extra == "dev"
22
+ Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
23
+ Requires-Dist: ipython>=8.38.0; extra == "dev"
24
+ Requires-Dist: ruff; extra == "dev"
25
+ Provides-Extra: docs
26
+ Requires-Dist: quartodoc; extra == "docs"
27
+ Requires-Dist: nbformat; extra == "docs"
28
+ Requires-Dist: nbclient; extra == "docs"
29
+ Requires-Dist: jupyter-cache; extra == "docs"
30
+ Requires-Dist: ipykernel; extra == "docs"
31
+ Requires-Dist: griffe<2.0.0; extra == "docs"
32
+ Provides-Extra: resampler
33
+ Requires-Dist: plotly-resampler; extra == "resampler"
34
+ Provides-Extra: ml
35
+ Requires-Dist: scikit-learn>=1.0.0; extra == "ml"
36
+ Provides-Extra: dash
37
+ Requires-Dist: dash>=2.0.0; extra == "dash"
38
+ Requires-Dist: PyYAML>=6.0.0; extra == "dash"
39
+ Provides-Extra: build
40
+ Requires-Dist: build; extra == "build"
41
+ Requires-Dist: twine; extra == "build"
42
+ Provides-Extra: all
43
+ Requires-Dist: build; extra == "all"
44
+ Requires-Dist: twine; extra == "all"
45
+ Requires-Dist: griffe<2.0.0; extra == "all"
46
+ Requires-Dist: pytest>=9.0.2; extra == "all"
47
+ Requires-Dist: pytest-cov>=7.0.0; extra == "all"
48
+ Requires-Dist: ipython>=8.38.0; extra == "all"
49
+ Requires-Dist: ruff; extra == "all"
50
+ Requires-Dist: quartodoc; extra == "all"
51
+ Requires-Dist: nbformat; extra == "all"
52
+ Requires-Dist: nbclient; extra == "all"
53
+ Requires-Dist: jupyter-cache; extra == "all"
54
+ Requires-Dist: ipykernel; extra == "all"
55
+ Requires-Dist: plotly-resampler; extra == "all"
56
+ Requires-Dist: scikit-learn>=1.0.0; extra == "all"
57
+ Requires-Dist: fire>=0.7.0; extra == "all"
58
+ Requires-Dist: dash>=2.0.0; extra == "all"
59
+ Requires-Dist: PyYAML>=6.0.0; extra == "all"
60
+ Dynamic: license-file
61
+
62
+ # MD Utils
63
+
64
+ ![CI](https://github.com/matthiasdold/mdu/workflows/CI%20Testing/badge.svg?branch=main)
65
+ [![codecov](https://codecov.io/gh/matthiasdold/mdu/branch/main/graph/badge.svg)](https://codecov.io/gh/matthiasdold/mdu)
66
+ ![Tests](https://img.shields.io/badge/tests-176%20passed-brightgreen)
67
+ ![Python](https://img.shields.io/badge/python-3.10+-blue)
68
+
69
+ This repo includes common functionality I often use during analysis of
70
+ electrophysiology data.
71
+
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ # Basic installation
77
+ pip install mdu
78
+
79
+ # With development tools
80
+ pip install mdu[dev]
81
+
82
+ # With optional features
83
+ pip install mdu[resampler] # For large time-series plotting
84
+ pip install mdu[ml] # For ML plotting utilities
85
+ pip install mdu[dash] # For interactive dashboards
86
+ pip install mdu[all] # All optional features
87
+ ```
88
+
89
+ ## Testing
90
+
91
+ Run tests with coverage:
92
+
93
+ ```bash
94
+ pytest tests/ --cov=src/mdu --cov-report=html
95
+ ```
96
+
97
+ Current test coverage: **27%** (176 tests passing)
98
+
99
+ Coverage reports are automatically tracked on [Codecov](https://codecov.io/gh/matthiasdold/mdu) via CI.
100
+
mdu-0.0.1/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # MD Utils
2
+
3
+ ![CI](https://github.com/matthiasdold/mdu/workflows/CI%20Testing/badge.svg?branch=main)
4
+ [![codecov](https://codecov.io/gh/matthiasdold/mdu/branch/main/graph/badge.svg)](https://codecov.io/gh/matthiasdold/mdu)
5
+ ![Tests](https://img.shields.io/badge/tests-176%20passed-brightgreen)
6
+ ![Python](https://img.shields.io/badge/python-3.10+-blue)
7
+
8
+ This repo includes common functionality I often use during analysis of
9
+ electrophysiology data.
10
+
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Basic installation
16
+ pip install mdu
17
+
18
+ # With development tools
19
+ pip install mdu[dev]
20
+
21
+ # With optional features
22
+ pip install mdu[resampler] # For large time-series plotting
23
+ pip install mdu[ml] # For ML plotting utilities
24
+ pip install mdu[dash] # For interactive dashboards
25
+ pip install mdu[all] # All optional features
26
+ ```
27
+
28
+ ## Testing
29
+
30
+ Run tests with coverage:
31
+
32
+ ```bash
33
+ pytest tests/ --cov=src/mdu --cov-report=html
34
+ ```
35
+
36
+ Current test coverage: **27%** (176 tests passing)
37
+
38
+ Coverage reports are automatically tracked on [Codecov](https://codecov.io/gh/matthiasdold/mdu) via CI.
39
+
@@ -0,0 +1,64 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mdu"
7
+ version = "0.0.1"
8
+ authors = [{name="Matthias Dold", email="matthias.dold@gmx.de"}]
9
+ description = "Default utilities I use for electrophys analysis"
10
+ readme ="README.md"
11
+ requires-python = ">=3.10"
12
+ license = {text = "MIT"}
13
+ dependencies = [
14
+ "numpy>=2.2.6",
15
+ "scipy>=1.15.3",
16
+ "pandas>=2.3.3",
17
+ "matplotlib>=3.10.8",
18
+ "plotly>=6.6.0",
19
+ "mne>=1.11.0",
20
+ "statsmodels>=0.14.6",
21
+ "tqdm>=4.67.3",
22
+ "loguru>=0.7.0",
23
+ "polars>=1.38.0",
24
+ ]
25
+
26
+ [project.optional-dependencies]
27
+ dev = ["pytest>=9.0.2", "pytest-cov>=7.0.0", "ipython>=8.38.0", "ruff"]
28
+ docs = ["quartodoc", "nbformat", "nbclient", "jupyter-cache", "ipykernel", "griffe<2.0.0"] # griffe<2.0.0 required for quartodoc
29
+ resampler = ["plotly-resampler"]
30
+ ml = ["scikit-learn>=1.0.0"]
31
+ dash = ["dash>=2.0.0", "PyYAML>=6.0.0"]
32
+ build = ["build", "twine"]
33
+ all = [
34
+ "build",
35
+ "twine",
36
+ "griffe<2.0.0",
37
+ "pytest>=9.0.2",
38
+ "pytest-cov>=7.0.0",
39
+ "ipython>=8.38.0",
40
+ "ruff",
41
+ "quartodoc",
42
+ "nbformat",
43
+ "nbclient",
44
+ "jupyter-cache",
45
+ "ipykernel",
46
+ "plotly-resampler",
47
+ "scikit-learn>=1.0.0",
48
+ "fire>=0.7.0",
49
+ "dash>=2.0.0",
50
+ "PyYAML>=6.0.0"
51
+ ]
52
+
53
+ [tool.pytest.ini_options]
54
+ addopts = "-ra -q"
55
+ testpaths = [
56
+ "tests",
57
+ "./"
58
+ ]
59
+ filterwarnings = ["ignore:::.*fire.core"]
60
+
61
+ # Adding e.g. custom css
62
+ [tool.setuptools.package-data]
63
+ mdu = ["*.txt"]
64
+ "mdu.mne.ica.assets" = ["*.css"]
mdu-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,73 @@
1
+ import numpy as np
2
+ from mdu.utils.logging import get_logger
3
+
4
+ logger = get_logger("mdu")
5
+
6
+
7
+ class ChronoGroupsSplit:
8
+ """Leave out blocks of chronologically sorted pairs"""
9
+
10
+ def __init__(self, **kwags):
11
+ for k in kwags:
12
+ logger.info(f"Received kwargs for {k=} which will not be used")
13
+
14
+ def split(self, X, y, groups):
15
+ """Return the indices of all splits of the data in X and y.
16
+
17
+ Parameters
18
+ ----------
19
+ X : np.ndarray, shape (nsamples, nfeatures)
20
+ The data array with the sample dimension first.
21
+ y : np.ndarray, shape (nsamples,)
22
+ The labels vector.
23
+ groups : np.ndarray, shape (nsamples,)
24
+ A grouping vector matching the labels. This will be considered
25
+ to keep groups constant within each fold.
26
+
27
+ Returns
28
+ -------
29
+ splits : list of tuple of np.ndarray
30
+ A list of splits as (ix_train, ix_test) tuples to loop over.
31
+ """
32
+
33
+ y = np.asarray(y)
34
+ groups = np.asarray(groups)
35
+ # get groups per label
36
+ gm = {k: list(set(groups[y == k])) for k in set(y)}
37
+
38
+ for v in gm.values():
39
+ v.sort()
40
+
41
+ # ensure that groups are distinct in labels
42
+ assert all(
43
+ [set(s).intersection(groups[y != k]) == set() for k, s in gm.items()]
44
+ ), " Groups are not unique in label"
45
+
46
+ # ensure lengths match
47
+ set_lens = [len(v) for v in gm.values()]
48
+ if not all([e == set_lens[0] for e in set_lens]):
49
+ logger.info(
50
+ "Not all the same number of groups per label - "
51
+ "will zip and thus drop all groups longer than the min"
52
+ )
53
+
54
+ Xidcs = np.arange(X.shape[0])
55
+
56
+ splits = [
57
+ (
58
+ np.hstack(
59
+ [
60
+ Xidcs[groups == list(gv)[j]]
61
+ for gv in gm.values()
62
+ for j in range(min(set_lens))
63
+ if j != i
64
+ ]
65
+ ), # the non selected --> train set # noqa
66
+ np.hstack(
67
+ [Xidcs[groups == list(gv)[i]] for gv in gm.values()]
68
+ ), # the selected per grp --> test # noqa
69
+ )
70
+ for i in range(min(set_lens))
71
+ ]
72
+
73
+ return splits