How to create a hysteresis loop
Show older comments
I am very new to coding and I want to understand how to generate a hysteresis loop for blood vessels. This work was done in mice but the ones I see on MatLab answer primarily have to do with magnetism and I am unsure how to tailor my data to fit the different equations/codes.
Below is the code I wrote which essentially plots my data set but it does not generate a loop per se.
lumenWT = (Old.WT_2283)
pressureWT = (Old.Pressure);
x = floor(length(lumenWT)/2);
x1 = lumenWT(1:x);
x2 = lumenWT(x:end);
y1 = pressureWT(1:x);
y2 = pressureWT(x:end);
figure
L1 = plot(y1,x1,'-k',LineWidth=2);
hold on
L2 = plot(y2,x2,'-k',LineWidth=2);
legend([L1 L2 L3 L4], ...
'WT Loading','WT Unloading','Location','southeast');
ylabel('Lumen diameter (microns)')
xlabel('Pressure(mmHg)')
title("Old")
grid on
An answer from a few years ago generate this script which is what I am hoping to recreate but I have not been successful. :
X = [-3:.2:3 3:-.2:-3];
Y = [tanh(X(1:length(X)/2)-1) tanh(X(length(X)/2+1:end)+1)];
patch(X,Y,[.5 1 .5]); hold on
quiver(X(1:end-1),Y(1:end-1),diff(X),diff(Y),0);
I am kindly asking for some suggestions or some direction
7 Comments
Sulaymon Eshkabilov
on 2 Jan 2023
Can you share your data?
I relaize that you have raised and then lowered the pressure inside a blood vessel. YOu have measured the diameter as a funciton of pressure. You did the experiment in three specimens.
There is one rows on NaNs in the data, which we will remove.
Here is code to plot the pressure-diameter loops.
data=xlsread('Old.xlsx');
pres=data(:,1); %column 1 = pressure
diam=data(:,2:4); %columns 2-4=diameter
pres=pres(~isnan(pres)); %remove rows with NaN
diam=diam(~isnan(diam)); %remove rows with NaN
diam=reshape(diam,[16,3]); %reshape diam to have 3 columns
figure;
plot(pres,diam(:,1),'r',pres,diam(:,2),'g',pres,diam(:,3),'b')
xlabel('Pressure (mmHg'); ylabel('Diameter (\mum)');
grid on; title('Pressure versus Diameter')
legend('WT 2272','WT 2283','WT 2271');
The hysteresis "loops" do not look very much like loops.
Try it.
You measured a diameter of zero
when the presure was 20 mmHg, in all three vessels. Are you surprised by this? I would expect the opposite: in other words, I would expect a positive diameter at zero pressure, because most vessels have a positive unstressed volume.
Here is code which displays which part of the curve is rising pressure and which is falling. For a viscoelastic wall, and pressure on the horizontal axis, we expect to go counterclockwise around the loop. If the axes were reversed, we would expect to go clockwise around the loop.
data=xlsread('Old.xlsx');
pres=data(:,1); %column 1 = pressure
diam=data(:,2:end); %columns 2-4=diameter
[~,cols]=size(diam);
pres=pres(~isnan(pres)); %remove rows with NaN
diam=diam(~isnan(diam)); %remove rows with NaN
diam=reshape(diam,[],cols); %reshape diam to have 3 columns
[rows,~]=size(diam);
rm=rows/2; %middle row number
figure;
plot(pres(1:rm),diam(1:rm,1),'-r','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,1),'--r','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,2),'-g','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,2),'--g','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,3),'-b','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,3),'--b','linewidth',2);
xlabel('Pressure (mmHg'); ylabel('Diameter (\mum)');
grid on; title('Pressure versus Diameter')
legend('WT2272 up','WT2272 down','WT2283 up','WT2283 down',...
'WT2271 up','WT2271 down','location','southeast');
Good luck.
Alethia
on 3 Jan 2023
William Rose
on 3 Jan 2023

It has stress (σ) on the vertical axis and strain (λ) on the horizontal axis. To estimate stress and strain from pressure-diameter data:
Strain:
or 
Stress: 

where
is the diameter with zero stress,
is the change in diameter from
(
= circumferential length,
is the change in circumferential length from
), P is the pressure in the vessel, and w is the wall thickness. The equation for σ is a consequence of Laplace's law for wall tension in a cylindrical vessel.
Since you have an initial diameter of zero, the strain computed with the equation above is infinite. You could estimate circumferential length as 2*width of the flattened vessel when pressure is <=20, and L=pi*diameter when the cross section is ciruclar. Then you could use the second strain equation above.
Since you have not reported or estimated the wall thickness, we cannot calculate the stress. Wall thickness will tend to vary roughly inversely with circumferential length, since wall tissue volume is approximately constant.
Since you did not report the data needed to compute stress or strain, a plot of pressure versus diameter may be a reasonable substitute. The P-d plot and the stress-strain plot will both exhibit hysteresis, if it exists.
Alethia
on 3 Jan 2023
Answers (2)
Sulaymon Eshkabilov
on 3 Jan 2023
Edited: Sulaymon Eshkabilov
on 3 Jan 2023
clearvars
Old = readtable('Old.xlsx');
lumenWT = (Old.WT_2283) ;
pressureWT = (Old.Pressure);
x = floor(length(lumenWT)/2);
x1 = lumenWT(1:x);
x2 = lumenWT(x:end);
y1 = pressureWT(1:x);
y2 = pressureWT(x:end);
x2 = rmmissing(x2);
y2 = rmmissing(y2);
figure(1)
L1 = plot(y1,x1,'-k','LineWidth', 2);
hold on
L2 = plot(y2,x2,'-k','LineWidth',2);
legend([L1 L2], ...
'WT Loading','WT Unloading','Location','southeast');
ylabel('Lumen diameter (microns)')
xlabel('Pressure(mmHg)')
title("Old")
grid on
X = [x1; x2; -1*x1; -1*x2];
Y= [y1; y2; -1*y1; -1*y2];
patch(Y,X,[.5 1 .5]); hold on
quiver(Y(1:end-1),X(1:end-1),diff(Y),diff(X),0);
[I moved my code to the "Answer" section, which is where I should have posted it initially.]
I relaize that you have raised and then lowered the pressure inside a blood vessel. YOu have measured the diameter as a funciton of pressure. You did the experiment in three specimens.
There is one rows on NaNs in the data, which we will remove.
Here is code to plot the pressure-diameter loops.
data=xlsread('Old.xlsx');
pres=data(:,1); %column 1 = pressure
diam=data(:,2:end); %columns 2-4=diameter
[~,cols]=size(diam);
pres=pres(~isnan(pres)); %remove rows with NaN
diam=diam(~isnan(diam)); %remove rows with NaN
diam=reshape(diam,[],cols); %reshape diam to have 3 columns
[rows,~]=size(diam);
rm=rows/2; %middle row number
figure;
plot(pres(1:rm),diam(1:rm,1),'-r','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,1),'--r','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,2),'-g','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,2),'--g','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,3),'-b','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,3),'--b','linewidth',2);
xlabel('Pressure (mmHg'); ylabel('Diameter (\mum)');
grid on; title('Pressure versus Diameter')
legend('WT2272 up','WT2272 down','WT2283 up','WT2283 down',...
'WT2271 up','WT2271 down','location','southeast');
Good luck.
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

