-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMLEM.m
107 lines (90 loc) · 3.84 KB
/
MLEM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
%% Author: Rodrigo de Barros Vimieiro
% Date: April, 2018
% rodrigo.vimieiro@gmail.com
% =========================================================================
%{
% -------------------------------------------------------------------------
% MLEM(proj,nIter,parameter)
% -------------------------------------------------------------------------
% DESCRIPTION:
% This function reconstruct iteratively the volume through
% Maximum-Likelihood Expectation-Maximization (MLEM) method.
%
% The geometry is for DBT with half cone-beam. All parameters are set
% in "ParameterSettings" code.
%
% INPUT:
%
% - proj = 2D projection images
% - nIter = Specific iterations to save volume data
% - parameter = Parameter of all geometry
%
% OUTPUT:
%
% - allreconData3d{1,...} = Cell with Volumes of each specific iteration.
% - allreconData3d{2,...} = Cell with informations of each specific iteration.
%
% Reference: Sidky, E. Y., 8-Iterative image reconstruction design
% for digital breast tomosynthesis, Tomosynthesis Imaging (2014).
%
% ---------------------------------------------------------------------
% Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
%
% 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 this program. If not, see <http://www.gnu.org/licenses/>.
%}
% =========================================================================
%% Recon Code - Iterative reconstruction: MLEM
function allreconData3d = MLEM(proj,nIter,parameter)
global showinfo
info.startDateAndTime = char(datetime('now','Format','MM-dd-yyyy'' ''HH:mm:ss'));
info.reconMeth = 'MLEM';
highestValue = (2^parameter.bitDepth) - 1;
allIterTime = zeros(nIter(end),1); % Time data for each iteration
allreconData3d = cell(1,size(nIter,2)); % Recon data for each iteration
% Initial estimated volume data
reconData3d = zeros(parameter.ny, parameter.nx, parameter.nz,'single');
reconData3d(:) = 1;
% Volume normalization
vol_norm = backprojection(ones(parameter.nv, parameter.nu, parameter.nProj, 'single'), parameter,[]);
if(showinfo)
fprintf('----------------\nStarting MLEM Iterations... \n\n')
end
% Start Iterations
for iter = 1:nIter(end)
tStart = tic;
% Error ratio between raw data and projection of estimated data
proj_ratio = proj./projection(reconData3d,parameter,[]);
proj_ratio(isnan(proj_ratio)) = 0;
proj_ratio(isinf(proj_ratio)) = 0;
upt_term = backprojection(proj_ratio, parameter,[]);
upt_term = upt_term ./vol_norm; % Volume normalization
upt_term(isnan(upt_term)) = 0;
upt_term(isinf(upt_term)) = 0;
reconData3d = reconData3d.*upt_term; % Updates the previous estimation
% Truncate to highest value
reconData3d(reconData3d>highestValue) = highestValue;
allIterTime(iter,1) = toc(tStart);
% Save data
indIter = find(nIter == iter);
if(indIter~=0)
allreconData3d{1,indIter} = reconData3d(parameter.iROI,parameter.jROI,parameter.sliceRange);
info.IterationNumber = num2str(iter);
info.IterationTime = num2str(sum(allIterTime(:)));
allreconData3d{2,indIter} = info;
end
if(showinfo)
fprintf('Iteration %d Time: %.2f\n\n',iter,allIterTime(iter,1));
end
end% Loop end iterations
end