Repository navigation
wfdb #6791
Replies: 1 comment
|
It is pure Python ( Examplerequires-python = ">=3.12"
dependencies = [
"flet",
"wfdb==4.3.1",
]Add the below only if your app plots ( [tool.flet.android]
extract_packages = ["matplotlib"]matplotlib reads Example: Detecting beats
import asyncio
import functools
import flet as ft
import numpy as np
from wfdb.processing import calc_mean_hr, calc_rr, xqrs_detect
FS = 250
def main(page: ft.Page):
result = ft.Text()
async def detect(e):
sig = np.asarray(my_ecg_samples, dtype=np.float64) # one channel, in mV
# xqrs is CPU-bound — keep it off the UI thread.
qrs = await asyncio.to_thread(
functools.partial(xqrs_detect, sig=sig, fs=FS, verbose=False)
)
rr = calc_rr(qrs, fs=FS, rr_units="seconds")
hr = calc_mean_hr(rr, fs=FS, rr_units="seconds")
result.value = f"{len(qrs)} beats — {hr:.1f} bpm"
page.update()
page.add(ft.FilledButton("Detect QRS", on_click=detect), result)
ft.run(main)
Caveats worth knowing1. FLAC-format records don't work. wfdb reads WFDB formats 2. 3. 32-bit x86 emulators. 4. If anything imports matplotlib, set os.environ.setdefault(
"MPLCONFIGDIR",
os.path.join(os.getenv("FLET_APP_STORAGE_DATA", "."), "matplotlib"),
)Put it above the first 5. Size. scipy (89 MB), pandas (46 MB), numpy (23 MB) and matplotlib (22 MB) dominate: ~180 MB of site-packages per ABI, and the little demo app I built lands at 177 MB APK for a single So: nothing to build on our side — add |

wfdbneeds no mobile-forge recipe — it already works on both platforms straight from PyPI.It is pure Python (
wfdb-4.3.1-py3-none-any.whl), and every native package in its dependency tree already has mobile wheels:numpy,scipy,pandas,matplotlib,contourpy,kiwisolver,pillowfrom pypi.flet.dev, andaiohttp/charset-normalizerfrom PyPI's own Android/iOS wheels.fsspecandrequestsare pure Python.Example
Add the below only if your app plots (
wfdb.plot_items/plot_wfdb, or your ownmatplotlibimport):matplotlib reads
mpl-data/matplotlibrcthrough a real_…