├── LICENSE ├── README.md ├── art.m ├── broadband.m ├── circ.m ├── coherLen.m ├── gauss_distribution.m ├── main.m ├── reference.m ├── reflectivity.m └── sample.m /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 shbkd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Optical-Coherence-Tomography-using-Matlab 2 | ========================================= 3 | 4 | OCT simulation in matlab 5 | -------------------------------------------------------------------------------- /art.m: -------------------------------------------------------------------------------- 1 | function Iart = art(Idet,z,Iref,lambda) 2 | % art: algebraic reconstruction technique (ART) 3 | % "Optical coherence tomography by using frequency measurements in 4 | % wavelength domain, 2011" - by Hon Luen Seck 5 | %% Create A matrix 6 | A= repmat(Idet,1,length(z)); 7 | for i = 1:length(Idet) 8 | for j= 1:length(z) 9 | A(i,j)=A(i,j)*exp(1i*4*pi*z(j)/lambda(i)); 10 | end 11 | end 12 | %% Create B matrix 13 | b= Idet-Iref; 14 | %% Getting z distribution 15 | Iart= (A)\b; 16 | plot(z,real(Iart)); xlabel('dist, um'); ylabel('A-scan') 17 | -------------------------------------------------------------------------------- /broadband.m: -------------------------------------------------------------------------------- 1 | function [amp,lambda] = broadband(lambda,cenLamda,fwhm,flag) 2 | %flag: normalization parameter, default 0 3 | if nargin <4 4 | flag = 0; 5 | end 6 | amp = gauss_distribution(lambda, cenLamda, fwhm); 7 | if flag == 1 8 | amp = amp/(max(amp)-min(amp)); 9 | end 10 | 11 | % amp= (amp-min(amp))./(max(amp)-min(amp)); 12 | lambda= lambda*10^-9; 13 | -------------------------------------------------------------------------------- /circ.m: -------------------------------------------------------------------------------- 1 | function[out]=circ(r) 2 | % circle function % 3 | % evaluates circ(r) 4 | % note: returns odd number of samples for diameter 5 | % 6 | out=abs(r)<=1; 7 | end 8 | -------------------------------------------------------------------------------- /coherLen.m: -------------------------------------------------------------------------------- 1 | function len = coherLen(lamda0, fwhm) 2 | % lamda: mean wavelength (nm scale, just put num, will convert to nm) 3 | % same for fwhm 4 | % fwhm: full width at half maxima of source spectrum 5 | % len: coherence length in nm 6 | lamda0 = lamda0*1e-9; fwhm = fwhm*1e-9; 7 | c = 2*log(2)/pi; 8 | len = c*lamda0^2/fwhm; 9 | -------------------------------------------------------------------------------- /gauss_distribution.m: -------------------------------------------------------------------------------- 1 | function f = gauss_distribution(x, mu, s) 2 | p1 = -.5 * ((x - mu)/s) .^ 2; 3 | p2 = (s * sqrt(2*pi)); 4 | f = exp(p1) ./ p2; 5 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | %% Gearing Up!! 2 | % clc; clear all; close all; 3 | %% Define source 4 | specRange= 750:.1:1050; % Spectrum range with interval 5 | cenLamda= 840; fwhm= 50; % central lambda full width aat half maxima 6 | %% Generate a Source spectrum 7 | [Iso lambda]= broadband(specRange,cenLamda,fwhm); 8 | %% Query sample 9 | m = 50; % Assumed no. of reflectors in sample 10 | depth = 3e-3; %depth of the sample 11 | % Creating position of reflectors 12 | z= 0:depth/(m-1):depth; 13 | Isamp = sample(m,Iso,lambda,z); 14 | %% Query reference 15 | z0 = 0; Iref = reference(Iso,lambda,z0); 16 | %% Detector characteristic 17 | Idet= sum(Isamp,2) + Iref; 18 | %% Applying algorithms 19 | % Algorithm 1: ART 20 | Iart = art(Idet,z,Iref,lambda); 21 | -------------------------------------------------------------------------------- /reference.m: -------------------------------------------------------------------------------- 1 | function Iref = reference(amp,lambda,z0) 2 | % generates reference mirror charactetistic Intensity 3 | % parameter z0 tells if there is any extra phase difference 4 | if size(amp,1) == 1 5 | amp= amp'; 6 | end 7 | R = .5; R= repmat(R,length(amp),1); 8 | Iref= amp.*R; 9 | 10 | phasediff = cos(2*pi./lambda'*z0); 11 | Iref = Iref.*phasediff; 12 | -------------------------------------------------------------------------------- /reflectivity.m: -------------------------------------------------------------------------------- 1 | function R = reflectivity(m, MaxR, MinR) 2 | % generates reflectivity profile of sample 3 | % m: no. of layers for which to generate profile 4 | % MaxR: maximum reflectivity co-eff. of outermost layer 5 | % MinR: minimum reflectivity co-eff. of innermost layer 6 | dr = -(MaxR-MinR)/(m-1); 7 | R = MaxR:dr:MinR; 8 | -------------------------------------------------------------------------------- /sample.m: -------------------------------------------------------------------------------- 1 | function Isamp = sample(m,amp,lambda,z) 2 | % generates sample charactetistic Intensity 3 | if size(amp,1) == 1 4 | amp= amp'; 5 | end 6 | R = reflectivity(m,.5,.1); R= repmat(R,length(amp),1); 7 | ampLayer = repmat(amp,1,m); 8 | Isamp= ampLayer.*R; 9 | 10 | phasediff = cos(2*pi./lambda'*z); 11 | Isamp = Isamp.*phasediff; 12 | --------------------------------------------------------------------------------