-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtachybradycardia.py
41 lines (32 loc) · 1.26 KB
/
tachybradycardia.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def bradycardia(hr, lowerthresh):
"""
This module determines when in the ECG data there is bradycardia
:param hr: (ndarray) heart rate- used to determine when
bradycardia occurred in ECG trace
:param lowerthresh: (int or double) lower threshold for determining
bradycardia- user input or default 60 bpm
:return: brady: (ndarray) 1 for bradycardia, 0 otherwise
"""
import numpy as np
brady = [0] * np.size(hr)
for i in range(len(hr)):
if hr[i] <= int(lowerthresh): # this indicates bradycardia,
# aka the heart is beating too slowly
brady[i] = 1
return brady
def tachycardia(hr, upperthresh):
"""
This module determines when in the ECG data there is tachycardia
:param hr: (ndarray) heart rate-
used to determine when tachycardia occurred in ECG trace
:param upperthresh: (int or double) upper threshold for determining
tachycardia- user input or default 100 bpm
:return: tachy: (ndarray) 1 for tachycardia, 0 otherwise
"""
import numpy as np
tachy = [0] * np.size(hr)
for i in range(len(hr)):
if hr[i] >= int(upperthresh): # this indicates tachycardia,
# aka the heart is beating too quickly
tachy[i] = 1
return tachy