Location: Hodgkin & Huxley (1952) model @ ab2962b87966 / BG / scripts_BG / IVFigs.py

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://models.cellml.org/workspace/64f/rawfile/ab2962b8796666ad9938a2577611c954f006b5fd/BG/scripts_BG/IVFigs.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+'\\IV_compare.png'
# maxH=8.75 inches, width 2.63-7.5
rows,cols = 1,2
width, height= cols*3.5, rows*3
left = 0.15  # the left side of the subplots of the figure,0.125
right = 0.95   # the right side of the subplots of the figure,0.9
bottom = 0.2  # 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.4  # the amount of width reserved for space between subplots,
              # expressed as a fraction of the average axis width, 0.2
hspace = 0.2  # 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+'\\INa_HH_open.csv'
odata = pd.read_csv(ofilename)
ox_data0 = odata['INa_HH_open/V']
oy_data0 = odata['INa_HH_open/I_Na_fA']
nfilename=current+'\\INa_BG_open.csv'
ndata = pd.read_csv(nfilename)
nx_data0 = ndata['boundary_conditions/V_m']
ny_data0 = ndata['outputs/I_Na']

ofilename=current+'\\IK_HH_open.csv'
odata = pd.read_csv(ofilename)
ox_data1 = odata['IK_HH_open/V']
oy_data1 = odata['IK_HH_open/I_K_fA']
nfilename=current+'\\IK_BG_open.csv'
ndata = pd.read_csv(nfilename)
nx_data1 = ndata['boundary_conditions/V_m'] 
ny_data1 = ndata['outputs/I_K']

ylabels = ['$I_{Na}$','$I_{K}$',]
   
trace1={'dataX': ox_data0, 'dataY': oy_data0, 'lname': 'HH',  'linestyle':'--', 'marker':'', 'linecolor':colors[0],'y2':False}
trace2={'dataX': nx_data0, 'dataY': ny_data0, 'lname': 'BG',  'linestyle':'-', 'marker':'',  'linecolor':colors[0],'y2':False}
trace3={'dataX': ox_data1, 'dataY': oy_data1, 'lname': 'HH',  'linestyle':'--', 'marker':'',  'linecolor':colors[0],'y2':False}
trace4={'dataX': nx_data1, 'dataY': ny_data1, 'lname': 'BG',  'linestyle':'-', 'marker':'',  'linecolor':colors[0],'y2':False}

subfigs={'1':
          {'rowid':0, 'colid':0, 'xlabel': '$V_m$ (mV)', 'ylabel':'$I_{Na}$(fA)', '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':trace1,'2':trace2}
         },

         '2':
          {'rowid':1, 'colid':0, 'xlabel': '$V_m$ (mV)', 'ylabel':'$I_{K}$(fA)', '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':trace3,'2':trace4}
         }
}


fig,axs=plotExp.plotExp(figs,subfigs,figfiles)