- Author:
- WeiweiAi <wai484@aucklanduni.ac.nz>
- Date:
- 2022-03-31 10:48:40+13:00
- Desc:
- Add open channel IV of HH models; Add simulation and plot python scripts
- Permanent Source URI:
- https://staging.physiomeproject.org/workspace/64f/rawfile/ab2962b8796666ad9938a2577611c954f006b5fd/BG/scripts_BG/APFigs.py
# importing modules
from asyncio import constants
import sys as sys
import os
import numpy
import pandas as pd
import matplotlib.pyplot as plt
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__)) # scripts_BG
# Getting the parent directory name
# where the current directory is present.
parent = os.path.dirname(current) # BG
gparent = os.path.dirname(parent) # VPH-MIP
mpath = gparent + '\\cellLib\\src'
# appending a path
sys.path.append(mpath)
import plotExp
colors=plt.rcParams['axes.prop_cycle'].by_key()['color']
figfiles=current+'\\AP_compare.png'
# maxH=8.75 inches, width 2.63-7.5
rows,cols = 4,2
width, height= cols*3.5, rows*2.2
left = 0.125 # the left side of the subplots of the figure,0.125
right = 0.9 # the right side of the subplots of the figure,0.9
bottom = 0.1 # the bottom of the subplots of the figure, 0.1
top = 0.95 # the top of the subplots of the figure 0.9
wspace = 0.5 # the amount of width reserved for space between subplots,
# expressed as a fraction of the average axis width, 0.2
hspace = 0.4 # the amount of height reserved for space between subplots,
# expressed as a fraction of the average axis height, 0.2
figs ={ 'width':width, 'height': height, 'rows': rows, 'cols': cols,'left':left,'bottom':bottom,'right':right,'top':top,'wspace': wspace,'hspace': hspace}
lgdfont, labelfont =11, 12
ofilename=current+'\\AP_HH.csv'
odata = pd.read_csv(ofilename)
ox_data = odata['time']
nfilename=current+'\\AP_BG.csv'
ndata = pd.read_csv(nfilename)
nx_data = ndata['time']*1000 #ms
A_cap=0.3
gK_max=36.0
gNa_max=120.0
ovarSave = {'outputs/INa','outputs/IK','outputs/gNa','outputs/gK','outputs/Ileak','outputs/Ii',}
nvarSave = {'outputs/I_Na','outputs/I_K','outputs/q_S31_norm','outputs/q_S4_norm','outputs/I_leak','outputs/I_i',}
ylabels = ['$I_{Na}$(fA)','$I_{K}$(fA)','$g_{Na}$','$g_{K}$','$I_{leak}$(fA)','$I_{i}$(fA)']
ylabel2s = ['$q_{S31}$','$q_{S4}$',]
oy_data = -odata['outputs/V']-65 # shift
ny_data = ndata['outputs/V_m']*1000 # V -> mV
trace={}
trace[1]={'dataX': ox_data, 'dataY': oy_data, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[2]={'dataX': nx_data, 'dataY': ny_data, 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[3]={'dataX': ox_data, 'dataY': odata['outputs/INa']*A_cap*1e9, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[4]={'dataX': nx_data, 'dataY': ndata['outputs/I_Na'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[5]={'dataX': ox_data, 'dataY': odata['outputs/IK']*A_cap*1e9, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[6]={'dataX': nx_data, 'dataY': ndata['outputs/I_K'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[7]={'dataX': ox_data, 'dataY': odata['outputs/gNa']/gNa_max, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[8]={'dataX': nx_data, 'dataY': ndata['outputs/q_S31_norm'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[9]={'dataX': ox_data, 'dataY': odata['outputs/gK']/gK_max, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[10]={'dataX': nx_data, 'dataY': ndata['outputs/q_S4_norm'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[11]={'dataX': ox_data, 'dataY': odata['outputs/Ileak']*A_cap*1e9, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[12]={'dataX': nx_data, 'dataY': ndata['outputs/I_leak'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
trace[13]={'dataX': ox_data, 'dataY': odata['outputs/Ii']*A_cap*1e9, 'lname': 'HH', 'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace[14]={'dataX': nx_data, 'dataY': ndata['outputs/I_i'], 'lname': 'BG', 'linestyle':'-', 'marker':'', 'linecolor':colors[1],'y2':False}
subfigs={'1':
{'rowid':0, 'colid':0, 'xlabel': 'time (ms)', 'ylabel':'$V_m$ (mV)', 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[1],'2':trace[2]}
},
'2':
{'rowid':0, 'colid':1, 'xlabel': 'time (ms)', 'ylabel':'$V_m$ (mV)', 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[1],'2':trace[2]}
},
'3':
{'rowid':1, 'colid':0, 'xlabel': 'time (ms)', 'ylabel':ylabels[0], 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[3],'2':trace[4]}
},
'4':
{'rowid':1, 'colid':1, 'xlabel': 'time (ms)', 'ylabel':ylabels[1], 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[5],'2':trace[6]}
},
'5':
{'rowid':2, 'colid':0, 'xlabel': 'time (ms)', 'ylabel':ylabels[2], 'twiny':False, 'ylabel2':ylabel2s[0],'labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[7],'2':trace[8]}
},
'6':
{'rowid':2, 'colid':1, 'xlabel': 'time (ms)', 'ylabel':ylabels[3], 'twiny':False, 'ylabel2':ylabel2s[1],'labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[9],'2':trace[10]}
},
'7':
{'rowid':3, 'colid':0, 'xlabel': 'time (ms)', 'ylabel':ylabels[4], 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[11],'2':trace[12]}
},
'8':
{'rowid':3, 'colid':1, 'xlabel': 'time (ms)', 'ylabel':ylabels[5], 'twiny':False, 'ylabel2':'','labelcolor':colors[1],
'lgdshow': True, 'lgdloc':'best', 'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,
'setlim': False, 'xmin':0, 'xmax': 1, 'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both',
'traces':{'1':trace[13],'2':trace[14]}
},
}
fig,axs=plotExp.plotExp(figs,subfigs,figfiles)