Location: Tong_2011_V1 @ a03f680a6922 / Experiments / Figure_2 / Fig2_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_2/Fig2_plt.py

# Author: Leyla Noroozbabaee
# Date: 12/12/2021
# To reproduce Figure 6 from original paper, the python file 'Fig6_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 = 'Fig2'

# 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()
var_name = np.array(["Time", "hss", "mss", "htc", "mtc", "ina", "v"])

filename = '%s.csv' % (prefilename)
print(filename)
data = pd.read_csv(filename)
print('filename', filename)
data = pd.read_csv(filename)
time = data [ var_name[0] ]
hss_data = data [var_name[1]]
mss_data = data [var_name[2]]
htc_data = data [var_name[3]]
mtc_data = data [var_name[4]]
ina_data = data [var_name[5]]
v_data = data [var_name[6]]

axs[0].plot( v_data, hss_data, 'b', v_data, pow(mss_data,3), 'r')
axs[1].semilogy( v_data, htc_data, 'b', v_data, mtc_data, 'r')# y_data = data [ var [ i ] ]

# Set ylable
tit = ['Steady state','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"
prefilename = 'Fig2'

for i in range(4):
    filename = '%s_%s.csv' % (prefilename,  i+1)
    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([ -100, 50 ])
    axs [i].set_xlabel('V (mV)', fontsize=labelfontsize)
    axs [i].set_ylabel('%s' % (tit[i]),fontsize=labelfontsize)
    if i == 0 or i == 1:
        y_d_2 = data [ 'Curve2' ]
        axs [ i ].plot(x_d, y_d_2, 'k*')
    elif i == 2:
        y_d_2 = data [ 'Curve2' ]
        y_d_3 = data [ 'Curve3' ]
        y_d_4 = data [ 'Curve4' ]
        y_d_5 = data [ 'Curve5' ]
        axs [ i ].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 ])
    # plt.tick_params(direction='in', axis='both')


I_V = []


for i in range(11):
    prefilename = 'Fig2_3'
    filename5 = '%s_%s.csv' % (prefilename, 4)
    data5 = pd.read_csv(filename5)
    print('filename', filename5)
    ina_data5 = data5 ['ina']
    max_ina_data5 = max(abs(data5 ['ina']))
    filename = '%s_%s.csv' % (prefilename, i)
    data = pd.read_csv(filename)
    print('filename', filename)
    time = data ['Time']
    ina_data = data ['ina']
    max_ina_data = max(data ['ina'])
    print(' max_ina_data ', max_ina_data5)
    if  5<=i<11:
         axs [2].plot( time, ina_data/max_ina_data5, color=cycle [i % 4])
    if max_ina_data  < 0:
        MAX_I_V = (min(ina_data / max_ina_data5))
    else:
        MAX_I_V = (max(ina_data / max_ina_data5))
    I_V.append(MAX_I_V )

V = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]
print(I_V)
axs[3].plot(V, I_V, '-b')
figfiles = '%s.png' % (prefilename)
plt.savefig(figfiles)
plt.show()
# import matplotlib.pyplot as plt
# import pandas as pd
# from sklearn import preprocessing
# import numpy as np
# # Figure name
# prefilename = 'Fig2'
# #figfile = 'Figure_8_origin'
# # Read data from the files
# # x_name = 'Time'
# # y_name = 'fss'
# # z_name = ['I_inj']
# # current = r'$I_{Aon1}(pA)$'
# # print(current)
# # y_labels = [ '%s' % current ]
#
# suffix = [ 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' ]
# c = ['a','b','c','d']
# # Set figure dimension (width, height) in inches.
# fw, fh = 15, 10
# # Set subplots
# subpRow, subpCol = 2, 2
# ax, lns = {}, {}
# # Set Title
# tit = ['1s','2 s','1s','2 s','1s','2 s']
# # 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 = .1, wspace=.1)
# axs = axs.ravel()
# var_name = np.array(["Time", "hss", "mss", "htc", "mtc", "ina", "v"])
# # y_name =['fss'];
# x_base =[0.4, 0.6]
#
# filename = '%s.csv' % (prefilename)
# print(filename)
# data = pd.read_csv(filename)
# print('filename', filename)
# data = pd.read_csv(filename)
# time = data [ var_name[0] ]
# hss_data = data [var_name[1]]
# mss_data = data [var_name[2]]
# htc_data = data [var_name[3]]
# mtc_data = data [var_name[4]]
# ina_data = data [var_name[5]]
# v_data = data [var_name[6]]
#
# axs[0].plot( v_data, hss_data, 'b', v_data, pow(mss_data,3), 'r')
# axs[1].semilogy( v_data, htc_data, 'b', v_data, mtc_data, 'r')# y_data = data [ var [ i ] ]
# #axs[3].plot( ,  v_data, f2tc_data, 'k')
# #axs[3].plot( v_data, ina_data, 'k')
#
# prefilename = 'Fig2'
# # for i in range(1,2):
# #     filename = '%s_%s.csv' % (prefilename,  i)
# #     print('filename', filename, i)
# #     data = pd.read_csv(filename)
# #     y_d = data [ 'Curve1' ]
# #    #y_d1 = data [ 'Curve2' ]
# #     x_d = data [ 'x' ]
# #     axs [ i ].plot(x_d, y_d, 'k*')
# #     plt.tick_params(direction='in', axis='both')
#
# filename = '%s_%s.csv' % (prefilename, 2)
# print('filename', filename, 2)
# data = pd.read_csv(filename)
# y_d = data [ 'Curve1' ]
# y_d1 = data [ 'Curve2' ]
# x_d = data [ 'x' ]
# axs [ 2 ].plot(x_d, y_d, 'k*',x_d, y_d1, 'k*')
# plt.tick_params(direction='in', axis='both')
# I_V = []
#
# prefilename = 'Fig2_3'
# for i in range(11):
#
#     filename5 = '%s_%s.csv' % (prefilename,5)
#     data5 = pd.read_csv(filename5)
#     print('filename', filename5)
#     ina_data5 = data5 ['ina']
#     max_ina_data5 = max(abs(data5 ['ina']))
#     filename = '%s_%s.csv' % (prefilename, i)
#     data = pd.read_csv(filename)
#     print('filename', filename)
#     time = data ['Time']
#     ina_data = data ['ina']
#     max_ina_data = max(data ['ina'])
#     print(' max_ina_data ',max_ina_data5)
#     if  5<=i<11:
#
#          axs [2].plot( time, ina_data/max_ina_data5, color=cycle [i % 4])#, label='%d mV ' % (V))
#     # axs [6 ].plot(time, itot_data [ 0 ], color=cycle [ i % 4 ])  # , label='%d mV ' % (V))
#     # axs [7 ].plot(time, ina_tot_data [ 0 ], color=cycle [ i % 4 ])  # , label='%d mV ' % (V))
#     MAX_I_V = (min(ina_data / max_ina_data5))
#     I_V.append(MAX_I_V )
#
# V =[50, 40, 30, 20, 10, 0,-10,-20,-30,-40,-50]
# print(I_V)
# axs[3].plot(V, I_V, '-b')# y_data = data [ var [ i ]
# prefilename = 'Fig2'
# filename = '%s_%s.csv' % (prefilename, 4)
# print('filename', filename, 4)
# data = pd.read_csv(filename)
# y_d = data [ 'Curve1' ]
#
# x_d = data [ 'x' ]
# axs [ 3 ].plot(x_d, y_d, 'k*')
# figfiles = '%s.png' % (prefilename)
# plt.savefig(figfiles)
# plt.show()
#
# figfiles = '%s.png' % (prefilename)
# plt.savefig(figfiles)
# plt.show()
#