-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
538 lines (512 loc) · 24.6 KB
/
gui.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
#!/usr/bin/python
from __future__ import division, print_function
import math
import sys
import os
import time
import threading
import signal
from timeit import default_timer as timer
import numpy
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from common import *
# Parameters
###############################################################################
scalex = 5
scaley = 50
offsety = 30
scale2y = 100
offset2y = 20
scale6y = 100
offset6y = 80
debug = False
###############################################################################
nb_cols = 44 # Not counting the final '\n'
delay = 0.025
t_plot = [0]
p_cmh2o_plot = [0]
p_e_cmh2o_plot = [0]
Ppeak_plot = [0]
PEEP_plot = [0]
flow_control_air_plot = [0]
flow_control_O2_plot = [0]
valve_air_plot = [0]
valve_O2_plot = [0]
valve_expi_plot = [0]
flow_air_plot = [0]
flow_expi_plot = [0]
flow_O2_plot = [0]
flow_filtered_air_plot = [0]
flow_filtered_expi_plot = [0]
flow_filtered_O2_plot = [0]
flow_filtered_plot = [0]
vol_l_plot = [0]
class GUIWindow(pg.GraphicsWindow):
sigKeyPress = QtCore.pyqtSignal(object)
def keyPressEvent(self, ev):
self.scene().keyPressEvent(ev)
self.sigKeyPress.emit(ev)
def closeEvent(self, ev):
# Global variables to share with other functions.
global bExit
#ev.ignore()
ev.accept() # let the window close
bExit = True
def keyPressed(evt):
# Global variables to share with other functions.
global bExit, debug
#print("Key pressed")
#print(evt.key())
if evt.key() == QtCore.Qt.Key_Escape:
bExit = True
if evt.key() == QtCore.Qt.Key_D:
debug = not debug
#win = pg.GraphicsWindow()
win = GUIWindow()
win.sigKeyPress.connect(keyPressed)
win.setWindowTitle('Pressure, flow, volume')
plt = win.addPlot(row = 0, col = 0)
plt2 = win.addPlot(row = 0, col = 1)
plt3 = win.addPlot(row = 0, col = 2)
plt4 = win.addPlot(row = 1, col = 2)
plt5 = win.addPlot(row = 2, col = 2)
plt6 = win.addPlot(row = 3, col = 2)
win.move(0, 0)
win.resize(800, 420)
if debug:
plt.show()
plt2.show()
plt3.hide()
plt4.hide()
plt5.hide()
else:
plt.hide()
plt2.hide()
plt3.show()
plt4.show()
plt5.show()
plt6.hide()
plt.showGrid(x = True, y = True)
plt2.showGrid(x = True, y = True)
plt3.showGrid(x = True, y = True)
plt4.showGrid(x = True, y = True)
plt5.showGrid(x = True, y = True)
plt6.showGrid(x = True, y = True)
plt.setTitle('Temp. I: 25.00 C, Temp. E: 25.00 C', **{'color': '#FFFFFF', 'size': '10pt'})
plt2.setTitle('Temp. A: 25.00 C, Temp. E: 25.00 C, Temp. O: 25.00 C', **{'color': '#FFF', 'size': '10pt'})
plt.setLabel('left', 'Pressure (in cmH2O)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt2.setLabel('left', 'Flow (in L/min)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt2.setLabel('right', 'Volume (in cl)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt3.setLabel('left', 'Pressure (in cmH2O)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt4.setLabel('left', 'Flow (in L/min)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt5.setLabel('left', 'Volume (in cl)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt6.setLabel('left', 'Flow (in L/min)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt.setLabel('bottom', 'Time (in s)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt2.setLabel('bottom', 'Time (in s)', **{'color': '#FFFFFF', 'font-size': '10pt'})
plt.addLegend(size = (0, 0), offset = (4, 1))
plt2.addLegend(size = (0, 0), offset = (4, 1))
plt3.addLegend(size = (0, 0), offset = (4, 1))
plt4.addLegend(size = (0, 0), offset = (4, 1))
plt5.addLegend(size = (0, 0), offset = (4, 1))
plt6.addLegend(size = (0, 0), offset = (4, 1))
font = QtGui.QFont()
font.setPixelSize(11)
plt.getAxis('left').tickFont = font
plt2.getAxis('left').tickFont = font
plt2.getAxis('right').tickFont = font
plt3.getAxis('left').tickFont = font
plt4.getAxis('left').tickFont = font
plt5.getAxis('left').tickFont = font
plt6.getAxis('left').tickFont = font
plt.getAxis('bottom').tickFont = font
plt2.getAxis('bottom').tickFont = font
plt3.getAxis('bottom').tickFont = font
plt4.getAxis('bottom').tickFont = font
plt5.getAxis('bottom').tickFont = font
plt6.getAxis('bottom').tickFont = font
c_p_cmh2o = plt.plot(t_plot, p_cmh2o_plot, pen = '#FFFF00', name = 'Inspi. pres.')
c2_p_cmh2o = plt3.plot(t_plot, p_cmh2o_plot, pen = '#FFFF00', name = 'Inspi. pres.')
c_p_e_cmh2o = plt.plot(t_plot, p_e_cmh2o_plot, pen = '#FFA500', name = 'Expi. pres.')
c_Ppeak = plt.plot(t_plot, Ppeak_plot, pen = '#FFFFFF')
c2_Ppeak = plt3.plot(t_plot, Ppeak_plot, pen = '#FFFFFF')
c_PEEP = plt.plot(t_plot, PEEP_plot, pen = '#AAAAAA')
c2_PEEP = plt3.plot(t_plot, PEEP_plot, pen = '#AAAAAA')
c_flow_control_air = plt2.plot(t_plot, flow_control_air_plot, pen = '#AAFF00')
c2_flow_control_air = plt6.plot(t_plot, flow_control_air_plot, pen = '#AAFF00')
c_flow_control_O2 = plt2.plot(t_plot, flow_control_O2_plot, pen = '#00AAFF')
c2_flow_control_O2 = plt6.plot(t_plot, flow_control_O2_plot, pen = '#00AAFF')
c_valve_air = plt.plot(t_plot, valve_air_plot, pen = '#00FF00', name = 'Air valve')
c_valve_O2 = plt.plot(t_plot, valve_O2_plot, pen = '#0000FF', name = 'O2 valve')
c_valve_expi = plt.plot(t_plot, valve_expi_plot, pen = '#FF0000', name = 'Expi. valve')
c_flow_air = plt2.plot(t_plot, flow_air_plot, pen = '#003000')
c_flow_expi = plt2.plot(t_plot, flow_expi_plot, pen = '#300000')
c_flow_O2 = plt2.plot(t_plot, flow_O2_plot, pen = '#003030')
c_flow_filtered_air = plt2.plot(t_plot, flow_filtered_air_plot, pen = '#00FF00', name = 'Air flow')
c2_flow_filtered_air = plt6.plot(t_plot, flow_filtered_air_plot, pen = '#00FF00', name = 'Air flow')
c_flow_filtered_expi = plt2.plot(t_plot, flow_filtered_expi_plot, pen = '#FF0000', name = 'Expi. flow')
c_flow_filtered_O2 = plt2.plot(t_plot, flow_filtered_O2_plot, pen = '#0000FF', name = 'O2 flow')
c2_flow_filtered_O2 = plt6.plot(t_plot, flow_filtered_O2_plot, pen = '#0000FF', name = 'O2 flow')
c_flow_filtered = plt4.plot(t_plot, flow_filtered_plot, pen = '#FF0000', name = 'Flow')
c_vol_l = plt2.plot(t_plot, vol_l_plot, pen = '#FF00FF', name = 'Volume')
c2_vol_l = plt5.plot(t_plot, vol_l_plot, pen = '#FF00FF', name = 'Volume')
for item in plt.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
for item in plt2.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
for item in plt3.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
for item in plt4.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
for item in plt5.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
for item in plt6.legend.items:
for single_item in item:
if isinstance(single_item, pg.graphicsItems.LabelItem.LabelItem):
single_item.setText(single_item.text, **{'color': '#FFFFFF', 'size': '10pt'})
if (scaley != 0):
plt.enableAutoRange('y', False)
plt.setYRange(-scaley+offsety, scaley+offsety, 0)
#plt3.enableAutoRange('y', False)
#plt3.setYRange(-scaley+offsety, scaley+offsety, 0)
if (scale2y != 0):
plt2.enableAutoRange('y', False)
plt2.setYRange(-scale2y+offset2y, scale2y+offset2y, 0)
#plt4.enableAutoRange('y', False)
#plt4.setYRange(-scale2y+offset2y, scale2y+offset2y, 0)
#plt5.enableAutoRange('y', False)
#plt5.setYRange(-scale2y+offset2y, scale2y+offset2y, 0)
plt6.enableAutoRange('y', False)
plt6.setYRange(-scale6y+offset6y, scale6y+offset6y, 0)
# Waiting for the file to be created...
while True:
try:
file = open('data.csv', 'r')
except IOError:
time.sleep(1)
else:
break
file.seek(0, os.SEEK_END)
bExit = False
def signal_handler(sig, frame):
global bExit
#signal.signal(signal.SIGINT, signal.SIG_IGN) # To avoid interruption by other CTRL+C...
bExit = True
signal.signal(signal.SIGINT, signal_handler) # To catch CTRL+C
debug_prev = -1
mode_prev = -1
#count = 0
while (bExit != True):
start_time = time.time()
try:
data = file.readlines()
if data:
for line in data:
cols = line.split(';')
if (len(cols) > nb_cols): # Need the final '\n' so we are sure the numbers are fully written
#print(cols)
try:
index = 0
t = float(cols[index])
index = index+1
t0 = float(cols[index])
index = index+1
p0 = float(cols[index])
index = index+1
temperature0 = float(cols[index])
index = index+1
p = float(cols[index])
index = index+1
temperature = float(cols[index])
index = index+1
p_e = float(cols[index])
index = index+1
temperature_e = float(cols[index])
index = index+1
alarms = int(cols[index])
index = index+1
select = int(cols[index])
index = index+1
mode = int(cols[index])
index = index+1
flow_control = int(cols[index])
index = index+1
O2_percent = int(cols[index])
index = index+1
ramp = int(cols[index])
index = index+1
Ppeak = int(cols[index])
index = index+1
PEEP = int(cols[index])
index = index+1
respi_rate = int(cols[index])
index = index+1
inspi_percent = int(cols[index])
index = index+1
PEEP_dec_rate = int(cols[index])
index = index+1
PEEP_tuning = int(cols[index])
index = index+1
Fl_PEEP = int(cols[index])
index = index+1
O2_PEEP = int(cols[index])
index = index+1
PEEP_inspi_detection_delta = float(cols[index])
index = index+1
vol_inspi_detection_delta = int(cols[index])
index = index+1
inspi_detection_delta_duration = int(cols[index])
index = index+1
flow_thresh = float(cols[index])
index = index+1
valve_air = int(cols[index])
index = index+1
valve_O2 = int(cols[index])
index = index+1
valve_expi = int(cols[index])
index = index+1
pressure_air = float(cols[index])
index = index+1
pressure_expi = float(cols[index])
index = index+1
pressure_O2 = float(cols[index])
index = index+1
temperature_air = float(cols[index])
index = index+1
temperature_expi = float(cols[index])
index = index+1
temperature_O2 = float(cols[index])
index = index+1
flow_air = float(cols[index])
index = index+1
flow_expi = float(cols[index])
index = index+1
flow_O2 = float(cols[index])
index = index+1
flow_filtered_air = float(cols[index])
index = index+1
flow_filtered_expi = float(cols[index])
index = index+1
flow_filtered_O2 = float(cols[index])
index = index+1
vol_air = float(cols[index])
index = index+1
vol_expi = float(cols[index])
index = index+1
vol_O2 = float(cols[index])
index = index+1
t_t0 = t-t0
p_cmh2o = (p-p0)*1.01972
p_e_cmh2o = (p_e-p0)*1.01972
flow_filtered = flow_filtered_air+flow_filtered_O2+flow_filtered_expi
vol_l = (vol_air+vol_O2+vol_expi)
if (t_t0 < t_plot[-1]):
# Reset if time seems to decrease...
t_plot = [0]
p_cmh2o_plot = [0]
p_e_cmh2o_plot = [0]
Ppeak_plot = [0]
PEEP_plot = [0]
flow_control_air_plot = [0]
flow_control_O2_plot = [0]
valve_air_plot = [0]
valve_O2_plot = [0]
valve_expi_plot = [0]
flow_air_plot = [0]
flow_expi_plot = [0]
flow_O2_plot = [0]
flow_filtered_air_plot = [0]
flow_filtered_expi_plot = [0]
flow_filtered_O2_plot = [0]
flow_filtered_plot = [0]
vol_l_plot = [0]
if (select == 0):
wintitle = '[Mode: {:d}]'
win.setWindowTitle(wintitle.format(int(mode)))
elif (select == 1):
wintitle = '[Flow: {:d}]'
win.setWindowTitle(wintitle.format(int(flow_control)))
elif (select == 2):
wintitle = '[O2: {:d}%]'
win.setWindowTitle(wintitle.format(int(O2_percent)))
elif (select == 3):
wintitle = '[Ramp: {:d}%]'
win.setWindowTitle(wintitle.format(int(ramp)))
elif (select == 4):
wintitle = '[Ppeak: {:d}]'
win.setWindowTitle(wintitle.format(int(Ppeak*1.01972)))
elif (select == 5):
wintitle = '[PEEP: {:d}]'
win.setWindowTitle(wintitle.format(int(PEEP*1.01972)))
elif (select == 6):
wintitle = '[Respi: {:d}/min]'
win.setWindowTitle(wintitle.format(int(respi_rate)))
elif (select == 7):
wintitle = '[I:E: {:d}%]'
win.setWindowTitle(wintitle.format(int(inspi_percent)))
elif (select == 8):
wintitle = '[PE d: {:d}%]'
win.setWindowTitle(wintitle.format(int(PEEP_dec_rate)))
elif (select == 9):
wintitle = '[PE t: {:d}%]'
win.setWindowTitle(wintitle.format(int(PEEP_tuning)))
elif (select == 10):
wintitle = '[FE: {:d}%]'
win.setWindowTitle(wintitle.format(int(Fl_PEEP)))
elif (select == 11):
wintitle = '[OE: {:d}%]'
win.setWindowTitle(wintitle.format(int(O2_PEEP)))
elif (select == 12):
wintitle = '[PI dlta: {:.1f}]'
win.setWindowTitle(wintitle.format(PEEP_inspi_detection_delta*1.01972))
elif (select == 13):
wintitle = '[VI dlta: {:d}ml]'
win.setWindowTitle(wintitle.format(int(vol_inspi_detection_delta)))
elif (select == 14):
wintitle = '[I dlta: {:d}ms]'
win.setWindowTitle(wintitle.format(int(inspi_detection_delta_duration)))
elif (select == 15):
wintitle = '[F th: {:.2f}]'
win.setWindowTitle(wintitle.format(flow_thresh))
else:
if ((int(t_t0) % 10) > 5): # Alternate text displayed
wintitle = 'Mode: {:d} Flow: {:d} O2: {:d}% Ramp: {:d}% Ppeak: {:d} PEEP: {:d} Respi: {:d}/min I:E: {:d}%'
win.setWindowTitle(wintitle.format(int(mode), int(flow_control), int(O2_percent), int(ramp), int(Ppeak*1.01972), int(PEEP*1.01972), int(respi_rate), int(inspi_percent)))
else:
wintitle = 'PE d: {:d}% PE t: {:d}% FE: {:d}% OE: {:d}% PI dlta: {:.1f} VI dlta: {:d}ml I dlta: {:d}ms F th: {:.2f}'
win.setWindowTitle(wintitle.format(int(PEEP_dec_rate), int(PEEP_tuning), int(Fl_PEEP), int(O2_PEEP), PEEP_inspi_detection_delta*1.01972, int(vol_inspi_detection_delta), int(inspi_detection_delta_duration), flow_thresh))
if ((alarms != 0) and ((int(t_t0) % 2) == 0)):
wintitle = 'Alarm 0x{:04X} : '
if ((alarms & HARDWARE_ALARM) > 0):
wintitle = wintitle+'Check sensors, '
if ((alarms & OS_ALARM) > 0):
wintitle = wintitle+'Restart or check SD, '
if ((alarms & PRESSURE_ALARM) > 0):
wintitle = wintitle+'Pressure too low or high, '
if ((alarms & FLOW_ALARM) > 0):
wintitle = wintitle+'Flow too low or high, '
if ((alarms & VOL_ALARM) > 0):
wintitle = wintitle+'Volume too low or high, '
if ((alarms & PPEAK_ALARM) > 0):
wintitle = wintitle+'Ppeak not reached, '
if ((alarms & PEEP_ALARM) > 0):
wintitle = wintitle+'PEEP not reached, '
wintitle = wintitle[:-2]
win.setWindowTitle(wintitle.format(int(alarms)))
if debug:
if (debug_prev != debug):
win.move(-4, 4)
win.resize(800, 420)
plt.setTitle('Temp. I: {:.2f} C, Temp. E: {:.2f} C'.format(temperature, temperature_e))
plt2.setTitle('Temp. A: {:.2f}, E: {:.2f}, O: {:.2f}'.format(temperature_air, temperature_expi, temperature_O2))
plt.show()
plt2.show()
plt3.hide()
plt4.hide()
plt5.hide()
plt6.hide()
else:
if (debug_prev != debug):
win.move(-10, -32)
win.resize(808, 452)
plt.hide()
plt2.hide()
plt3.show()
if (mode == 2):
plt4.hide()
plt5.hide()
plt6.show()
else:
plt4.show()
plt5.show()
plt6.hide()
debug_prev = debug
mode_prev = mode
# Should ensure that no ValueError exception can happen here to avoid lists of different length,
# so no float conversion should be done in the append()...
t_plot.append(t_t0)
p_cmh2o_plot.append(p_cmh2o)
p_e_cmh2o_plot.append(p_e_cmh2o)
Ppeak_plot.append(Ppeak)
PEEP_plot.append(PEEP)
flow_control_air_plot.append(flow_control*max(0.0, 1.0-O2_percent*0.01))
flow_control_O2_plot.append(flow_control*O2_percent*0.01)
valve_air_plot.append(float(valve_air)/10.0)
valve_O2_plot.append(float(valve_O2)/10.0)
valve_expi_plot.append(float(valve_expi)/10.0)
flow_air_plot.append(flow_air)
flow_expi_plot.append(flow_expi)
flow_O2_plot.append(flow_O2)
flow_filtered_air_plot.append(flow_filtered_air)
flow_filtered_expi_plot.append(flow_filtered_expi)
flow_filtered_O2_plot.append(flow_filtered_O2)
flow_filtered_plot.append(flow_filtered)
vol_l_plot.append(100.0*vol_l)
if (t_plot[-1]-t_plot[0] > 2*scalex):
t_plot.pop(0)
p_cmh2o_plot.pop(0)
p_e_cmh2o_plot.pop(0)
Ppeak_plot.pop(0)
PEEP_plot.pop(0)
flow_control_air_plot.pop(0)
flow_control_O2_plot.pop(0)
valve_air_plot.pop(0)
valve_O2_plot.pop(0)
valve_expi_plot.pop(0)
flow_air_plot.pop(0)
flow_expi_plot.pop(0)
flow_O2_plot.pop(0)
flow_filtered_air_plot.pop(0)
flow_filtered_expi_plot.pop(0)
flow_filtered_O2_plot.pop(0)
flow_filtered_plot.pop(0)
vol_l_plot.pop(0)
except ValueError:
time.sleep(delay)
else:
time.sleep(delay)
else:
time.sleep(delay)
except EOFError:
file.seek(0, os.SEEK_END) # Might be necessary on recent versions of Linux, see https://lists.gnu.org/archive/html/info-gnu/2018-08/msg00000.html...
c_p_cmh2o.setData(t_plot, p_cmh2o_plot)
c2_p_cmh2o.setData(t_plot, p_cmh2o_plot)
c_p_e_cmh2o.setData(t_plot, p_e_cmh2o_plot)
c_Ppeak.setData(t_plot, Ppeak_plot)
c2_Ppeak.setData(t_plot, Ppeak_plot)
c_PEEP.setData(t_plot, PEEP_plot)
c2_PEEP.setData(t_plot, PEEP_plot)
c_flow_control_air.setData(t_plot, flow_control_air_plot)
c2_flow_control_air.setData(t_plot, flow_control_air_plot)
c_flow_control_O2.setData(t_plot, flow_control_O2_plot)
c2_flow_control_O2.setData(t_plot, flow_control_O2_plot)
c_valve_air.setData(t_plot, valve_air_plot)
c_valve_O2.setData(t_plot, valve_O2_plot)
c_valve_expi.setData(t_plot, valve_expi_plot)
c_flow_air.setData(t_plot, flow_air_plot)
c_flow_expi.setData(t_plot, flow_expi_plot)
c_flow_O2.setData(t_plot, flow_O2_plot)
c_flow_filtered_air.setData(t_plot, flow_filtered_air_plot)
c2_flow_filtered_air.setData(t_plot, flow_filtered_air_plot)
c_flow_filtered_expi.setData(t_plot, flow_filtered_expi_plot)
c_flow_filtered_O2.setData(t_plot, flow_filtered_O2_plot)
c2_flow_filtered_O2.setData(t_plot, flow_filtered_O2_plot)
c_flow_filtered.setData(t_plot, flow_filtered_plot)
c_vol_l.setData(t_plot, vol_l_plot)
c2_vol_l.setData(t_plot, vol_l_plot)
pg.QtGui.QApplication.processEvents()
#count += 1
end_time = time.time()
#print('It has been %0.4f seconds since the loop started' %(end_time - start_time))
file.close()
win.close()