Skip to content

Add functions to determine sample ranges of signals in multi-segment records #403

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

Merged
merged 4 commits into from
Jun 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for contained_ranges
  • Loading branch information
cx1111 committed Jun 30, 2022
commit a1bb8a66bb9c7ec5d23c06c33c66fa0a01fed05c
50 changes: 50 additions & 0 deletions tests/test_multi_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import wfdb


class TestMultiRecord:
def test_contained_ranges_simple_cases(self):
record = wfdb.MultiRecord(
segments=[
wfdb.Record(sig_name=["I", "II"], sig_len=5),
wfdb.Record(sig_name=["I", "III"], sig_len=10),
],
)

assert record.contained_ranges("I") == [(0, 15)]
assert record.contained_ranges("II") == [(0, 5)]
assert record.contained_ranges("III") == [(5, 15)]

def test_contained_ranges_variable_layout(self):
record = wfdb.rdheader(
"sample-data/multi-segment/s00001/s00001-2896-10-10-00-31",
rd_segments=True,
)

assert record.contained_ranges("II") == [
(3261, 10136),
(4610865, 10370865),
(10528365, 14518365),
]
assert record.contained_ranges("V") == [
(3261, 918261),
(920865, 4438365),
(4610865, 10370865),
(10528365, 14518365),
]
assert record.contained_ranges("MCL1") == [
(10136, 918261),
(920865, 4438365),
]
assert record.contained_ranges("ABP") == [
(14428365, 14450865),
(14458365, 14495865),
]

def test_contained_ranges_fixed_layout(self):
record = wfdb.rdheader(
"sample-data/multi-segment/041s/041s",
rd_segments=True,
)

for sig_name in record.sig_name:
assert record.contained_ranges(sig_name) == [(0, 2000)]