Location: Tong_2011_V1 @ a03f680a6922 / Experiments / Figure_7 / Fig7_plt.py

Author:
Leyla <noroozbabaee@gmail.com>
Date:
2022-05-10 14:01:08+12:00
Desc:
Adding Tong_2011 to PMR
Permanent Source URI:
https://models.cellml.org/workspace/85c/rawfile/a03f680a69226c515cd789723c8036028406852b/Experiments/Figure_7/Fig7_plt.py

# Author: Leyla Noroozbabaee
# Date: 12/12/2021
# To reproduce Figure 6 from original paper, the python file 'Fig7_sim.py' should be run.

import matplotlib.pyplot as plt
import pandas as pd
from sklearn import preprocessing
import numpy as np
# Figure name
prefilename = 'Fig7'

# Set figure dimension (width, height) in inches.
fw, fh = 15, 10
# Set subplots
subpRow, subpCol = 2, 2
ax, lns = {}, {}

# This gives list with the colors from the cycle, which you can use to iterate over.
cycle = plt.rcParams [ 'axes.prop_cycle' ].by_key() [ 'color' ]
# Set subplots
lfontsize, labelfontsize = 10, 15  # legend, label fontsize
fig, axs = plt.subplots(subpRow, subpCol, figsize=(fw, fh), facecolor='w', edgecolor='k')
fig.subplots_adjust(hspace = .3, wspace=.3)
axs = axs.ravel()
varName = np.array(["Time", "sss", "xss", "stc", "xtc","ika", "v"])
filename = '%s.csv' % (prefilename)
print(filename)
data = pd.read_csv(filename)
print('filename', filename)
data = pd.read_csv(filename)
time = data [ varName[0] ]
sss_data = data [varName[1]]
xss_data = data [varName[2]]
stc_data = data [varName[3]]
xtc_data = data [varName[4]]
ika_data = data [varName[5]]
v_data = data [varName[6]]
axs[0].plot( v_data, pow(sss_data,1), 'b', v_data, xss_data, '--b')
# axs[1].plot(v_data, ptc_data, 'b')
# axs[2].semilogy(v_data, k1tc_data/1000, 'b',  v_data, k2tc_data/1000, '--b')

#axs[4].plot( v_data, ika_data, 'b')
# Set ylable
tit = ['Steady state','Steady state','Time constant (ms)','Time constant (ms)','I (normalised)','I (normalised)']
cycle = plt.rcParams [ 'axes.prop_cycle' ].by_key() [ 'color' ]
# To add the extracted data from original paper to your plot, modify the path to have access to the
# "Extracted_data"
I_V = []
prefilename = 'Fig7_3'
# V =[-60]
# V =[50, 40, 30, 25, 20, 10, 0,-10,-20,-30,-40,-50,-60, -70,-80]
V =  [-40,-30,-20,-10,0, 10 ]
#for i in range(5,10):
for i in range(len(V)):
    filename5 = '%s_%s.csv' % (prefilename, 5)
    data5 = pd.read_csv(filename5)
    print('filename', filename5)
    ika_data5 = data5 ['ika']
    max_ika_data5 = max(abs(data5 ['ika']))
    filename = '%s_%s.csv' % (prefilename, i)
    data = pd.read_csv(filename)
    print('filename', filename)
    time = data ['Time']
    ika_data = data ['ika']
    max_ika_data = max(data['ika'])
    print('max_ika_data', max_ika_data5)
    # if 5 <= i < 11:
    axs [ 2 ].plot(time / 1000, ika_data/max_ika_data5 , color=cycle [ i % 4 ])
    axs [ 3 ].plot(time / 1000, ika_data / max_ika_data5, color=cycle [ i % 4 ])
    axs [ 2 ].set_xlim([ 0, 10 ])
    axs [ 3 ].set_xlim([ 0, 0.5 ])
    #axs [4].plot( time, ika_data, color=cycle [i % 4])
    MAX_I_V = (min(ika_data / max_ika_data5))
    I_V.append(MAX_I_V )


# v_clamp =[50, 40, 30, 25, 20, 10, 0,-10,-20,-30,-40,-50,-60, -70,-80]
# print(I_V)
# axs[5].plot(V, I_V, '-b')# y_data = data [ var [ i ]
prefilename = 'Fig7'

# for i in range(6):
#     filename = '%s_%s.csv' % (prefilename,  i+1)
#     data = pd.read_csv(filename)
#     data = pd.read_csv(filename)
#     y_d = data [ 'Curve1' ]
#     x_d = data [ 'x' ]
#     axs [ i ].plot(x_d, y_d, 'k*')
#    # axs [ i ].set_xlim([ -90, 60 ])
#     axs [ i ].set_xlabel('V (mV)', fontsize=labelfontsize)
#     axs [ i ].set_ylabel('%s' % (tit [ i ]), fontsize=labelfontsize)
#     if i == 0 or i == 3:
#         y_d_2 = data [ 'Curve2' ]
#         axs [ 0 ].plot(x_d, y_d_2, 'k*')
#         #axs [ 3 ].plot(x_d, y_d_2, 'k*')
#     elif i == 1:
#         # y_d_2 = data [ 'Curve1' ]
#         axs [ 1 ].semilogy(x_d, y_d, 'k*')
#     elif i == 2:
#         y_d_2 = data [ 'Curve2' ]
#         axs [ i ].semilogy(x_d, y_d, 'k*', x_d, y_d_2, 'k*')
#
#     elif i == 4 or i == 5 :
#         y_d_2 = data [ 'Curve2' ]
#         y_d_3 = data [ 'Curve3' ]
#         y_d_4 = data [ 'Curve4' ]
#         y_d_5 = data [ 'Curve5' ]
#         axs [ 4 ].plot(x_d, y_d_2, '*', x_d, y_d_3, '*', x_d, y_d_4, '*', x_d, y_d_5, '*', color=cycle [ i % 4 ])
#         axs [ 5 ].plot(x_d, y_d_2, '*', x_d, y_d_3, '*', x_d, y_d_4, '*', x_d, y_d_5, '*', color=cycle [ i % 4 ])
#      #   axs [ i ].set_xlim([ 0, 50 ])
#         axs [ i ].set_xlabel('Time (ms)', fontsize=labelfontsize)
#       #  axs [ i ].set_ylim([ -1, 0 ])
#
#     axs [i].set_xlabel('V (mV)', fontsize=labelfontsize)
#     axs [i].set_ylabel('%s' % (tit[i]),fontsize=labelfontsize)
#


# prefilename = 'Fig7_3'
# prename = 'max_ika'
# # V =[-60]
# # V =[50, 40, 30, 25, 20, 10, 0,-10,-20,-30,-40,-50,-60, -70,-80]
# V_max =  [ -30, -20, -10, 0, 10,20,30,40,-30, -20, -10, 0, 10,20,30,40]
# V =  [ -30, -20, -10, 0, 10,20,30,40]
# I_max = []
# for j in range(2):
#
#     name = '%s_%s' % (prename, j)
#     name = []
#     for i in range(len(V)):
#         filename = '%s_%s_%s.csv' % (prefilename, j,i)# % (prefilename, 0)
#         print('filename', filename)
#         data = pd.read_csv(filename)
#         # print('filename', filename5)
#         ika_data = data ['v']
#         max_ika_data1 = max((data ['ika']))
#
#         print(I_max)
#         # filename = '%s_%s_%s.csv' % (prefilename, j,i)
#         # data = pd.read_csv(filename)
#         # print('filename', filename)
#         # time = data ['Time']
#         # ika_data = data ['ika']
#         # v_data = data [ 'v' ]
#         v_max = np.reshape(V_max, (1,-1))
#         if max_ika_data1 < 0:
#             MAX_I_V = abs((max(data ['ika'])))
#         else:
#             MAX_I_V =abs((max(data ['ika'])))
#         I_max.append(MAX_I_V )
#
#         print(max_ika_data)
# axs [ 3 ].plot(V_max, np.array(I_max), '*k')

figfiles = '%s.png' % (prefilename)
plt.savefig(figfiles)
plt.show()

##axs[1].semilogy( v_data, htc_data, 'b', v_data, mtc_data, 'r')