Skip to content

Commit

Permalink
violin plot added
Browse files Browse the repository at this point in the history
  • Loading branch information
mojumder17 committed Sep 13, 2022
1 parent 69f0400 commit 1edb4ae
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 4 deletions.
2 changes: 1 addition & 1 deletion finalcode/extract_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def ExtractWork(IODet, SimDet, param1, param2, param3):
WD = np.array([-1.0*np.trapz(sff[:,i]*0.0075, eff[:,i]) for i in range(0,len(sff[1,:]))])
print len(WD)

uDG2.vector()[:] = WD
uDG2.vector()[:] = WD*0.1323
print uDG2.vector().array()
fdatamean << uDG2

Expand Down
2 changes: 1 addition & 1 deletion main/10.ahaplot_WithoutDisarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def aha_wd(directory1, case3, Case1, case4):
LVbullseyemulti(data = aharraythick, filename = "Thickness", Stimulus = "Thickness", DirectorY = directory, maxm=1.75, minm=0.30 )
LVbullseyemulti(data = aharraystrain, filename = "Long_strain", Stimulus = "Long_strain", DirectorY = directory, maxm = 25.0, minm=10.0)
LVbullseyemulti(data = aharraystress, filename = "Pk2_stress", Stimulus = "Pk2_stress", DirectorY = directory, maxm = 100.0, minm = 25.0)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm=145.0, minm=35.0)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm=20.0, minm=3.0)



Expand Down
2 changes: 1 addition & 1 deletion main/11.ahaplot_With_disarray_nonobstructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def aha_wd(directory1, case3, Case1, case4):

LVbullseyemulti(data = aharraystrain, filename = "Long_strain", Stimulus = "Long_strain", DirectorY = directory, maxm = 30, minm=5)
LVbullseyemulti(data = aharraystress, filename = "Pk2_stress", Stimulus = "Pk2_stress", DirectorY = directory, maxm =75 , minm = 25)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm =140 , minm = 5)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm =20.0 , minm = 0.0)



Expand Down
2 changes: 1 addition & 1 deletion main/11.ahaplot_With_disarray_obstructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def aha_wd(directory1, case3, Case1, case4):

LVbullseyemulti(data = aharraystrain, filename = "Long_strain", Stimulus = "Long_strain", DirectorY = directory, maxm = 30, minm=5)
LVbullseyemulti(data = aharraystress, filename = "Pk2_stress", Stimulus = "Pk2_stress", DirectorY = directory, maxm =75 , minm = 25)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm =140 , minm = 5)
LVbullseyemulti(data = aharrayworkdensity_f, filename = "Work_density_fiber", Stimulus = "Work_density", DirectorY = directory, maxm =20.0 , minm = 0.0)



Expand Down
91 changes: 91 additions & 0 deletions main/14. Multiple_violin_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#########################################################

import sys
import vtk
import os
from dolfin import *
import pdb
import vtk.util.numpy_support as vtk_support
#sys.path.append("/home/fenics/shared/")
sys.path.append("/mnt/home/mojumder/HPCC_HCM/github/HCM")
import vtk_py as vtk_py
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import scipy.stats as stats

############################################################
from finalcode.mean_dev import StimulusDev2

################################################################




def DataExtraction(directory, casename,stimuli):

filename = directory+casename + ".vtp"

pdata_reader = vtk.vtkXMLPolyDataReader()
pdata_reader.SetFileName(filename)
pdata_reader.Update()
pdata = pdata_reader.GetOutput()

array = (vtk_support.vtk_to_numpy(pdata.GetPointData().GetArray(stimuli)))

return array










case1 = ['P1' , 'P2', 'P3']




Stimulus = 'fstressPk2_'+'max'
DataName = 'f_22'
for l in range(len(case1)):
directory1 = './with_dispersion/'+ case1[l]+"/k0/simulation/mechanics/ME/"

vtufilename = directory1+ 'fstressPk2_'+'max'
filename = "data_set_"+Stimulus
fdatadev3 = open(directory1+case1[l]+"_thickness.txt", "w+")
StimulusDev2(STIMULUS=Stimulus,VTUfilename = vtufilename, fdatadev3 =fdatadev3, dataname = DataName, DirectorY = directory1, field_type="point")


if l==0:
P1_array = DataExtraction(directory1, Stimulus,stimuli= "Thickness")
elif l==1:
P2_array = DataExtraction(directory1, Stimulus,stimuli= "Thickness")
else:
P3_array = DataExtraction(directory1, Stimulus,stimuli= "Thickness")


fig, ax = plt.subplots(figsize = (8,6))
ax.violinplot([P1_array, P2_array, P3_array][::-1], positions = [3,2,1], showmeans = True)

def set_axis_style2(ax, labels):
ax.get_yaxis().set_tick_params(labelsize = 14, direction = 'out')
ax.get_xaxis().set_tick_params(labelsize = 14)
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks(np.arange(1, len(labels)+1))
ax.set_xticklabels(labels, fontsize = 14)
ax.set_xlim(0.25, len(labels)+0.75)
ax.set_ylabel('Thickness (cm)', fontsize = 14)
set_axis_style2(ax, ['Control', 'Non-Obstructive','Obstructive'])
#plt.show()
plt.savefig('thicknessall' +"_1.png")
#plt.show()
plt.close()




1 change: 1 addition & 0 deletions main/2.Nonobstructive_k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"Q_mv" : 0.0124479080844,
"stop_iter" : 6,
"V_LV_target": 82.1,
}

SimDetails = {
"diaplacementInfo_ref": False,
Expand Down
97 changes: 97 additions & 0 deletions main/Matlabplot/active_tension_dispersion_P2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
function active_tension()
lamda = 1.5
%I = Invariant(lamda)
timevariantformulation()

end
function timevariantformulation()
%Constant values
lr = 1.85;
lo = 1.55 ;
CaoMax = 4.35;
Cao = 4.35;
B = 4.75;
to = 400 ;
ttrans = 430;
tau = 35;
BCL = 910;

% c = [0.93, 0.96, 1.0, 1.1, 1.2, 1.6 ]
% T = 95E03; %400E03;

c = [1.0,1.05,1.1,1.25,2.1] %,4.0] %,18.0 ]
T = 400E03;


%variables
lamda = 1.0;
lambda = 1.0;
timepoint =linspace(0, BCL, BCL/2);
sigma_active = zeros(1, length(timepoint));
dlamda = lamda/to;
actmax = zeros(1, length(c));
for j = 1:length(c)
Tmax = c(j)*T;

for i = 1:length(timepoint)
ta = timepoint(i);
% if ta<to
% lambda = lambda + dlamda;
% else
% lambda = lambda - dlamda;
% end
lambda = lamda;

lso = ActiveLength(lambda, lr, lo);

deno = sqrt(exp((B*lso)-1));
ECa50 = CaoMax/deno;

if ta<ttrans
Ct = 0.5*(1-cos(pi*ta/to));
else
Ct = 0.5*(1-cos(pi*ttrans/to))*exp(-((ta-ttrans)/tau));
end


CaTerm = Cao^2 /(Cao^2 + ECa50^2);
Pact = Tmax*CaTerm*Ct;
sigma_active(i) = Pact;

end

figure(1)
hold on
plot(timepoint, sigma_active/1000,'LineWidth',1.5)
hold on
actmax(j) = max(sigma_active)/1000.0

end

grid on
legend({'\kappa = 0','\kappa = 0.07','\kappa = 0.1','\kappa = 0.14','\kappa=0.18'}, 'FontSize',16, 'Fontname','Times New Roman')%,'17','18','19')%,'change','pp') %,'0.35,0.05','0.35,0.09','0.35,0.5')
%legend({'Control','Non-Obstructive', 'Obstructive'}, 'FontSize',16)
title('Non-obstructive HCM','FontSize',18, 'Fontname','Times New Roman','Fontweight','normal')
xlabel('Time (ms)','FontSize',18, 'Fontname','Times New Roman')
ylabel('Tension (kPa)','FontSize',18, 'Fontname','Times New Roman')
hold off
ax = gca;
%ax.FontSize = 12;
%ax.FontWeight = 'bold';
% ax.XLim = [25 60];
%pbaspect([1 1 1])
%grid minor
%plot_func (list, sigma_total_xx)
saveas(gcf, 'activetension_p2_dispersion_new', 'png')
actmax
end

function lso = ActiveLength(lamda, lr, lo)
ls = lamda*lr;
if ls<=lo
lso = 0.002;
else
lso = ls-lo;

end
end
96 changes: 96 additions & 0 deletions main/Matlabplot/active_tension_dispersion_P3_otg.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
function active_tension()
lamda = 1.5
%I = Invariant(lamda)
timevariantformulation()

end
function timevariantformulation()
%Constant values
lr = 1.85;
lo = 1.55 ;
CaoMax = 4.35;
Cao = 4.35;
B = 4.75;
to = 350; %800 ;
ttrans = 420; %410;
tau = 35; %40;
BCL = 1180; %910;

c = [1.05, 1.125, 1.15, 1.3, 1.45, 1.75]
T = 95E03; %400E03;

% c = [2.0,2.6,2.7, 3.0,7.0,18.0 ]
% T = 400E03;


%variables
lamda = 1.0;
lambda = 1.0;
timepoint =linspace(0, BCL, BCL/2);
sigma_active = zeros(1, length(timepoint));
dlamda = lamda/to;
actmax = zeros(1, length(c));
for j = 1:length(c)
Tmax = c(j)*T;

for i = 1:length(timepoint)
ta = timepoint(i);
% if ta<to
% lambda = lambda + dlamda;
% else
% lambda = lambda - dlamda;
% end
lambda = lamda;

lso = ActiveLength(lambda, lr, lo);

deno = sqrt(exp((B*lso)-1));
ECa50 = CaoMax/deno;

if ta<ttrans
Ct = 0.5*(1-cos(pi*ta/to));
else
Ct = 0.5*(1-cos(pi*ttrans/to))*exp(-((ta-ttrans)/tau));
end


CaTerm = Cao^2 /(Cao^2 + ECa50^2);
Pact = Tmax*CaTerm*Ct;
sigma_active(i) = Pact;

end

figure(1)
hold on
plot(timepoint, sigma_active/1000,'LineWidth',1.5)
hold on
actmax(j) = max(sigma_active)/1000.0

end

grid on
legend({'\kappa = 0','\kappa = 0.07','\kappa = 0.1','\kappa = 0.14','\kappa=0.18','\kappa=0.22' }, 'FontSize',16, 'Fontname','Times New Roman')%,'17','18','19')%,'change','pp') %,'0.35,0.05','0.35,0.09','0.35,0.5')
%legend({'Control','Non-Obstructive', 'Obstructive'}, 'FontSize',16)
title('Obstructive HCM','FontSize',18, 'Fontname','Times New Roman', 'Fontweight' , 'normal')
xlabel('Time (ms)','FontSize',18, 'Fontname','Times New Roman')
ylabel('Tension (kPa)','FontSize',18, 'Fontname','Times New Roman')
hold off
ax = gca;
%ax.FontWeight = 'bold';
% ax.XLim = [25 60];
%pbaspect([1 1 1])
%grid minor
%plot_func (list, sigma_total_xx)
saveas(gcf, 'activetension_p3_dispersion_otg', 'png')
actmax
end

function lso = ActiveLength(lamda, lr, lo)
ls = lamda*lr;
if ls<=lo
lso = 0.002;
else
lso = ls-lo;

end
end
Loading

0 comments on commit 1edb4ae

Please sign in to comment.