Skip to content

Commit

Permalink
Test reading fixed-layout multi-frequency signals.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Benjamin Moody committed Oct 13, 2021
1 parent 1e30da0 commit 9d76714
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sample-data/multi-segment/041s/041s.hea
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
041s/2 7 125 2000 8:26:04 26/10/1994
041s01 1000
041s02 1000
Binary file added sample-data/multi-segment/041s/041s01.dat
Binary file not shown.
9 changes: 9 additions & 0 deletions sample-data/multi-segment/041s/041s01.hea
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
041s01 7 125 1000 8:26:04 26/10/1994
041s01.dat 212x4 2000 12 0 168 -2716 0 III
041s01.dat 212x4 2000 12 0 2 -25019 0 I
041s01.dat 212x4 2000 12 0 155 -12467 0 V
041s01.dat 212 20(-1600)/mmHg 12 0 -242 -18875 0 ABP
041s01.dat 212 80(-1600)/mmHg 12 0 706 -5338 0 PAP
041s01.dat 212 2000 12 0 -841 30145 0 PLETH
041s01.dat 212 2000 12 0 401 3712 0 RESP
#Produced by xform from record mimicdb/041/04100001, beginning at s74000
Binary file added sample-data/multi-segment/041s/041s02.dat
Binary file not shown.
9 changes: 9 additions & 0 deletions sample-data/multi-segment/041s/041s02.hea
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
041s02 7 125 1000 8:26:12 26/10/1994
041s02.dat 212x4 2000 12 0 -103 -862 0 III
041s02.dat 212x4 2000 12 0 -64 14967 0 I
041s02.dat 212x4 2000 12 0 89 13162 0 V
041s02.dat 212 20(-1600)/mmHg 12 0 -715 -21117 0 ABP
041s02.dat 212 80(-1600)/mmHg 12 0 -583 -31770 0 PAP
041s02.dat 212 2000 12 0 -840 -31041 0 PLETH
041s02.dat 212 2000 12 0 -861 -31272 0 RESP
#Produced by xform from record mimicdb/041/04100002, beginning at 0:0
Binary file added tests/target-output/record-multi-fixed-d.gz
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,34 @@ def test_multi_fixed_c(self):
np.testing.assert_equal(sig_round, sig_target)
assert record.__eq__(record_named)

def test_multi_fixed_d(self):
"""
Multi-segment, fixed layout, multi-frequency, selected channels
Target file created with:
rdsamp -r sample-data/multi-segment/041s/ -s 3 2 1 -H |
cut -f 2- | sed s/-32768/-2048/ |
gzip -9 -n > tests/target-output/record-multi-fixed-d.gz
"""
record = wfdb.rdrecord('sample-data/multi-segment/041s/041s',
channels=[3, 2, 1], physical=False,
smooth_frames=False)

# Convert expanded to uniform array (high-resolution)
sig = np.zeros((record.sig_len * 4, record.n_sig), dtype=int)
for i, s in enumerate(record.e_d_signal):
sig[:, i] = np.repeat(s, len(sig[:, i]) // len(s))

sig_target = np.genfromtxt(
'tests/target-output/record-multi-fixed-d.gz')

record_named = wfdb.rdrecord('sample-data/multi-segment/041s/041s',
channel_names=['ABP', 'V', 'I'],
physical=False, smooth_frames=False)

np.testing.assert_array_equal(sig, sig_target)
assert record.__eq__(record_named)

def test_multi_variable_a(self):
"""
Multi-segment, variable layout, selected duration, samples read
Expand Down

0 comments on commit 9d76714

Please sign in to comment.