]> Creatis software - CreaPhase.git/blob - utilities_LW/CTFPropagation_1D.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / CTFPropagation_1D.m
1 ## Copyright (C) 2015 Loriane Weber
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with Octave; see the file COPYING.  If not, see
15 ## <http://www.gnu.org/licenses/>.
16
17 ## CTFPropagation 1D
18
19 ## Author: Loriane Weber <lweber@gpid16a-1801>
20 ## Created: 2015-11-20
21
22 function [ Id ] = CTFPropagation_1D (ph, B, D, lambda, oversamp, ftot)
23
24 [mp, np]=size(ph);
25
26 if(np!=1)
27         disp('error')
28         return
29 end
30
31 %% propagators in 1D (sin and cos)
32 ssq=2*ssquare1(lambda*D, ftot, 1)'; 
33 csq=2*csquare1(lambda*D, ftot, 1)'; 
34
35 tmp_B=zeros(2*mp, 1);
36 tmp_ph=zeros(2*mp, 1);
37 tmp_B(1:mp,1)=B;
38 tmp_ph(1:mp,1)=ph;
39                 
40 % fourier domain
41 tmp_B=fft(tmp_B);
42 tmp_ph=fft(tmp_ph);
43
44 tmp_Id=-csq.*tmp_B + ssq.*tmp_ph;
45 tmp_Id=1+real(ifft(tmp_Id));
46         
47
48 Id=tmp_Id(1:mp, 1);
49                         
50         if oversamp==2
51                 ipf = [0.5 1 0.5]; % modelise le binning du detecteur
52                 Idd = conv(Id,ipf,'same')./conv(ones(size(Id)),ipf,'same');
53                 Idd = Idd(oversamp:oversamp:end, :);
54                 Id=Idd; 
55         elseif oversamp==4
56                 ipf = [0.5 1.0 1.0 1.0 0.5]; % modelise le binning du detecteur
57                 Idd = conv(Id,ipf,'same')./conv(ones(size(Id)),ipf,'same');
58                 Idd = Idd(oversamp:oversamp:end, :);
59
60                 
61                 Id=Idd; 
62         end % oversamp
63
64
65 endfunction