]> Creatis software - CreaPhase.git/blobdiff - utilities_LW/CTFPropagation_1D.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / CTFPropagation_1D.m
diff --git a/utilities_LW/CTFPropagation_1D.m b/utilities_LW/CTFPropagation_1D.m
new file mode 100644 (file)
index 0000000..2801aab
--- /dev/null
@@ -0,0 +1,65 @@
+## Copyright (C) 2015 Loriane Weber
+## 
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+## 
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## CTFPropagation 1D
+
+## Author: Loriane Weber <lweber@gpid16a-1801>
+## Created: 2015-11-20
+
+function [ Id ] = CTFPropagation_1D (ph, B, D, lambda, oversamp, ftot)
+
+[mp, np]=size(ph);
+
+if(np!=1)
+       disp('error')
+       return
+end
+
+%% propagators in 1D (sin and cos)
+ssq=2*ssquare1(lambda*D, ftot, 1)'; 
+csq=2*csquare1(lambda*D, ftot, 1)'; 
+
+tmp_B=zeros(2*mp, 1);
+tmp_ph=zeros(2*mp, 1);
+tmp_B(1:mp,1)=B;
+tmp_ph(1:mp,1)=ph;
+               
+% fourier domain
+tmp_B=fft(tmp_B);
+tmp_ph=fft(tmp_ph);
+
+tmp_Id=-csq.*tmp_B + ssq.*tmp_ph;
+tmp_Id=1+real(ifft(tmp_Id));
+       
+
+Id=tmp_Id(1:mp, 1);
+                       
+       if oversamp==2
+               ipf = [0.5 1 0.5]; % modelise le binning du detecteur
+               Idd = conv(Id,ipf,'same')./conv(ones(size(Id)),ipf,'same');
+               Idd = Idd(oversamp:oversamp:end, :);
+               Id=Idd; 
+       elseif oversamp==4
+               ipf = [0.5 1.0 1.0 1.0 0.5]; % modelise le binning du detecteur
+               Idd = conv(Id,ipf,'same')./conv(ones(size(Id)),ipf,'same');
+               Idd = Idd(oversamp:oversamp:end, :);
+
+               
+               Id=Idd; 
+       end % oversamp
+
+
+endfunction