Repository navigation
Fix channels and invalid samples in wfdb_to_wav - #645
Merged
Merged
Conversation
Read the digital samples directly instead of reading physical values and converting them back with adc(), and pass channels to rdrecord, which was ignored. Write invalid samples as the format 16 invalid value: shifting them overflowed to 0 for resolutions below 12 bits. Add tests for sampfrom and sampto, channels, and invalid samples. Fixes #637 Fixes #638 Fixes #639 Fixes #640
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to #632 for
wfdb_to_wav. They change the same few lines, so they are in one PR.Read digital samples (wfdb_to_wav: read digital samples directly instead of converting back with adc() #638). The record is read with
physical=False, andd_signalis used directly. Before, physical values were read and converted back withadc(). That needed a full-length float64 copy, and the output depended on howadc()rounds. The old comment about the mismatches from that conversion is removed.channels(wfdb_to_wav ignores the channels parameter #640). It is now passed tordrecord. Before, it was ignored and every signal was written.Invalid samples (wfdb_to_wav writes invalid samples as 0 for resolutions below 12 bits #637). They are written as -32768, the format 16 invalid value, so they are read back as missing (also with
write_header=True). Before, they were shifted like any other sample, and below 12 bits they overflowed. For a format 212 record with an invalid sample (-2048):adc_res-32768-327680-32768Format 8 has no invalid value, so those channels are not changed.
Tests (Test wfdb_to_wav with sampfrom and sampto #639). New tests for
sampfrom/sampto(includinginit_valuein the header written withwrite_header=True), forchannels, and for invalid samples with 11 and 12 bits. Thechannelstest and the 11-bit invalid sample test fail onmain. The others already pass there, as expected.Testing:
uv run pytest tests/io tests/test_record.py -m "not network" -W errorpasses (114), as doruff format --checkandruff check. Changelog entry added inchangelog.d/.Fixes #637
Fixes #638
Fixes #639
Fixes #640
@tompollard 🟥 red 🐳 whale · quince