## 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/>.

## PhantTibo_Analytical

## Author: Loriane Weber <lweber@rnice7-0102>
## Created: 2015-12-10

%%%%%% INPUT PARAMETERS
%% ps : is the physical pixel size, in um
%% RedAttFact : reduced attenuation factor
%% angles : angles of projections
%% save : 1 or 0 (1 if you want to save in edf, 0 sinon

function [MuP_tot, Phi_tot, B_tot] = CircleMat_Analytical (angles, ps, R_circle, circle_center, absorption_mat, beta_mat, delta_mat, taille, save)

du= 1; % echantillonage de la projection
angles_rad=(angles*pi/180) + pi/2; % in radians % +pi/2 to be coherent with radon transform

circle_center=circle_center - floor(taille/2);
u=[-(taille-1)/2:du:+(taille-1)/2]; 
disp('proj')


for i=1:length(angles)

	u0_mat= cos(angles_rad(i))*circle_center(1) + sin(angles_rad(i))*circle_center(2);

## Proj attenuation
	MuP_mat=Analytical_1D(absorption_mat, u, R_circle, u0_mat);
	MuP_tot(:, i) = MuP_mat * ps;

## Proj Phi
	Phi_mat=Analytical_1D(delta_mat, u, R_circle, u0_mat);
	Phi_tot(:, i) = Phi_mat * ps;

## Proj Beta
	B_mat=Analytical_1D(beta_mat, u, R_circle, u0_mat);
	B_tot(:, i) = B_mat *ps;

end

if save
	edfwrite('Sino_AnalyticalCirclePET_Mu.edf', MuP_tot, 'float32')
	edfwrite('Sino_AnalyticalCirclePET_Phi.edf', Phi_tot, 'float32')
	edfwrite('Sino_AnalyticalCirclePET_B.edf', B_tot, 'float32')
end


endfunction
