WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 78a1a86

Browse files
author
Benjamin Moody
committed
Merge pull request #372 into main
This adds support for reading FLAC compressed signal files (indicated by format codes 508, 516, and 524, which were added in libwfdb version 10.7.0.) Reading FLAC files uses the Python soundfile package, which in turn requires the libsndfile and libFLAC C libraries to be installed. soundfile is now included as a dependency of wfdb; you can install it even if you don't have libsndfile, but trying to 'import soundfile' will fail in that case. Consequently, wfdb will only try to import soundfile when you actually try to read a FLAC signal file. Note that most desktop Linux systems include libsndfile by default, and the soundfile wheel packages include libsndfile binaries for x86-64 Windows and Mac OS platforms.
2 parents 14248d1 + d49a5c3 commit 78a1a86

File tree

16 files changed

+391
-36
lines changed

16 files changed

+391
-36
lines changed

.github/workflows/run-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
run: |
2929
python -m pip install --upgrade pip poetry
3030
pip install ".[dev]"
31+
- name: Install libsndfile
32+
if: startsWith(matrix.os, 'ubuntu')
33+
run: |
34+
sudo apt-get install -y libsndfile1
3135
- name: Run tests
3236
run: pytest
3337
- name: Validate poetry file
@@ -48,6 +52,7 @@ jobs:
4852
python3-pandas \
4953
python3-requests \
5054
python3-scipy \
55+
python3-soundfile \
5156
python3-pytest \
5257
git
5358

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pip install wfdb
3535
poetry add wfdb
3636
```
3737

38+
On Linux systems, accessing *compressed* WFDB signal files requires installing `libsndfile`, by running `sudo apt-get install libsndfile1` or `sudo yum install libsndfile`. Support for Apple M1 systems is a work in progess (see <https://github.com/bastibe/python-soundfile/issues/310> and <https://github.com/bastibe/python-soundfile/issues/325>).
39+
3840
The development version is hosted at: <https://github.com/MIT-LCP/wfdb-python>. This repository also contains demo scripts and example data. To install the development version, clone or download the repository, navigate to the base directory, and run:
3941

4042
```sh

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ python = "^3.7"
1010
numpy = "^1.10.1"
1111
scipy = "^1.0.0"
1212
pandas = "^1.0.0"
13+
SoundFile = ">=0.10.0, <0.12.0"
1314
matplotlib = "^3.2.2"
1415
requests = "^2.8.1"
1516
pytest = {version = "^7.1.1", optional = true}

sample-data/flacformats.d0

524 Bytes
Binary file not shown.

sample-data/flacformats.d1

881 Bytes
Binary file not shown.

sample-data/flacformats.d2

1.26 KB
Binary file not shown.

sample-data/flacformats.hea

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
flacformats 3 200 499
2+
flacformats.d0 508 200/mV 8 0 -127 -484 0 sig 0, fmt 508
3+
flacformats.d1 516 200/mV 16 0 -32766 -750 0 sig 1, fmt 516
4+
flacformats.d2 524 200/mV 24 0 -8388605 8721 0 sig 2, fmt 524

sample-data/mixedsignals.hea

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mixedsignals 6 62.4725/999.56 14400
2+
mixedsignals_e.dat 516x4 200/mV 14 8192 0 24460 0 II
3+
mixedsignals_e.dat 516x4 200/mV 14 8192 0 19772 0 III
4+
mixedsignals_e.dat 516x4 200/mV 14 8192 0 22261 0 V
5+
mixedsignals_p.dat 516x2 16(800)/mmHg 12 2048 0 49347 0 ABP
6+
mixedsignals_p.dat 516x2 4096(0)/NU 12 2048 0 36026 0 Pleth
7+
mixedsignals_r.dat 516 4093(2)/Ohm 12 2048 0 35395 0 Resp

sample-data/mixedsignals_e.dat

72.1 KB
Binary file not shown.

sample-data/mixedsignals_p.dat

33.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)