forked from MJ0706/HCM-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69f0400
commit 1edb4ae
Showing
10 changed files
with
393 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.