Team:USTC/Software
In this section, we will introduce all the software program we used when processing our modeling and experimental data. Through our modeling, many complicated processdures are simply omitted by our convenient programs.
In general, our software programs are used in several sections,
- Fringes Analysis, analysis of interference pattern.
- Adhesion Dynamics, a series of programs relating to bacteria adhesion dynamics.
- Rose Prediction, which calculate the advantages of our ROSE improvement.
All software of our project, you can download them at Github:2015USTCiGEM. All codes are based on
Fringes Pattern Simulation-Film I
This program is used to simulate fringes pattern deliverd by film I.
Code:
function drawndh(r,h,t,n) %r is radius of film,h is the distance of deformation,t is the drift angle of film,n is pixel number
wl=6.5e-7; %wave length
R=r.^2/(2*h);
[x,y]=meshgrid(linspace(-0.004,0.004,n),linspace(-0.004,0.004,n));
r2=x.^2+y.^2;
delta=pi*r2/(R*wl)-2*pi*y*sin(t)/wl;
I=abs(sin(delta).^2);
imshow(I);
end
Demo
After the formation of demo, we are able to recongize the real situation in our pre-experiment.
Fringes Pattern Simulation-Film II
This program is used to simulate fringes pattern deliverd by film II.
Code
function drawfr(a,b,h,n)%a is the angle between film and x axis, b is the angle between film and y axis, h is the distance of film deformation, n is the pixel number
[X,Y]=meshgrid(linspace(-0.003,0.003,n),linspace(-0.003,0.003,n));
wl=6.5e-7;
L=2*(X.*tan(0.01)+Y.*tan(0.01));
delta=2*pi*L/wl;
I=1+cos(delta);
imshow(I)
end
Demo
Film I Fringes Analysis
Using this code, we are able to capture some important parameters in Film I.
Code
function ms3=solvendh(X,nx,ny,n,dx,dy)%nx is the number of fringes on x axis,ny is the number of fringes on y axis,n is the number of fringes on diag,dx is the x length of CCD,dx is the x length of CCD.
x=X(1);
y=X(2);
z=X(3);
l=1.2e-4;
ms3(1)=(2*(z+nx)*l)^0.5-(2*z*l)^0.5-((x+dx)^2+y^2)^0.5+(x^2+y^2)^0.5;
ms3(2)=(2*(z+ny)*l)^0.5-(2*z*l)^0.5-(x^2+(y+dy)^2)^0.5+(x^2+y^2)^0.5;
ms3(3)=(2*(z+n)*l)^0.5-(2*z*l)^0.5-((x+dx)^2+(y+dy)^2)^0.5+(x^2+y^2)^0.5;
Demo
Film II Fringes Analysis-Fringes number analysis
This is the final program used to get our NDM calibration. Based on this software program, we are able to count the number of bright fringes. As a matter of fact, the variation of bright fringes is the key breakthrough to antibiotic analysis.
Code
function seeim(i)
name=num2str(i);
I=imread(name,'pnm');
G=rgb2gray(I);
imshow(G);
Demo
function A=getfr(i)
name=num2str(i);
I=imread(name,'pnm');
G=rgb2gray(I);
G1=medfilt2(G);
[x,y]=size(G1);
r=zeros(x,1);
for m=1:20
p=G1(:,x-m+1);
p=double(p);
r=r+p;
end
[a,b]=size(r);
for m=1:b-1
r(m,1)=(r(m-1,1)+r(m,1)+r(m+1,1));
end
A=r;
function M=getfrs(i)
A=getfr(i);
t=1:480;
[pksa,locsa]=findpeaks(A,'minpeakdistance',3);plot(t,A,'b',locsa,pksa,'bo');
[a,k]=size(pksa);
M=a;
Running result
ans =
78
To get a series of results, this program is required.
function N=getpkss(i,j)
B=zeros(j-i+1,1);
for m=i:j
A=getfr(m);
[pksa,locsa]=findpeaks(A,'minpeakdistance',3);
[a,k]=size(pksa);
B(m-i+1,1)=a;
end
N=B;
Demo
ans =
78
80
77
76
75
79
81
80
75
80
82
82
81
78
79
82
81
81
83
81
79
During analysis of ahdesion assay results, we are quite annoyed about counting total bacteria number and moving bacteria number, which is really important for mechanism analysis and results determination. Consequently, this part explains how we efficiently accomplished these tough work based on our software.
Bacteria counting program
This program is used to count the total number of bacteria.
Code
function a=shujun(i)
name=num2str(i);
I=imread(name,'jpg');
L=graythresh(I);%get the self-adapting threshold
G=im2bw(I,0.3);%image binaryzation with special threshold
W1=~G;
W2=bwmorph(W1,'majority',20);%mathematical morphology operations
W3=medfilt2(W2,[10,10]);%filtering
W4=bwareaopen(W3,40);%delete small area to reduce error noises
[labeled,num]=bwlabel(W4,4);%counting number of objects
a=num;
end
Demo
input image:
output result
ans =
865
function A=mulshu(m)
A=zeros(m,1);
for i=1:m
A(i,1)=shujun(i);
end
Moving Bacteria Counting Program
This program is used to count the total number of moving bacteria. Along with bacterial counting program, we finally got the mechanism of polylysine interaction.
Code
function b=act(m,n)
s1=num2str(m);
s2=num2str(n);
I1=imread(s1,'jpg');
I2=imread(s2,'jpg');
G=I1-I2;
b=shujun(G);
end
function A=mulact(m)
A=zeros(m,1);
for i=1:m
name1=num2str(i);
name2=num2str(i+1);
I1=imread(name1,'jpg');
I2=imread(name2,'jpg');
c=act(I1,I2);
A(i,1)=c;
end
Demo
ans =
405
Bacteria total number-time curve
Coding
function drawBT1(Ka,Kd,C,Vz,sigma0)%Ka is the adhesive rate of bacteria, Kd is the drop rate of bacteria, C is the density of bacteria solution,Vz is the velocity of bacteria,sigma0 is the maximum density of baacteria on surface
t=linspace(0,100,101);
K=Ka*C*Vz/(Kd*sigma0+Ka*C*Vz);
sigma=K*sigma0*(1-exp(-Ka*C*Vz*t/(K*sigma0));
plot(t,sigma)
end
Running result
Bacteria movement number-Time curve
Coding
function drawBMT(c,b,m0,k)
t=linspace(0,100,101);
M=c*(1-exp(-b*t))*m0.*exp(-k*t);
plot(t,M)
xlabel('Time(s)');
ylabel('Movement bacteria number');
title('PAO1-PLL-0 Movement number-time');
end
Running result
This program is used to predict the advantages of ROSE construction. We successfully demonstrate our ROSE will be able to amplify fluorescence siganl.
Code
clear all
R=R,k=k,k1=k1,k2=k2,k3=k3,k4=k4,k5=k5,k6=k6,k7=k7,k0=k0; %define the constant
t=linspace(0,10); %detecting time range
F=k1*S;
A=k*dsolve('Dx=k2*F','x(0)=0','t');
RA=k3*R*A;
X=k4*RA;
Cl=dsolve('Dx=k5*X','x(0)=0','t');
lambda=1-k6*cl;
t0=fzero(lambda,t); %find the zero point of lambda
if lambda>=0
G=dsolve('Dx=k7*lambda','x(0)=0','t');
else
Gm=G(t0);
end
%finish the equation solving step
plot(G,t); %print the G-t picture
hold on
plot(k0*t,t); %print the traditional strategy result in the same image
Demo