3
3
import unittest
4
4
from unittest import TestCase
5
5
6
- from systole import import_ppg
7
- from systole .detectors import msptd
6
+ from systole import import_ppg , import_dataset1
7
+ from systole .detectors import msptd , moving_average , pan_tompkins , hamilton , christov , engelse_zeelenberg
8
8
9
+ signal_df = import_dataset1 (modalities = ["ECG" ])[: 20 * 2000 ]
9
10
10
11
class TestDetectors (TestCase ):
11
12
def test_msptd (self ):
@@ -17,6 +18,31 @@ def test_msptd(self):
17
18
assert (peaks_onsets [0 ] == peaks ).all ()
18
19
assert (peaks_onsets [1 ] == onsets ).all ()
19
20
21
+ def test_moving_average (self ):
22
+ """Test moving average function"""
23
+ peaks = moving_average (signal = signal_df .ecg .to_numpy (), sfreq = 1000 )
24
+ assert peaks .sum () == 1037313
25
+
26
+ def test_pan_tompkins (self ):
27
+ """Test moving average function"""
28
+ peaks = pan_tompkins (signal = signal_df .ecg .to_numpy (), sfreq = 1000 )
29
+ assert peaks .sum () == 1038115
30
+
31
+ def test_hamilton (self ):
32
+ """Test moving average function"""
33
+ peaks = hamilton (signal = signal_df .ecg .to_numpy (), sfreq = 1000 )
34
+ assert peaks .sum () == 1066453
35
+
36
+ def test_christov (self ):
37
+ """Test moving average function"""
38
+ peaks = christov (signal = signal_df .ecg .to_numpy (), sfreq = 1000 )
39
+ assert peaks .sum () == 1037238
40
+
41
+ def test_engelse_zeelenberg (self ):
42
+ """Test moving average function"""
43
+ peaks = engelse_zeelenberg (signal = signal_df .ecg .to_numpy (), sfreq = 1000 )
44
+ assert peaks .sum () == 1036188
45
+
20
46
21
47
if __name__ == "__main__" :
22
48
unittest .main (argv = ["first-arg-is-ignored" ], exit = False )
0 commit comments