- Author:
- nima <nafs080@aucklanduni.ac.nz>
- Date:
- 2021-06-10 17:38:41+12:00
- Desc:
- Files renamed, visualisation improved
- Permanent Source URI:
- https://staging.physiomeproject.org/workspace/648/rawfile/03b1f4674de2914f0c9ab16c8154951773b3eafd/Figure5-plot.py
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# read the csv file extracted from sedml file
data = pd.read_csv('Fig05.csv')
#clean the data
data = data.loc[:, ~data.columns.str.contains('^Unnamed')]
data = data.drop(columns=["time"])
cl = []
for i in range(0, 7):
cl.append(data.index[data.T.iloc[i] == data.T.iloc[i][700:1500].min()].values[-1] -
data.index[data.T.iloc[i] == data.T.iloc[i][200:700].min()].values[-1])
print(cl)
y_shift = [-15, -10, -5, 0, 5, 10, 15]
plt.figure(figsize=(14, 14))
plt.subplot(2, 2, 1)
plt.plot(y_shift, cl, 'navy', linestyle='', marker='D', markersize='14', label='', linewidth=3)
plt.grid()
plt.ylim(400, 1200)
plt.yticks(np.arange(400,1300,200))
plt.xlabel('y$_{\infty}$ shift', fontsize=16)
plt.tick_params(axis='both', labelsize=14)
plt.ylabel('CL (ms)', fontsize=16)
plt.title('A', loc= 'left', y = 1.05, x= -0.06, fontsize='20')
DDR = []
for i in range(0, 7):
A = data.T.iloc[i][200:700].min()
end = (data.index[data.T.iloc[i] == data.T.iloc[i][200:700].min()][-1] + 100)
B = data.T.iloc[i][end]
DDR.append((B - A) * 10)
print(DDR)
plt.subplot(2, 2, 2)
plt.plot(y_shift, DDR, 'navy', linestyle='', marker='D', markersize='14', label='', linewidth=3)
plt.grid()
plt.ylim(20, 80)
plt.yticks(np.arange(20,90,20))
plt.xlabel('y$_{\infty}$ shift', fontsize='16')
plt.ylabel('DDR$_{100}$ (mV/s)', fontsize='16')
plt.tick_params(axis='both', labelsize=14)
plt.title('B', loc= 'left', y = 1.05, x= -0.06, fontsize='20')
MDP = []
for i in range(0, 7):
A = data.T.iloc[i].min()
MDP.append(A)
print(MDP)
plt.subplot(2, 2, 3)
plt.plot(y_shift, MDP, 'navy', linestyle='', marker='D', markersize='14', label='')
plt.grid()
plt.ylim(-65, -50)
plt.yticks(np.arange(-65, -45, 5))
plt.xlabel('y$_{\infty}$ shift', fontsize='16')
plt.ylabel('MDP (mV)', fontsize='16')
plt.tick_params(axis='both', labelsize=14)
plt.title('C', loc= 'left', y = 1.05, x= -0.06, fontsize='20')
APD = []
dys = []
for i in range(0, 7):
y = data.T.iloc[i][:601]
dy = np.gradient(y)
dys.append(dy)
a = dy[dy > 0.5]
neg = dy[dy < 0]
start = np.where(dy == a[0])
end = np.where(dy == neg[:int(neg.shape[0] * 0.9)][-1])
duration = end[0][-1] - start[0][-1]
APD.append(duration)
print(APD)
plt.subplot(2, 2, 4)
plt.plot(y_shift, APD, 'navy', linestyle='', marker='D', markersize='14', label='')
plt.grid()
plt.ylim(150, 190)
plt.xlabel('y$_{\infty}$ shift', fontsize='16')
plt.ylabel('APD$_{90}$ (ms)', fontsize='16')
plt.tick_params(axis='both', labelsize=14)
plt.title('D', loc= 'left', y = 1.05, x= -0.06, fontsize='20')
plt.subplots_adjust(left=0.1,
bottom=0.5,
right=3.5,
top=2,
wspace=0.4,
hspace=0.4)
plt.savefig('figure5.png')
plt.show()