Skip to content

Commit

Permalink
Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
mic-pan committed Feb 13, 2018
1 parent 4b44433 commit a67e273
Show file tree
Hide file tree
Showing 18 changed files with 68,351 additions and 122,423 deletions.
49 changes: 34 additions & 15 deletions MATLAB/code/cardiac_AP_sim_single.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,33 @@
W_e = 5.182;

%% Run simulation
tspan = [0 0.8];
tspan = [0 3];
[VOI,STATES,CONSTANTS] = cardiac_AP_exported(tspan,'con');
% Compute algebraic variables
[RATES,ALGEBRAIC] = cardiac_AP_exported_computeRates(VOI, STATES, CONSTANTS);
ALGEBRAIC = cardiac_AP_exported_computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);
t = VOI;

%% Plot membrane voltage
h1 = figure;
h1a = figure;
V = 1000*ALGEBRAIC(:,15);
plot(1000*(t-0.3),V,'k','LineWidth',2);
xlabel('Time (ms)');
ylabel('Voltage (mV)');
xlim(1000*[-0.1 0.4]);
h_arrow = annotation('arrow',[0.5 0.35],[0.45 0.23]);
h_arrow.LineWidth = 2;
h_arrow.HeadLength = 20;
h_arrow.HeadWidth = 20;
xlim(1000*[-0.1 0.3]);
set(gca,'FontSize',16);

%% Plot membrane voltage over three beats
h1b = figure;
V = 1000*ALGEBRAIC(:,15);
plot(1000*(t-0.3),V,'k','LineWidth',2);
xlabel('Time (ms)');
ylabel('Voltage (mV)');
xlim(1000*[-0.1 2.7]);
set(gca,'FontSize',16);

%% Plot intracellular calcium concentration
Expand Down Expand Up @@ -132,35 +145,41 @@
plot(1000*(t-0.3),P/1e3,'k','LineWidth',2);
xlabel('Time (ms)');
ylabel('Power (pW)');
xlim(1000*[-0.1 0.4]);
xlim(1000*[-0.1 2.7]);
set(gca,'FontSize',16);

Idx_post_stim = t>0.3;
num_pre_stim = sum(t<=0.3);
E = cumtrapz(t(Idx_post_stim),P(Idx_post_stim));
E = cumtrapz(t,P);

t_beat = t-0.3;
V_peak = max(V);
V_end = V(end);
idx_ref = find(t >= 1.3,1);
E_ref = E(idx_ref-1);
E_plot = E-E_ref;

idx_start = find(t >= 1.3,1)-1;
idx_end = find(t >= 2.3,1)-1;
t_beat = t-1.3;
V_peak = max(V(idx_start:idx_end));
V_end = V(idx_end);
V_90 = 0.9*V_end + 0.1*V_peak;
Idx_repolarised = find((V <= V_90) & (t_beat > 0.02),1);
Idx_cross = [Idx_repolarised-1 Idx_repolarised];
APD = interp1(V(Idx_cross),t_beat(Idx_cross),V_90);

h6 = figure;
plot(1000*[-0.1; 0; t(Idx_post_stim)-0.3],[0; 0; E/1e3],'k','LineWidth',2);
plot(1000*(t-0.3),E_plot/1e3,'k','LineWidth',2);
hold on;
plot(1000*t_beat(Idx_repolarised),E(Idx_repolarised-num_pre_stim)/1e3,'k.','MarkerSize',30);
text(1000*t_beat(Idx_repolarised)-10,E(Idx_repolarised-num_pre_stim)/1e3-3,['E = ' num2str(round(E(Idx_repolarised-num_pre_stim)/1e3,1)) ' pJ'],...
plot(1000*[-0.1 2.7],[0 0],'b--','LineWidth',2);
plot(1000*(t_beat(Idx_repolarised)+1),E_plot(Idx_repolarised)/1e3,'k.','MarkerSize',30);
text(1000*(t_beat(Idx_repolarised)+1)-15,E_plot(Idx_repolarised)/1e3 - 15,['E = ' num2str(round(E_plot(Idx_repolarised)/1e3,1)) ' pJ'],...
'Color','k','FontSize',16);
xlabel('Time (ms)');
ylabel('Energy (pJ)');
xlim(1000*[-0.1 0.4]);
xlim(1000*[-0.1 2.7]);
set(gca,'FontSize',16);

%% Print figures
if save_figures
print_figure(h1,output_dir,'cardiac_AP_Vm');
print_figure(h1a,output_dir,'cardiac_AP_Vm');
print_figure(h1b,output_dir,'cardiac_AP_Vm3');
print_figure(h2,output_dir,'cardiac_AP_Cai');
print_figure(h3,output_dir,'cardiac_AP_ion_currents');
print_figure(h4,output_dir,'cardiac_AP_other_currents');
Expand Down
72 changes: 36 additions & 36 deletions MATLAB/code/stim_current_comparison.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,42 @@

h_fig = figure;
subplot(6,3,1);
plot(struct_var_con.t(301:1000:end)/60,1000*struct_var_con.V(301:1000:end),'k','LineWidth',2);
plot(struct_var_con.t(301:1000:end)/60,1000*struct_var_con.V(301:1000:end),'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t(301:1000:end)/60,1000*struct_var_ncs.V(301:1000:end),'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t(301:1000:end)/60,1000*struct_var_ncs.V(301:1000:end),'r','LineWidth',2);
xlim([0 30]);
ylabel('V_{dia} (mV)');
set(gca,'FontSize',font_size);
title('A','FontSize',28);

subplot(6,3,4);
plot(struct_var_con.t(1:1000:end-1)/60,struct_var_con.APD,'k','LineWidth',2);
plot(struct_var_con.t(1:1000:end-1)/60,struct_var_con.APD,'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t(1:1000:end-1)/60,struct_var_ncs.APD,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t(1:1000:end-1)/60,struct_var_ncs.APD,'r','LineWidth',2);
xlim([0 30]);
ylabel('APD (ms)');
set(gca,'FontSize',font_size);

subplot(6,3,7);
plot(struct_var_con.t/60,struct_var_con.Ki,'k','LineWidth',2);
plot(struct_var_con.t/60,struct_var_con.Ki,'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t/60,struct_var_ncs.Ki,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t/60,struct_var_ncs.Ki,'r','LineWidth',2);
xlim([0 30]);
ylabel('[K^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,10);
plot(struct_var_con.t/60,struct_var_con.Nai,'k','LineWidth',2);
plot(struct_var_con.t/60,struct_var_con.Nai,'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t/60,struct_var_ncs.Nai,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t/60,struct_var_ncs.Nai,'r','LineWidth',2);
xlim([0 30]);
ylabel('[Na^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,13);
plot(struct_var_con.t(1:1000:end-1)/60,1000*struct_var_con.peak_Ca,'k','LineWidth',2);
plot(struct_var_con.t(1:1000:end-1)/60,1000*struct_var_con.peak_Ca,'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t(1:1000:end-1)/60,1000*struct_var_ncs.peak_Ca,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t(1:1000:end-1)/60,1000*struct_var_ncs.peak_Ca,'r','LineWidth',2);
xlim([0 30]);
ylabel('Peak [Ca^{2+}]_i ({\mu}M)');
xlabel('Time (mins)');
Expand All @@ -94,9 +94,9 @@
initial_charge = struct_var_con.charge(1);

subplot(6,3,16);
plot(struct_var_con.t(1:3001),struct_var_con.charge(1:3001)-initial_charge,'k','LineWidth',2);
plot(struct_var_con.t(1:3001),struct_var_con.charge(1:3001)-initial_charge,'b','LineWidth',2);
hold on;
plot(struct_var_ncs.t(1:3001),struct_var_ncs.charge(1:3001)-initial_charge,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_var_ncs.t(1:3001),struct_var_ncs.charge(1:3001)-initial_charge,'r','LineWidth',2);
ylabel('{\Delta}Charge (fmol)');
xlabel('Time (sec)');
set(gca,'FontSize',font_size);
Expand All @@ -113,51 +113,51 @@
struct_e_ncs.peak_Ca = calc_peak_Ca(struct_e_ncs.t,struct_e_ncs.Cai);

subplot(6,3,2);
plot(struct_e_con.t(301:1000:end)/60,1000*struct_e_con.V(301:1000:end),'k','LineWidth',2);
plot(struct_e_con.t(301:1000:end)/60,1000*struct_e_con.V(301:1000:end),'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t(301:1000:end)/60,1000*struct_e_ncs.V(301:1000:end),'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t(301:1000:end)/60,1000*struct_e_ncs.V(301:1000:end),'r','LineWidth',2);
xlim([0 30]);
ylabel('V_{dia} (mV)');
set(gca,'FontSize',font_size);
title('B','FontSize',28);

subplot(6,3,5);
plot(struct_e_con.t(1:1000:end-1)/60,struct_e_con.APD,'k','LineWidth',2);
plot(struct_e_con.t(1:1000:end-1)/60,struct_e_con.APD,'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t(1:1000:end-1)/60,struct_e_ncs.APD,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t(1:1000:end-1)/60,struct_e_ncs.APD,'r','LineWidth',2);
xlim([0 30]);
ylabel('APD (ms)');
set(gca,'FontSize',font_size);

subplot(6,3,8);
plot(struct_e_con.t/60,struct_e_con.Ki,'k','LineWidth',2);
plot(struct_e_con.t/60,struct_e_con.Ki,'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t/60,struct_e_ncs.Ki,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t/60,struct_e_ncs.Ki,'r','LineWidth',2);
xlim([0 30]);
ylabel('[K^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,11);
plot(struct_e_con.t/60,struct_e_con.Nai,'k','LineWidth',2);
plot(struct_e_con.t/60,struct_e_con.Nai,'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t/60,struct_e_ncs.Nai,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t/60,struct_e_ncs.Nai,'r','LineWidth',2);
xlim([0 30]);
ylabel('[Na^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,14);
plot(struct_e_con.t(1:1000:end-1)/60,1000*struct_e_con.peak_Ca,'k','LineWidth',2);
plot(struct_e_con.t(1:1000:end-1)/60,1000*struct_e_con.peak_Ca,'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t(1:1000:end-1)/60,1000*struct_e_ncs.peak_Ca,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t(1:1000:end-1)/60,1000*struct_e_ncs.peak_Ca,'r','LineWidth',2);
xlim([0 30]);
ylabel('Peak [Ca^{2+}]_i ({\mu}M)');
xlabel('Time (mins)');
set(gca,'FontSize',font_size);

subplot(6,3,17);
plot(struct_e_con.t(1:3001),struct_e_con.charge(1:3001)-initial_charge,'k','LineWidth',2);
plot(struct_e_con.t(1:3001),struct_e_con.charge(1:3001)-initial_charge,'b','LineWidth',2);
hold on;
plot(struct_e_ncs.t(1:3001),struct_e_ncs.charge(1:3001)-initial_charge,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_e_ncs.t(1:3001),struct_e_ncs.charge(1:3001)-initial_charge,'r','LineWidth',2);
ylabel('{\Delta}Charge (fmol)');
xlabel('Time (sec)');
set(gca,'FontSize',font_size);
Expand All @@ -171,9 +171,9 @@
struct_ie_ncs.APD = calc_APD_array(struct_ie_ncs.t,struct_ie_ncs.V);

subplot(6,3,3);
plot(struct_ie_con.t(301:1000:end)/60,1000*struct_ie_con.V(301:1000:end),'k','LineWidth',2);
plot(struct_ie_con.t(301:1000:end)/60,1000*struct_ie_con.V(301:1000:end),'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t(301:1000:end)/60,1000*struct_ie_ncs.V(301:1000:end),'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t(301:1000:end)/60,1000*struct_ie_ncs.V(301:1000:end),'r','LineWidth',2);
xlim([0 30]);
ylabel('V_{dia} (mV)');
title('C');
Expand All @@ -183,43 +183,43 @@
title('C','FontSize',28);

subplot(6,3,6);
plot(struct_ie_con.t(1:1000:end-1)/60,struct_ie_con.APD,'k','LineWidth',2);
plot(struct_ie_con.t(1:1000:end-1)/60,struct_ie_con.APD,'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t(1:1000:end-1)/60,struct_ie_ncs.APD,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t(1:1000:end-1)/60,struct_ie_ncs.APD,'r','LineWidth',2);
xlim([0 30]);
ylabel('APD (ms)');
set(gca,'FontSize',font_size);

subplot(6,3,9);
plot(struct_ie_con.t/60,struct_ie_con.Ki,'k','LineWidth',2);
plot(struct_ie_con.t/60,struct_ie_con.Ki,'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t/60,struct_ie_ncs.Ki,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t/60,struct_ie_ncs.Ki,'r','LineWidth',2);
xlim([0 30]);
ylabel('[K^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,12);
plot(struct_ie_con.t/60,struct_ie_con.Nai,'k','LineWidth',2);
plot(struct_ie_con.t/60,struct_ie_con.Nai,'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t/60,struct_ie_ncs.Nai,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t/60,struct_ie_ncs.Nai,'r','LineWidth',2);
xlim([0 30]);
ylabel('[Na^+]_i (mM)');
set(gca,'FontSize',font_size);

subplot(6,3,15);
plot(struct_ie_con.t/60,1000*struct_ie_con.Cai,'k','LineWidth',2);
plot(struct_ie_con.t/60,1000*struct_ie_con.Cai,'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t/60,1000*struct_ie_ncs.Cai,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t/60,1000*struct_ie_ncs.Cai,'r','LineWidth',2);
xlim([0 30]);
ylabel('[Ca^{2+}]_i ({\mu}M)');
xlabel('Time (mins)');
set(gca,'FontSize',font_size);
ylim([0 1]);

subplot(6,3,18);
plot(struct_ie_con.t(1:3001),struct_ie_con.charge(1:3001)-initial_charge,'k','LineWidth',2);
plot(struct_ie_con.t(1:3001),struct_ie_con.charge(1:3001)-initial_charge,'b','LineWidth',2);
hold on;
plot(struct_ie_ncs.t(1:3001),struct_ie_ncs.charge(1:3001)-initial_charge,'Color',0.6*[1 1 1],'LineWidth',2);
plot(struct_ie_ncs.t(1:3001),struct_ie_ncs.charge(1:3001)-initial_charge,'r','LineWidth',2);
ylabel('{\Delta}Charge (fmol)');
xlabel('Time (sec)');
set(gca,'FontSize',font_size);
Expand Down
Loading

0 comments on commit a67e273

Please sign in to comment.