-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_patient_data.py
More file actions
57 lines (43 loc) · 1.41 KB
/
analyze_patient_data.py
File metadata and controls
57 lines (43 loc) · 1.41 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import numpy as np
import matplotlib.pyplot as plt
import glob
input_path, output_path, extension = 'data/', 'output/', 'png'
files = glob.glob(input_path+'inflammation-*.csv')
files.sort()
#checks for sussy data
def detect_problems(patient_data):
"""Perform problem detection for one file for patient data"""
if np.amax(data, axis=0) [0] == 0 and np.amax(data, axis=0) [20] == 20:
print('sussy max')
elif np.sum(np.amin(data, axis = 0)) == 0:
print('sussy min')
else:
print('passed')
#plot mean, max, and min
def plot_graphs(filename, patient_data):
"""Plot line graph of patient inflammation data for one file"""
#set up figs
fig = plt.figure(figsize=(10.0, 3.0))
#set up plots
axes1 = fig.add_subplot(1,3,1)
axes2 = fig.add_subplot(1,3,2)
axes3 = fig.add_subplot(1,3,3)
#plot the mean
axes1.set_ylabel('average')
axes1.plot(np.mean(patient_data, axis=0))
#plot the max
axes2.set_ylabel('max')
axes2.plot(np.amax(patient_data, axis=0))
#plot the min
axes3.set_ylabel('min')
axes3.plot(np.amin(patient_data, axis=0))
fig.tight_layout()
plt.savefig(output_path + filename [5:-3] + extension)
plt.show()
for file in inflammation_files:
#get the data
print(file)
data = np.loadtxt(fname=file, delimiter=',')
#detect problems and create graphs
detect_problems(data)
plot_graphs(file, data)