diff --git a/functions.py b/functions.py index 562dc55..a3f9367 100644 --- a/functions.py +++ b/functions.py @@ -7,6 +7,7 @@ from tkinter import Tk from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory import pandas as pd import tkinter as tk +from statistics import mean from scipy.signal import find_peaks @@ -81,15 +82,30 @@ def pressure(folder,N_ts,T_cyc,dt,n_cyc): Nc = round(T_cyc/dt) time = np.linspace(0,T_cyc,Nc) fig, ax = plt.subplots() + # SBP = [] + # DBP = [] + # MBP = [] + SBP = np.empty(pressure.shape[1]) + DBP = np.empty(pressure.shape[1]) + MBP = np.empty(pressure.shape[1]) for i in range(0,pressure.shape[1]): - ax.plot(time,pressure[N_ts-Nc:N_ts,-i]/1333.22,label='ROI-'+str(i+2)) - + ax.plot(time,pressure[N_ts-Nc:N_ts,i]/1333.22,label='ROI-'+str(i+2)) + # SBP.append(np.amax(pressure[N_ts-Nc:N_ts,i]/1333.22)) + # DBP.append(np.amin(pressure[N_ts-Nc:N_ts,i]/1333.22)) + # MBP.append(mean(pressure[N_ts-Nc:N_ts,i]/1333.22)) + SBP[i] = (np.amax(pressure[N_ts-Nc:N_ts,i]/1333.22)) + DBP[i] = (np.amin(pressure[N_ts-Nc:N_ts,i]/1333.22)) + MBP[i] = (mean(pressure[N_ts-Nc:N_ts,i]/1333.22)) + PP = SBP-DBP ax.set(xlabel='time [s]', ylabel='Pressure [mmHg]', title='Pressure @ each outlet') ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.legend(loc=0) plt.show() + + return (DBP,MBP,SBP,PP) + \ No newline at end of file diff --git a/main.py b/main.py index ead6b2a..705aec8 100644 --- a/main.py +++ b/main.py @@ -49,5 +49,5 @@ error_plot(folder,dt,rc,False) periodicity(project,folder,dt,T_cyc,n_cyc) # Pressure -pressure(folder,N_ts,T_cyc,dt,n_cyc) +(DBP,MBP,SBP,PP) = pressure(folder,N_ts,T_cyc,dt,n_cyc)