Skip to content

Commit 90b8e3b

Browse files
author
Benjamin Moody
committed
Test reading fixed-layout multi-frequency signals.
This test case uses an excerpt of record mimicdb/041/, which is a fixed-layout record with three signals at 500 Hz (four samples per frame) and four signals at 125 Hz (one sample per frame).
1 parent 8098338 commit 90b8e3b

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
041s/2 7 125 2000 8:26:04 26/10/1994
2+
041s01 1000
3+
041s02 1000
23.4 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
041s01 7 125 1000 8:26:04 26/10/1994
2+
041s01.dat 212x4 2000 12 0 168 -2716 0 III
3+
041s01.dat 212x4 2000 12 0 2 -25019 0 I
4+
041s01.dat 212x4 2000 12 0 155 -12467 0 V
5+
041s01.dat 212 20(-1600)/mmHg 12 0 -242 -18875 0 ABP
6+
041s01.dat 212 80(-1600)/mmHg 12 0 706 -5338 0 PAP
7+
041s01.dat 212 2000 12 0 -841 30145 0 PLETH
8+
041s01.dat 212 2000 12 0 401 3712 0 RESP
9+
#Produced by xform from record mimicdb/041/04100001, beginning at s74000
23.4 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
041s02 7 125 1000 8:26:12 26/10/1994
2+
041s02.dat 212x4 2000 12 0 -103 -862 0 III
3+
041s02.dat 212x4 2000 12 0 -64 14967 0 I
4+
041s02.dat 212x4 2000 12 0 89 13162 0 V
5+
041s02.dat 212 20(-1600)/mmHg 12 0 -715 -21117 0 ABP
6+
041s02.dat 212 80(-1600)/mmHg 12 0 -583 -31770 0 PAP
7+
041s02.dat 212 2000 12 0 -840 -31041 0 PLETH
8+
041s02.dat 212 2000 12 0 -861 -31272 0 RESP
9+
#Produced by xform from record mimicdb/041/04100002, beginning at 0:0
26.3 KB
Binary file not shown.

tests/test_record.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,41 @@ def test_multi_fixed_c(self):
746746
np.testing.assert_equal(sig_round, sig_target)
747747
assert record.__eq__(record_named)
748748

749+
def test_multi_fixed_d(self):
750+
"""
751+
Multi-segment, fixed layout, multi-frequency, selected channels
752+
753+
Target file created with:
754+
rdsamp -r sample-data/multi-segment/041s/ -s 3 2 1 -H |
755+
cut -f 2- | sed s/-32768/-2048/ |
756+
gzip -9 -n > tests/target-output/record-multi-fixed-d.gz
757+
"""
758+
record = wfdb.rdrecord(
759+
"sample-data/multi-segment/041s/041s",
760+
channels=[3, 2, 1],
761+
physical=False,
762+
smooth_frames=False,
763+
)
764+
765+
# Convert expanded to uniform array (high-resolution)
766+
sig = np.zeros((record.sig_len * 4, record.n_sig), dtype=int)
767+
for i, s in enumerate(record.e_d_signal):
768+
sig[:, i] = np.repeat(s, len(sig[:, i]) // len(s))
769+
770+
sig_target = np.genfromtxt(
771+
"tests/target-output/record-multi-fixed-d.gz"
772+
)
773+
774+
record_named = wfdb.rdrecord(
775+
"sample-data/multi-segment/041s/041s",
776+
channel_names=["ABP", "V", "I"],
777+
physical=False,
778+
smooth_frames=False,
779+
)
780+
781+
np.testing.assert_array_equal(sig, sig_target)
782+
assert record.__eq__(record_named)
783+
749784
def test_multi_variable_a(self):
750785
"""
751786
Multi-segment, variable layout, selected duration, samples read

0 commit comments

Comments
 (0)