Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8f6a27c
Add .gitignore and untrack .DS_Store
eprifti Feb 27, 2026
1cf1fe1
Fix deprecated cElementTree import in PDF2XML_mod.py
eprifti Feb 27, 2026
da26ab2
Fix dependency list in setup.py
eprifti Feb 27, 2026
59e3b56
Bump minimum Python version to 3.9
eprifti Feb 27, 2026
ab6937d
Fix broken import and syntax error in Generate_Database.py
eprifti Feb 27, 2026
eb844af
Add comprehensive test suite (137 tests)
eprifti Feb 27, 2026
9f1c0aa
Update roadmap and review with Phase 1 completion status
eprifti Feb 27, 2026
d49f75b
Replace print() with logging module across ecgtizer package
eprifti Feb 27, 2026
922002b
Remove dead code from PDF2XML.py
eprifti Feb 27, 2026
befd1f2
Fix bare except clauses in helper_functions.py
eprifti Feb 27, 2026
b862180
Replace wildcard import with explicit imports in PDF2XML.py
eprifti Feb 27, 2026
df92436
Fix boolean comparison anti-patterns across codebase
eprifti Feb 27, 2026
43f0bc8
Update roadmap: Phase 2 code quality items complete
eprifti Feb 27, 2026
bca854e
Clean up PDF2XML_mod.py: fix naming, remove dead functions
eprifti Feb 27, 2026
757245b
Extract magic numbers into named constants across codebase
eprifti Feb 27, 2026
674f1c1
Vectorize pixel-level loops with NumPy in PDF2XML.py
eprifti Feb 27, 2026
d7d390b
Add type hints to all public API functions
eprifti Feb 27, 2026
22ac960
Refactor PDF2XML.py: extract helper functions from monolithic code
eprifti Feb 27, 2026
996e398
Update roadmap: Phase 2 and Phase 3 complete
eprifti Feb 27, 2026
a1e2340
Add pyproject.toml to replace legacy setup.py
eprifti Feb 27, 2026
8452d78
Add GitHub Actions CI workflow
eprifti Feb 27, 2026
c814072
Add pre-commit hooks config (black, flake8, mypy)
eprifti Feb 27, 2026
0431112
Add Unlicense LICENSE file
eprifti Feb 27, 2026
5e0146a
Update roadmap: Phase 4 nearly complete (4/5 items done)
eprifti Feb 27, 2026
e414ab5
Rewrite README with architecture diagram, usage examples, and API ref…
eprifti Feb 27, 2026
77ec9f9
Add module-level docstrings to all 9 modules and __all__ to __init__.py
eprifti Feb 27, 2026
5f6e6e7
Add NumPy-style docstrings to ECGtizer class, PDF2XML_mod, and anonym…
eprifti Feb 27, 2026
7556beb
Add NumPy-style docstrings to analyses, completion and extraction mod…
eprifti Feb 27, 2026
60c6d7a
Add NumPy-style docstrings to XML2PDF module
eprifti Feb 27, 2026
712919d
Set up Sphinx documentation framework with autodoc API pages
eprifti Feb 27, 2026
911cac8
Update roadmap: Phase 4 complete, add Phase 5 documentation checklist
eprifti Feb 27, 2026
d491a15
Add Sphinx docs build job to CI workflow
eprifti Feb 27, 2026
a9d88f9
Add tests for anonymisation and XML2PDF; fix xml_to_pdf type1 bug
eprifti Feb 27, 2026
9631a39
Remove legacy setup.py (replaced by pyproject.toml)
eprifti Feb 27, 2026
4e32022
Add functional documentation with real examples for all 8 modules
eprifti Feb 27, 2026
ead5b42
Update roadmap: CI docs, new tests, functional docs, setup.py removal
eprifti Feb 27, 2026
9156cf8
Add pipeline vignette notebook with 12-stage visual walkthrough
eprifti Feb 27, 2026
a21be52
Add PDF export of pipeline vignette notebook
eprifti Feb 27, 2026
b287a28
Remove XML file dump from pipeline vignette
eprifti Feb 27, 2026
229ca00
Fix NaN leads in fragmented extraction and sup_holes
eprifti Feb 27, 2026
7a5a31c
Add pytest-cov for test coverage reporting
eprifti Feb 27, 2026
d5a577f
Add performance benchmark script
eprifti Feb 27, 2026
69f325c
Add PyPI packaging setup
eprifti Feb 27, 2026
83729e8
Add proper CLI entry point, remove broken ECGtizer_main.py
eprifti Feb 27, 2026
db7ad9b
Vectorize hot paths for 2-29x speedup
eprifti Feb 27, 2026
b1c8073
Fix crashes on real-world ECG files
eprifti Feb 27, 2026
f5d6190
Fix Write_PDF breaking with absolute output paths
eprifti Feb 27, 2026
aada413
Fix waveform extraction quality: grid removal, track segmentation, ca…
eprifti Feb 27, 2026
96736ec
Improve extraction quality and analysis display
eprifti Apr 17, 2026
0b6fabb
security: Pass weights_only=True to torch.load (C1, #5)
eprifti Apr 17, 2026
bcfdc6a
security: Harden XML parsing and pin Pillow (H1/L1, #9 #14)
eprifti Apr 17, 2026
87cf0f6
security: Cap PDF pages and DPI to prevent decompression bombs (M2, #12)
eprifti Apr 17, 2026
614c967
security: Harden SSRF in handwritten-text generator (M3, #13)
eprifti Apr 17, 2026
df2b27d
security: Bump vulnerable dependencies in generator requirements (C3/…
eprifti Apr 17, 2026
459d0fb
Add Phase 6 (security hardening) to roadmap
eprifti Apr 17, 2026
1817901
Update roadmap: mark closed security items and log Phase 6 progress
eprifti Apr 18, 2026
553c446
Bump minimum Python to 3.10
eprifti Apr 18, 2026
caafc80
Log py3.10 bump and upstream contributions in roadmap
eprifti Apr 18, 2026
15a92ee
Ignore coverage and pytest-cache artefacts
eprifti Apr 18, 2026
35abcdf
Note untracked diagnostic scripts in roadmap backlog
eprifti Apr 18, 2026
42ea69e
Add pandas to [dev] extras — required by test fixtures
eprifti Apr 18, 2026
95becc7
Normalize whitespace with black, fix one latent bug marker
eprifti Apr 18, 2026
ea71b0c
Expand flake8 ignore list for black compat + pre-existing debt
eprifti Apr 18, 2026
fd5400b
Fix anonymisation test patches: use sys.modules for reliable module l…
eprifti Apr 18, 2026
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
Binary file removed .DS_Store
Binary file not shown.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y poppler-utils

- name: Install package and dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests with coverage
run: pytest tests/ -v --tb=short --cov=ecgtizer --cov-report=term-missing

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 mypy

- name: Flake8
# E203 conflicts with black; E266/E741 are stylistic.
# F401/F841 are pre-existing tech debt (unused imports/vars) — re-enable after cleanup pass.
run: flake8 ecgtizer/ --max-line-length=120 --ignore=E501,W503,E402,E203,E266,E741,F401,F841

- name: Mypy (informational)
run: mypy ecgtizer/ --ignore-missing-imports || true

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install package and docs dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"

- name: Build Sphinx docs
run: sphinx-build -b html docs/ docs/_build/html -W --keep-going
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install build tools
run: pip install build

- name: Build sdist and wheel
run: python -m build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Byte-compiled / optimized
__pycache__/
*.py[cod]
*$py.class
*.so

# Distribution / packaging
build/
dist/
*.egg-info/
*.egg

# Cython
*.c
*.cpp
!ecgtizer/*.c
!ecgtizer/*.cpp

# Virtual environments
.venv/
venv/
env/

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Jupyter
.ipynb_checkpoints/

# Sphinx documentation
docs/_build/

# Vignette / notebook outputs
output/

# Test / coverage artefacts
.coverage
.coverage.*
htmlcov/
.pytest_cache/

28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=500']

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: ['--line-length=120']

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=120', '--ignore=E501,W503,E402']

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
args: ['--ignore-missing-imports']
additional_dependencies: ['numpy']
6 changes: 2 additions & 4 deletions Create_database/Generate_Database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys
sys.path.append("../../ecgtizer_old/ecgtizer/ecgtizer/")
from XML2PDF import Write_PDF
import os
import pandas as pd
Expand Down Expand Up @@ -512,8 +510,8 @@ def process_ecg(i, TYPE):

return data

def main(path_data = "ptb_xl/raw/physionet.org/files/ptb-xl/1.0.3/" , path_save = "ptb_xl/noised_images/temp/6x2/",
path_save_xml = "../../../../../data/ecg/db_projects/physionet/ptb_xl/noised_images/temp/", TYPE):
def main(TYPE, path_data = "ptb_xl/raw/physionet.org/files/ptb-xl/1.0.3/" , path_save = "ptb_xl/noised_images/temp/6x2/",
path_save_xml = "../../../../../data/ecg/db_projects/physionet/ptb_xl/noised_images/temp/"):
# TYPE = 1 # 4x4 TYPE = 2 # 6x2

### Path des données PTB-XL
Expand Down
2 changes: 1 addition & 1 deletion Create_database/XML2PDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def read_lead(lead_str):
def read_xml(file):
matrix = {}
with open(file) as fd:
doc = xml.parse(fd.read())
doc = xml.parse(fd.read(), disable_entities=True)

num_lead = len(doc['AnnotatedECG']['component']['series']['component']['sequenceSet']['component'])
for i in range(1,num_lead):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def get_handwritten(link,num_words,input_file,output_dir,x_offset=0,y_offset=0,h
filename = input_file

#Extract n medical terms
if(validators.url(link)):
#Parse URL
r = requests.get(link)
if(validators.url(link) and link.lower().startswith(("http://", "https://"))):
#Parse URL — restrict scheme, set timeout, cap response size to prevent SSRF/DoS
r = requests.get(link, timeout=10, allow_redirects=False)
r.raise_for_status()

if platform == "darwin":
soup = BeautifulSoup(r.content, "html5lib")
Expand Down
4 changes: 2 additions & 2 deletions Create_database/ecg_image_generator/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_frequency(header):
frequency = float(frequency.split('/')[0])
else:
frequency = float(frequency)
except:
except (ValueError, IndexError):
pass
else:
break
Expand All @@ -171,7 +171,7 @@ def get_adc_gains(header, leads):
j = leads.index(current_lead)
try:
adc_gains[j] = float(entries[2].split('/')[0])
except:
except (ValueError, IndexError):
pass
else:
break
Expand Down
28 changes: 14 additions & 14 deletions Create_database/ecg_image_generator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
beautifulsoup4==4.12.2
imageio==2.27.0
beautifulsoup4>=4.12.3
imageio>=2.34.0
imgaug==0.4.0
imutils==0.5.4
keras==2.14.0
opencv_python==4.6.0.66
pillow==10.3.0
requests==2.21.0
scikit-image==0.21.0
scikit-learn==1.4.2
scipy>=1.10.0
keras>=3.8.0
opencv_python>=4.10.0.84
pillow>=12.2.0
requests>=2.32.3
scikit-image>=0.22.0
scikit-learn>=1.5.0
scipy>=1.11.4
seaborn==0.12.2
spacy==3.2.6
tensorflow==2.14.0
validators==0.18.2
spacy>=3.7.4
tensorflow>=2.18.0
validators>=0.20.0
matplotlib
html5lib==1.1
joblib==1.3.2
numpy==1.26.4
pandas==2.2.2
wfdb==4.1.2
wfdb>=4.1.2
pyyaml
qrcode==7.4.2
qrcode==7.4.2
49 changes: 0 additions & 49 deletions ECGtizer_main.py

This file was deleted.

24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.md
recursive-include ecgtizer/fonts *.ttf
Loading
Loading