Skip to content

Commit d141845

Browse files
authored
Merge pull request #5 from snesmaeili/dev
Refactor PyZaplinePlus: Professional package structure, comprehensive…
2 parents 81e1f8d + df5632d commit d141845

16 files changed

Lines changed: 4484 additions & 31 deletions

.github/workflows/publish.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: pip
25+
cache-dependency-path: pyproject.toml
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -e ".[test]"
31+
32+
- name: Test with pytest
33+
run: |
34+
pytest tests/ -v --tb=short
35+
36+
publish:
37+
needs: test
38+
runs-on: ubuntu-latest
39+
environment: release
40+
permissions:
41+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.10"
50+
cache: pip
51+
cache-dependency-path: pyproject.toml
52+
53+
- name: Install build dependencies
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install build twine
57+
58+
- name: Build package
59+
run: python -m build
60+
61+
- name: Check package
62+
run: twine check dist/*
63+
64+
- name: Publish to PyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
cache: pip
27+
cache-dependency-path: pyproject.toml
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -e ".[test]"
33+
34+
- name: Lint with ruff
35+
run: |
36+
pip install ruff
37+
ruff check .
38+
ruff format --check .
39+
40+
- name: Test with pytest
41+
run: |
42+
pytest tests/ -v --tb=short --disable-warnings
43+
44+
- name: Test with pytest (with coverage)
45+
if: matrix.python-version == '3.10'
46+
run: |
47+
pip install pytest-cov
48+
pytest tests/ --cov=pyzaplineplus --cov-report=xml --cov-report=term-missing
49+
50+
- name: Upload coverage to Codecov
51+
if: matrix.python-version == '3.10'
52+
uses: codecov/codecov-action@v3
53+
with:
54+
file: ./coverage.xml
55+
flags: unittests
56+
name: codecov-umbrella
57+
fail_ci_if_error: false

.gitignore

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,163 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
db.sqlite3
59+
60+
# Flask stuff:
61+
instance/
62+
.webassets-cache
63+
64+
# Scrapy stuff:
65+
.scrapy
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
# Jupyter Notebook
74+
.ipynb_checkpoints
75+
76+
# IPython
77+
profile_default/
78+
ipython_config.py
79+
80+
# pyenv
81+
.python-version
82+
83+
# celery beat schedule file
84+
celerybeat-schedule
85+
86+
# SageMath parsed files
87+
*.sage.py
88+
89+
# Environments
90+
.env
91+
.venv
92+
env/
93+
venv/
94+
ENV/
95+
env.bak/
96+
venv.bak/
97+
98+
# Spyder project settings
99+
.spyderproject
100+
.spyproject
101+
102+
# Rope project settings
103+
.ropeproject
104+
105+
# mkdocs documentation
106+
/site
107+
site/
108+
109+
# mypy
110+
.mypy_cache/
111+
.dmypy.json
112+
dmypy.json
113+
114+
# Pyre type checker
115+
.pyre/
116+
117+
# IDEs
118+
.vscode/
119+
.idea/
120+
*.swp
121+
*.swo
122+
*~
123+
124+
# OS generated files
125+
.DS_Store
126+
.DS_Store?
127+
._*
128+
.Spotlight-V100
129+
.Trashes
130+
ehthumbs.db
131+
Thumbs.db
132+
133+
# Project specific - EEG data files
134+
*.mat
135+
*.fif
136+
*.set
137+
*.fdt
138+
*.elc
139+
*.h5
140+
*.edf
141+
*.bdf
142+
143+
# Test and example data
144+
test_data/
145+
data/
146+
examples/data/
147+
148+
# Generated plots and figures
149+
*.png
150+
*.jpg
151+
*.jpeg
152+
*.svg
153+
!docs/**/*.png
154+
!docs/**/*.jpg
155+
!docs/**/*.svg
156+
157+
# Old structure (keep for reference during migration)
158+
pyZapline_plus/data/
159+
pyZapline_plus/*.png
160+
1161
pyZapline_plus/data/P01_noRAC_slowWalk_basic_prepared.fdt
2162
pyZapline_plus/data/P01_noRAC_slowWalk_basic_prepared.set
3163
pyZapline_plus/data/test_joy_EEG.set

CHANGELOG.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Comprehensive test suite with >90% coverage
12+
- Professional documentation with MkDocs
13+
- GitHub Actions for CI/CD and automated publishing
14+
- Type hints throughout the codebase
15+
- Integration examples for MNE-Python
16+
17+
### Changed
18+
- Restructured package for professional distribution
19+
- Improved error handling and validation
20+
- Enhanced visualization capabilities
21+
- Optimized performance for large datasets
22+
23+
### Fixed
24+
- Memory efficiency improvements
25+
- Edge cases in noise detection
26+
- Compatibility with latest NumPy and SciPy versions
27+
28+
## [1.0.0] - 2024-01-XX
29+
30+
### Added
31+
- Initial release of PyZaplinePlus
32+
- Core functionality for line noise removal using Zapline-plus algorithm
33+
- Automatic and manual noise frequency detection
34+
- Adaptive and fixed chunk segmentation
35+
- Comprehensive visualization of cleaning results
36+
- Integration with MNE-Python workflows
37+
- Support for Python 3.8-3.12
38+
- MIT license
39+
40+
### Features
41+
- **Automatic Line Noise Detection**: Detects power line noise (50/60 Hz) automatically
42+
- **Adaptive Processing**: Dynamically adjusts cleaning parameters
43+
- **Denoising Source Separation**: Uses DSS with PCA for precise noise removal
44+
- **Multiple Noise Frequencies**: Handles multiple frequencies simultaneously
45+
- **Flexible Segmentation**: Both fixed-time and adaptive chunking options
46+
- **Visualization Tools**: Built-in plotting for quality assessment
47+
- **Scientific Validation**: Based on peer-reviewed Zapline-plus research
48+
49+
### Dependencies
50+
- numpy >= 1.20.0
51+
- scipy >= 1.7.0
52+
- scikit-learn >= 1.0.0
53+
- matplotlib >= 3.3.0
54+
- Optional: mne >= 1.0.0 for EEG integration
55+
56+
---
57+
58+
## Version History
59+
60+
- **v1.0.0**: Initial professional release with full feature set
61+
- **v0.x.x**: Development versions (not publicly released)
62+
63+
## Migration Guide
64+
65+
### From Original pyZapline_plus
66+
67+
If you were using the original development version:
68+
69+
```python
70+
# Old way
71+
from pyZapline_plus.pyzaplineplus import PyZaplinePlus, zapline_plus
72+
73+
# New way
74+
from pyzaplineplus import PyZaplinePlus, zapline_plus
75+
```
76+
77+
The API remains largely the same, but with improved:
78+
- Error handling
79+
- Documentation
80+
- Type safety
81+
- Performance
82+
- Testing coverage
83+
84+
## Breaking Changes
85+
86+
- Package name changed from `pyZapline_plus` to `pyzaplineplus`
87+
- Module imports simplified
88+
- Some internal function signatures improved for consistency
89+
90+
## Support
91+
92+
For questions about specific versions or migration help:
93+
- Open an issue on [GitHub](https://github.com/SinaEsmaeili/PyZaplinePlus/issues)
94+
- Check the [documentation](https://pyzaplineplus.readthedocs.io/)
95+

0 commit comments

Comments
 (0)