-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read FLAC signal files #372
Commits on Jun 10, 2022
-
This defines the function _open_file, which opens an input data file as a random-access file object. This module is intended to eventually replace the "streaming I/O" functions in the wfdb.io.download module (_remote_file_size, _stream_header, _stream_dat, and _stream_annotation.) Some notes on the implementation: - Contrary to many existing functions, I've deliberately made pn_dir the first argument rather than the second, since putting the prefix first seems more natural. - There's no dir_name argument; instead, callers should include the local directory name as part of file_name. I consider it a bug that some functions have a separate dir_name argument that is ignored when pn_dir is set. - This function does not do automatic version number resolution for PhysioNet projects. That's something the caller (still) needs to do and should be handled elsewhere.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for d418a9a - Browse repository at this point
Copy the full SHA d418a9aView commit details -
pyproject.toml: add dependency on soundfile.
The soundfile library provides a python wrapper for libsndfile, which in turn provides an interface to libFLAC for reading and writing FLAC files.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 0932a35 - Browse repository at this point
Copy the full SHA 0932a35View commit details -
.github/workflows: Install soundfile and libsndfile.
"build": pip install will install the Python soundfile package. On Windows/MacOS, this will install a binary wheel package that includes a private copy of libsndfile; on Ubuntu, it will install a generic package that requires us to install libsndfile separately. "test-deb10-i386": python3-soundfile installs the Python soundfile package and also depends on libsndfile1.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 9c677b5 - Browse repository at this point
Copy the full SHA 9c677b5View commit details -
_digi_bounds: use a dictionary instead of "if" statements.
The _digi_bounds function previously did not handle formats 310, 311, 61, 160, or 8 (which are not supported by wrsamp). Add these formats to SAMPLE_VALUE_RANGE for consistency even though they're currently not used. This will also raise an exception for unknown formats, rather than silently returning None.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for b83fad5 - Browse repository at this point
Copy the full SHA b83fad5View commit details -
_digi_nan: use a dictionary instead of "if" statements.
This will also raise an exception for unknown formats, rather than silently returning None.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 184f4fb - Browse repository at this point
Copy the full SHA 184f4fbView commit details -
_rd_dat_signals: add support for FLAC formats (508, 516, 524).
These format codes are used to designate FLAC signal files. Format 508 indicates 8-bit, format 516 indicates 16-bit, and format 524 indicates 24-bit resolution. Other format codes between 500 and 532 (inclusive) are reserved. A FLAC signal file contains between one and eight channels, which are sampled at the same frequency. Therefore, all signals stored in the same signal file must have the same number of samples per frame. (If a record contains more than eight signals, or if they have differing sampling frequencies, they will require more than one signal file.) Note that the number of samples per frame has no effect on the encoding or decoding of the FLAC signal file; there is no interleaving like there is in a binary signal file. There is also no requiremement that WFDB frame boundaries match up with FLAC compression-block boundaries. (Perhaps confusingly, the FLAC specification uses the word "frame" to refer to the encoded form of a block of samples; this has nothing to do with WFDB frames, and unless otherwise noted, the word "frame" refers to a WFDB frame.) To simplify this initial implementation, the function _rd_compressed_file is nearly a drop-in replacement for _rd_dat_file, which means that this function must rearrange the input data into the format that _rd_dat_signals expects.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for e681f7b - Browse repository at this point
Copy the full SHA e681f7bView commit details -
_rd_dat_signals, _rd_dat_file: fix documentation.
The fmt argument is the format of the singular dat file. It is not a list and that wouldn't make any sense here.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 9d3491c - Browse repository at this point
Copy the full SHA 9d3491cView commit details -
Add a test case for all WFDB FLAC signal formats.
The record "flacformats" contains one signal in each of the three WFDB FLAC signal formats. As with the "binformats" record, sample j of signal i is equal to: (i + 16843019 * j) % ((1 << adcres) - 1) + 1 - (1 << (adcres - 1))) Use this record to test that it is possible to read all of the formats correctly, including when we skip one or two samples from the start and/or end of the record.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 0ff4f84 - Browse repository at this point
Copy the full SHA 0ff4f84View commit details -
Add a test case for reading FLAC files over HTTP.
We want to be sure that the soundfile library is compatible with wfdb.io._url.NetFile, since wfdb.io._signal._rd_compressed_file relies on this. This isn't a complete test of WFDB/FLAC functionality, in part because the sample files are very small so we can't really exercise the seeking functionality. However, this should be sufficient to verify that soundfile doesn't make silly assumptions (like assuming the input file corresponds to an OS file descriptor.)
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 6cdf038 - Browse repository at this point
Copy the full SHA 6cdf038View commit details -
Add an example of ICU waveform data in FLAC format.
Benjamin Moody committedJun 10, 2022 Configuration menu - View commit details
-
Copy full SHA for 9b5df00 - Browse repository at this point
Copy the full SHA 9b5df00View commit details
Commits on Jun 22, 2022
-
README.md: add note about installing libsndfile.
Benjamin Moody committedJun 22, 2022 Configuration menu - View commit details
-
Copy full SHA for d49a5c3 - Browse repository at this point
Copy the full SHA d49a5c3View commit details