MLEM.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. %% Author: Rodrigo de Barros Vimieiro
  2. % Date: April, 2018
  3. % rodrigo.vimieiro@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % MLEM(proj,nIter,parameter)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function reconstruct iteratively the volume through
  11. % Maximum-Likelihood Expectation-Maximization (MLEM) method.
  12. %
  13. % The geometry is for DBT with half cone-beam. All parameters are set
  14. % in "ParameterSettings" code.
  15. %
  16. % INPUT:
  17. %
  18. % - proj = 2D projection images
  19. % - nIter = Specific iterations to save volume data
  20. % - parameter = Parameter of all geometry
  21. %
  22. % OUTPUT:
  23. %
  24. % - allreconData3d{1,...} = Cell with Volumes of each specific iteration.
  25. % - allreconData3d{2,...} = Cell with informations of each specific iteration.
  26. %
  27. % Reference: Sidky, E. Y., 8-Iterative image reconstruction design
  28. % for digital breast tomosynthesis, Tomosynthesis Imaging (2014).
  29. %
  30. % ---------------------------------------------------------------------
  31. % Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
  32. %
  33. % This program is free software: you can redistribute it and/or modify
  34. % it under the terms of the GNU General Public License as published by
  35. % the Free Software Foundation, either version 3 of the License, or
  36. % (at your option) any later version.
  37. %
  38. % This program is distributed in the hope that it will be useful,
  39. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41. % GNU General Public License for more details.
  42. %
  43. % You should have received a copy of the GNU General Public License
  44. % along with this program. If not, see <http://www.gnu.org/licenses/>.
  45. %}
  46. % =========================================================================
  47. %% Recon Code - Iterative reconstruction: MLEM
  48. function allreconData3d = MLEM(proj,nIter,parameter)
  49. global showinfo
  50. info.startDateAndTime = char(datetime('now','Format','MM-dd-yyyy'' ''HH:mm:ss'));
  51. info.reconMeth = 'MLEM';
  52. highestValue = (2^parameter.bitDepth) - 1;
  53. allIterTime = zeros(nIter(end),1); % Time data for each iteration
  54. allreconData3d = cell(1,size(nIter,2)); % Recon data for each iteration
  55. % Initial estimated volume data
  56. reconData3d = zeros(parameter.ny, parameter.nx, parameter.nz,'single');
  57. reconData3d(:) = 1;
  58. % Volume normalization
  59. vol_norm = backprojection(ones(parameter.nv, parameter.nu, parameter.nProj, 'single'), parameter,[]);
  60. if(showinfo)
  61. fprintf('----------------\nStarting MLEM Iterations... \n\n')
  62. end
  63. % Start Iterations
  64. for iter = 1:nIter(end)
  65. tStart = tic;
  66. % Error ratio between raw data and projection of estimated data
  67. proj_ratio = proj./projection(reconData3d,parameter,[]);
  68. proj_ratio(isnan(proj_ratio)) = 0;
  69. proj_ratio(isinf(proj_ratio)) = 0;
  70. upt_term = backprojection(proj_ratio, parameter,[]);
  71. upt_term = upt_term ./vol_norm; % Volume normalization
  72. upt_term(isnan(upt_term)) = 0;
  73. upt_term(isinf(upt_term)) = 0;
  74. reconData3d = reconData3d.*upt_term; % Updates the previous estimation
  75. % Truncate to highest value
  76. reconData3d(reconData3d>highestValue) = highestValue;
  77. allIterTime(iter,1) = toc(tStart);
  78. % Save data
  79. indIter = find(nIter == iter);
  80. if(indIter~=0)
  81. allreconData3d{1,indIter} = reconData3d(parameter.iROI,parameter.jROI,parameter.sliceRange);
  82. info.IterationNumber = num2str(iter);
  83. info.IterationTime = num2str(sum(allIterTime(:)));
  84. allreconData3d{2,indIter} = info;
  85. end
  86. if(showinfo)
  87. fprintf('Iteration %d Time: %.2f\n\n',iter,allIterTime(iter,1));
  88. end
  89. end% Loop end iterations
  90. end