You are on page 1of 3

Course: Optical Interactions in Tissue

1. Program 3: Scattering
Student: Phan Duc Tri
Student Number : 201855834
Purpose: This program calculates the absorbance, reflectance and transmittance of the
total photons scatteting in tissue

2. Variable List
No. Variable Definition
1 T Transmittance counter
2 R Reflectance counter
3 A Absorption counter
4 (x,y,z) Initial position (0,0,0)
5 (cx,cy,cz) Initial direction (0,0,1)
6 ua absorption coefficient [1/cm]
7 us scattering coefficient [1/cm]
8 ut total attenuation coefficient [1/cm]
9 d depths [cm]

1
3. Result

4. Program design
% Program 3: Scattering
% Author: Phan Duc Tri
% Student Number: 201855834
% Test with 5 sets 10.000 photons for each set
for i=1:5
T = 0; % set zero counter: T - Transmitted
A = 0; % A - Absorbed
R = 0; % R - Reflected
for j=1:1000
x = 0; % initial position
y = 0; % initial position
z = 0; % initial position
cx = 1; % vector unit of axis x
cy = 1; % vector unit of axis y
cz = 1; % vector unit of axis z
g = 0; % isotropic
d = 0.02; % thickness of tissue

2
ua = 10; % absorption coefficient
us = 90; % scattering coefficient
ut = ua + us; % totall coefficient
while 1 % while loop: keep update the position
s = -log(rand)/ut; % distance
z = z + s*cz; % current position
if z < 0
R = R + 1; break % counter for reflected photon
elseif z > d
T = T + 1; break % counter for transmitted photon
end;
if rand()<(ua/ut)
A=A+1; % Increment absorption counter
break;
end;

theta=acos(2*rand()-1); % Calculate Deflection angle


phi=2*pi*rand(); % Calculate Azimutal angle
% Calculate new direction of photon
if abs(cz)>0.999999
cx = sin(theta)*cos(phi);
cy= sin(theta)*sin(phi);
cz= cz*cos(theta)/abs(cz);
else
cx= sin(theta)/sqrt(1-cz*cz)*(cx*cz*cos(phi)-cy*sin(phi))+cx*cos(theta);
cy= sin(theta)/sqrt(1-cz*cz)*(cy*cz*cos(phi)+cx*sin(phi))+cy*cos(theta);
cz= -sin(theta)*cos(phi)*sqrt(1-((cz)*(cz)))+cz*cos(theta);
end;

end;

end;
% Display outputs
subplot(3,2,i);
ATR=[A T R];
pie(ATR);
title(['Run ', num2str(i)], 'color', 'r', 'fontweight', 'b');
end;

labels = {'Absorbance','Transmittance','Reflectance'};
legend(labels,'Location','SouthEastOutside','Vertical');
% End program

You might also like