Repository navigation
Write selected multi-segment records with the modern API - #931
Conversation
A fixed-layout selection made only of ~ gaps was written as a master listing gaps alone, which no reader accepts because no data segment defines the channels. Raise before any file is created instead. Add formats= to write_segments and SegmentedRecordData.write, for every channel or one per selected channel in master order, mapped to each segment's own channels. Records stored in formats the library cannot write, such as format 8, can now be written.
|
I pushed b010628 with two fixes, on top of 00331f2. What I checked first I covered the five multi-segment sample records and small test records: fixed layout with a 1. A fixed-layout window made only of gaps was written but unreadable A window inside a 2. No way to choose a writable format Segments stored in a format the library can't write, such as format 8, the bit-packed formats, 61 or 160, always failed, because Tests
All 7 fail without the source change. My round-trip check, re-run with Not changed here The comment in |
## Summary Prepare wfdb 6.1.0, the first minor release after 6.0.0. This release adds the modern segmented-record workflow: - Plot a `SegmentedRecordData` on one timeline with boundaries and gaps (#928). - Inspect selected master metadata and edit a segment or shift times (#930). - Write fixed- and variable-layout segmented records, including selected windows, gaps, and explicit target formats (#931). This PR bumps the version in `pyproject.toml` and collects the three changelog fragments into `docs/changes.rst`. ## Verification - `uv build --offline` produced `wfdb-6.1.0.tar.gz` and `wfdb-6.1.0-py3-none-any.whl`. - Sphinx HTML build passed with `-W --keep-going`. - The release diff contains only the version and changelog changes. After this PR is merged, publish GitHub release `v6.1.0`. The release workflow will build and upload to PyPI through Trusted Publishing.
Summary
Add
write_segments(path, data)andSegmentedRecordData.write(path)for writing a selected multi-segment read as a new WFDB record. This follows #930 and is the second PR in the segmented-write plan.The writer generates unique segment names, preserves fixed or variable layout, keeps gaps at their selected lengths, writes a new variable-layout header in selected channel order, and uses the selected master time and comments rather than source provenance. Real segments with no selected channels become
~gaps. It accepts local record stems, supported writable cloud URIs, and local.wfdbarchives. Each real segment uses the existingRecordData.writevalidation and encoding path.Writes are staged so a validation or encoding failure leaves the destination untouched. Existing destination files produce an overwrite warning. The legacy
MultiRecord.wrsamppath is unchanged.formats=chooses one target format for every channel or one per selected master channel. This lets records read from a format that cannot be written, such as format 8, be saved in a supported format. A fixed-layout window containing only gaps is rejected because its output would have no data segment to define the channels.Tests
read_segmentsand combinedread_record, including selected windows, channel order, gaps and absent channels.formats=, per-channel format mapping in variable layout, and rejection of fixed-layout gap-only output.