Repository navigation
Read PhysioNet records whose names include folders - #666
Conversation
rdheader, rdrecord and rdann with pn_dir dropped any folders at the start of
the record name, so rdrecord("files/p1000/.../40689238",
pn_dir="mimic-iv-ecg/1.0") looked for 40689238.hea at the top of the database.
Move those folders to the end of pn_dir instead, in one helper that also
adds the latest version, which was repeated in each function.
Segments of multi-segment records on PhysioNet are now read by name from
pn_dir, without the local directory that used to be joined to them and
then dropped.
Fixes #467.
tompollard
left a comment
There was a problem hiding this comment.
The folder-path handling looks sound. I ran the 29 focused offline tests and separately checked a cached variable-layout multi-segment record in a nested folder against the same local record; the signals matched. All 18 PR checks pass. I found no code issue.
One documentation fix: the public rdheader, rdrecord, and rdsamp docstrings still say that when pn_dir is set, record_name should contain only the base record name (src/wfdb/io/record.py:1883, :2108, and :2507). That contradicts the folder paths this PR now supports and could steer users away from the fix. Could those descriptions say that folders may be included in either record_name or pn_dir, as the new docs/io.rst example shows?
|
Thanks, agreed. In e7c1441, the The same old sentence was in 10 docstrings, so I changed all of them:
|
Fixes #467.
rdheader,rdrecord,rdsampandrdannwithpn_dirdropped any folders at the start of the record name. Sordrecord("files/p1000/p10000032/s40689238/40689238", pn_dir="mimic-iv-ecg/1.0")looked for40689238.heaat the top of the database, and failed with "file not found". The folders now move to the end ofpn_dir, so the folders can be given in either argument._resolve_pn_dir, does this and also adds the latest version whenpn_dirhas none. That code was repeated in each of the three functions.pn_dir. Before, the local working directory was joined to the segment name and then dropped along with any other folders. A network test (test_multi_variable_d[physionet]) caught this.docs/io.rstdescribes folders in either argument.Testing
pn_dirwith a version, without one, and with some of the folders inpn_dir. They fail onmain. A network test reads the MIMIC-IV-ECG record from the issue.pytest: all offline and network tests pass, also with--resolution lowest-direct. Ruff and the docs build pass.@tompollard 🟥 red 🦥 sloth · aspen