11import numpy as np
2- from wfdb import readsignal
2+ from wfdb import rdsamp
33
44class test_rdsamp ():
55
66 # Test 1 - Format 212/Entire signal/Physical
77 # Target file created with: rdsamp -r sampledata/100 -P | cut -f 2- > target1
88 def test_1 (self ):
9- sig , fields = readsignal . rdsamp ('sampledata/100' )
9+ sig , fields = rdsamp ('sampledata/100' )
1010 sig = np .round (sig , decimals = 8 )
1111 targetsig = np .genfromtxt ('tests/targetoutputdata/target1' )
1212 assert np .array_equal (sig , targetsig )
1313
1414 # Test 2 - Format 212/Selected Duration/Selected Channel/Digital.
1515 # Target file created with: rdsamp -r sampledata/100 -f 0.002 -t 30 -s 1 | cut -f 2- > target2
1616 def test_2 (self ):
17- sig , fields = readsignal . rdsamp ('sampledata/100' , sampfrom = 1 , sampto = 10800 , channels = [1 ], physical = 0 )
17+ sig , fields = rdsamp ('sampledata/100' , sampfrom = 1 , sampto = 10800 , channels = [1 ], physical = 0 )
1818 targetsig = np .genfromtxt ('tests/targetoutputdata/target2' )
1919 targetsig = targetsig .reshape (len (targetsig ), 1 )
2020 assert np .array_equal (sig , targetsig )
2121
2222 # Test 3 - Format 16/Entire signal/Digital
2323 # Target file created with: rdsamp -r sampledata/test01_00s | cut -f 2- > target3
2424 def test_3 (self ):
25- sig , fields = readsignal . rdsamp ('sampledata/test01_00s' , physical = 0 )
25+ sig , fields = rdsamp ('sampledata/test01_00s' , physical = 0 )
2626 targetsig = np .genfromtxt ('tests/targetoutputdata/target3' )
2727 assert np .array_equal (sig , targetsig )
2828
2929 # Test 4 - Format 16 with byte offset/Selected Duration/Selected Channels/Physical
3030 # Target file created with: rdsamp -r sampledata/a103l -f 50 -t 160 -s 2 0 -P | cut -f 2- > target4
3131 def test_4 (self ):
32- sig , fields = readsignal . rdsamp ('sampledata/a103l' , sampfrom = 12500 , sampto = 40000 , channels = [2 , 0 ])
32+ sig , fields = rdsamp ('sampledata/a103l' , sampfrom = 12500 , sampto = 40000 , channels = [2 , 0 ])
3333 sig = np .round (sig , decimals = 8 )
3434 targetsig = np .genfromtxt ('tests/targetoutputdata/target4' )
3535 assert np .array_equal (sig , targetsig )
3636
3737 # Test 5 - Format 16 with byte offset/Selected Duration/Selected Channels/Digital
3838 # Target file created with: rdsamp -r sampledata/a103l -f 80 -s 0 1 | cut -f 2- > target5
3939 def test_5 (self ):
40- sig , fields = readsignal . rdsamp ('sampledata/a103l' , sampfrom = 20000 , physical = 0 , channels = [0 , 1 ])
40+ sig , fields = rdsamp ('sampledata/a103l' , sampfrom = 20000 , physical = 0 , channels = [0 , 1 ])
4141 targetsig = np .genfromtxt ('tests/targetoutputdata/target5' )
4242 assert np .array_equal (sig , targetsig )
4343
4444 # Test 6 - Format 80/Selected Duration/Selected Channels/Physical
4545 # Target file created with: rdsamp -r sampledata/3000003_0003 -f 1 -t 8 -s 1 -P | cut -f 2- > target6
4646 def test_6 (self ):
47- sig , fields = readsignal . rdsamp ('sampledata/3000003_0003' , sampfrom = 125 , sampto = 1000 , channels = [1 ])
47+ sig , fields = rdsamp ('sampledata/3000003_0003' , sampfrom = 125 , sampto = 1000 , channels = [1 ])
4848 sig = np .round (sig , decimals = 8 )
4949 targetsig = np .genfromtxt ('tests/targetoutputdata/target6' )
5050 targetsig = targetsig .reshape (len (targetsig ), 1 )
@@ -53,22 +53,22 @@ def test_6(self):
5353 # Test 7 - Multi-dat/Entire signal/Digital
5454 # Target file created with: rdsamp -r sampledata/s0010_re | cut -f 2- > target7
5555 def test_7 (self ):
56- sig , fields = readsignal . rdsamp ('sampledata/s0010_re' , physical = 0 )
56+ sig , fields = rdsamp ('sampledata/s0010_re' , physical = 0 )
5757 targetsig = np .genfromtxt ('tests/targetoutputdata/target7' )
5858 assert np .array_equal (sig , targetsig )
5959
6060 # Test 8 - Multi-dat/Selected Duration/Selected Channels/Physical
6161 # Target file created with: rdsamp -r sampledata/s0010_re -f 5 -t 38 -P -s 13 0 4 8 3 | cut -f 2- > target8
6262 def test_8 (self ):
63- sig , fields = readsignal . rdsamp ('sampledata/s0010_re' , sampfrom = 5000 , sampto = 38000 , channels = [13 , 0 , 4 , 8 , 3 ])
63+ sig , fields = rdsamp ('sampledata/s0010_re' , sampfrom = 5000 , sampto = 38000 , channels = [13 , 0 , 4 , 8 , 3 ])
6464 sig = np .round (sig , decimals = 8 )
6565 targetsig = np .genfromtxt ('tests/targetoutputdata/target8' )
6666 assert np .array_equal (sig , targetsig )
6767
6868 # Test 9 - Format 12 multi-samples per frame and skew/Entire Signal/Digital
6969 # Target file created with: rdsamp -r sampledata/03700181 | cut -f 2- > target9
7070 def test_9 (self ):
71- sig , fields = readsignal . rdsamp ('sampledata/03700181' , physical = 0 )
71+ sig , fields = rdsamp ('sampledata/03700181' , physical = 0 )
7272 sig = sig [:- 4 ,:] # The WFDB library rdsamp does not return the final N samples for all channels due to the skew.
7373 # The WFDB python rdsamp does return the final N samples, filling in NANs for end of skewed channels only.
7474 targetsig = np .genfromtxt ('tests/targetoutputdata/target9' )
@@ -77,7 +77,7 @@ def test_9(self):
7777 # Test 10 - Format 12 multi-samples per frame and skew/Selected Duration/Selected Channels/Physical
7878 # Target file created with: rdsamp -r sampledata/03700181 -f 8 -t 128 -s 0 2 -P | cut -f 2- > target10
7979 def test_10 (self ):
80- sig , fields = readsignal . rdsamp ('sampledata/03700181' , channels = [0 ,2 ], sampfrom = 1000 , sampto = 16000 )
80+ sig , fields = rdsamp ('sampledata/03700181' , channels = [0 ,2 ], sampfrom = 1000 , sampto = 16000 )
8181 sig = np .round (sig , decimals = 8 )
8282 targetsig = np .genfromtxt ('tests/targetoutputdata/target10' )
8383 assert np .array_equal (sig , targetsig )
@@ -88,15 +88,15 @@ def test_10(self):
8888 # Test 11 - Multi-segment variable layout/Entire signal/Physical
8989 # Target file created with: rdsamp -r sampledata/matched/s25047/s25047-2704-05-04-10-44 -P | cut -f 2- > target11
9090 #def test_11(self):
91- #sig, fields=readsignal. rdsamp('sampledata/matched/s25047/s25047-2704-05-04-10-44')
91+ #sig, fields=rdsamp('sampledata/matched/s25047/s25047-2704-05-04-10-44')
9292 #sig=np.round(sig, decimals=8)
9393 #targetsig=np.genfromtxt('tests/targetoutputdata/target11')
9494 #assert np.array_equal(sig, targetsig)
9595
9696 # Test 12 - Multi-segment variable layout/Selected duration/Selected Channels/Physical
9797 # Target file created with: rdsamp -r sampledata/matched/s00001/s00001-2896-10-10-00-31 -f 70 -t 4000 -s 3 0 -P | cut -f 2- > target12
9898 #def test_12(self):
99- #sig, fields=readsignal. rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=8750, sampto=500000, channels=[3, 0])
99+ #sig, fields=rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=8750, sampto=500000, channels=[3, 0])
100100 #sig=np.round(sig, decimals=8)
101101 #targetsig=np.genfromtxt('tests/targetoutputdata/target12')
102102 #assert np.array_equal(sig, targetsig)
@@ -107,15 +107,15 @@ def test_10(self):
107107 # Target file created with: rdsamp -r sampledata/3000003_0003 -f 0 -t 8.21 | cut -f 2- | wrsamp -o 310derive -O 310
108108 # rdsamp -r 310derive -f 0.007 | cut -f 2- > target13
109109 def test_13 (self ):
110- sig , fields = readsignal . rdsamp ('sampledata/310derive' , sampfrom = 2 , physical = 0 )
110+ sig , fields = rdsamp ('sampledata/310derive' , sampfrom = 2 , physical = 0 )
111111 targetsig = np .genfromtxt ('tests/targetoutputdata/target13' )
112112 assert np .array_equal (sig , targetsig )
113113
114114 # Test 14 - Format 311/Selected Duration/Physical
115115 # Target file created with: rdsamp -r sampledata/3000003_0003 -f 0 -t 8.21 -s 1 | cut -f 2- | wrsamp -o 311derive -O 311
116116 # rdsamp -r 311derive -f 0.005 -t 3.91 -P | cut -f 2- > target14
117117 def test_14 (self ):
118- sig , fields = readsignal . rdsamp ('sampledata/311derive' , sampfrom = 1 , sampto = 978 )
118+ sig , fields = rdsamp ('sampledata/311derive' , sampfrom = 1 , sampto = 978 )
119119 sig = np .round (sig , decimals = 8 )
120120 targetsig = np .genfromtxt ('tests/targetoutputdata/target14' )
121121 targetsig = targetsig .reshape ([977 ,1 ])
0 commit comments