Location: Hodgkin & Huxley (1952) model @ f60338fb964a / BG / scripts_BG / gate_ss.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-03-17 12:12:51+13:00
Desc:
Move the folders to BG; Add open channel testing
Permanent Source URI:
https://staging.physiomeproject.org/workspace/64f/rawfile/f60338fb964a811a3c12944d752e3b0f5165ce39/BG/scripts_BG/gate_ss.m

clear;
clc;
close all;
addpath(genpath('../../cellLib/BG_fit/'))
T = 279.45; % K
phi = 3^((T - 6.3-273.15) / 10);
%% n4 bg
opts = detectImportOptions('gate_n4_BG_ss.csv');
opts.SelectedVariableNames = ['outputs_q_S4_norm']; 
n4_ss = readmatrix('gate_n4_BG_ss.csv',opts);
opts.SelectedVariableNames = ['boundary_conditions_V_m']; 
V_m_n4 = readmatrix('gate_n4_BG_ss.csv',opts)*1000; %V->mV
opts.SelectedVariableNames = [2:(length(opts.VariableNames)-1)];
qn4_name=opts.SelectedVariableNames';
qn4_init_name=strrep(qn4_name,'outputs_','');
wline=find(V_m_n4==-65)+1;
opts.DataLines = [wline wline];
qn4_inits = readmatrix('gate_n4_BG_ss.csv',opts);
% Steady-state gating parameters of HH 
V = transpose(-105:1:65); % unit mV
[alpha,beta]=HH_gate_n(-(V+65),phi);
TF = isnan(alpha);
alpha(TF)=0.1;
n_ss_HH = calc_gss(alpha,beta);
n4_ss_HH = n_ss_HH.^4;
%% m3h bg
opts = detectImportOptions('gate_m3h_BG_ss.csv');
opts.SelectedVariableNames = ['outputs_q_S31_norm']; 
m3h_ss = readmatrix('gate_m3h_BG_ss.csv',opts);
opts.SelectedVariableNames = ['boundary_conditions_V_m']; 
V_m_m3h = readmatrix('gate_m3h_BG_ss.csv',opts)*1000; %V->mV
opts.SelectedVariableNames = [2:(length(opts.VariableNames)-1)];
qm3h_name=opts.SelectedVariableNames';
qm3h_init_name=strrep(qm3h_name,'outputs_','');
wline=find(V_m_m3h==-65)+1;
opts.DataLines = [wline wline];
qm3h_inits = readmatrix('gate_m3h_BG_ss.csv',opts);
% Steady-state gating parameters of HH 
V = transpose(-105:1:65); % unit mV
[alpha,beta]=HH_gate_m(-(V+65),phi);
TF = isnan(alpha);
alpha(TF)=1;
m_ss_HH = calc_gss(alpha,beta);
[alpha,beta]=HH_gate_h(-(V+65),phi);
h_ss_HH = calc_gss(alpha,beta);
m3h_ss_HH = m_ss_HH.^3.*h_ss_HH;

%% Write for CellML
q_name=strcat([qm3h_init_name;qn4_init_name],'_init');
q_init=num2cell([qm3h_inits,qn4_inits]);
q_unit=strcat('fmol',cell(1,length(q_name)));
blanks=strcat('',cell(1,(length(qm3h_init_name)+length(qn4_init_name))));
data_all=[blanks;q_name';q_unit;q_init;];
fileID = fopen('Init_paras_CellML.txt','w');
fprintf(fileID,'%7s var %s: %s {init: %g, pub: out};\n',data_all{:});
%% Plot for comparison
h=figure;
width=400*2;
height=350;
x0=100;
y0=50;
set(gcf,'position',[x0,y0,width,height])
t=tiledlayout(1,2);
ax = nexttile;
plot(ax,V,n4_ss_HH,'k--','LineWidth',2);
hold ('on');
plot(ax,V_m_n4,n4_ss,'k','LineWidth',2);
xlabel('Voltage (mV)');
ylabel(['n^4_{ss}']);
xlim([-120 60]);
set(gca,'XTick',-120:30:60);
xticklabels({-120,'',-60,'',0,'',60});
set(gca,'LineWidth',2);
grid on;
legend('HH','BG','Location','best')
ax = nexttile;
plot(ax,V,m3h_ss_HH,'k--','LineWidth',2);
hold ('on');
plot(ax,V_m_m3h,m3h_ss,'k','LineWidth',2);
xlabel('Voltage (mV)');
ylabel(['m^3h_{ss}']);
xlim([-120 60]);
set(gca,'XTick',-120:30:60);
xticklabels({-120,'',-60,'',0,'',60});
set(gca,'LineWidth',2);
grid on;
title(t,'Steady state')
filename='gate_ss';
savefig(h,sprintf('%s.fig',filename))
exportgraphics(h,sprintf('%s.eps',filename));