-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_output.py
21 lines (19 loc) · 938 Bytes
/
write_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def write_output(time, HRinst, HRavg, btc, filename="assignment02_output.csv"):
"""Writes to text file time, instantaneous heart rate, average heart rate
over user-specified interval, and when brady- or tachycardia occurred in
the ECG trace
:param time_HRinst: ndarray where first element is times and second element
is instantaneous heart rates
:param HRavg: list of average heart rates
:param btc: list of characters to indicate patient status (-- means not
enough data, T means tachycardia, B means bradycardia, and N means normal
"""
file = open(filename, "w+")
header = "Time (s), Instantaneous Heart Rate, Average Heart Rate," \
" Brady/Tachycardia Occurrence\n"
file.write(header)
for i, hr in enumerate(HRavg):
row = str(time[i]) + "," + str(HRinst[i]) + "," + str(HRavg[i]) + ","\
+ btc[i] + "\n"
file.write(row)
file.close()