SART.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. %% Author: Rodrigo de Barros Vimieiro
  2. % Date: May, 2018
  3. % rodrigo.vimieiro@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % SART(proj,nIter,parameter)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function reconstruct iteratively the volume through
  11. % Simultaneous Algebraic Reconstruction Technique (SART) method.
  12. %
  13. % The geometry is for DBT with half cone-beam. All parameters are set in
  14. % "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: Three-Dimensional Digital Tomosynthesis - Yulia Levakhina (2014)
  28. %
  29. % ---------------------------------------------------------------------
  30. % Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
  31. %
  32. % This program is free software: you can redistribute it and/or modify
  33. % it under the terms of the GNU General Public License as published by
  34. % the Free Software Foundation, either version 3 of the License, or
  35. % (at your option) any later version.
  36. %
  37. % This program is distributed in the hope that it will be useful,
  38. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  39. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40. % GNU General Public License for more details.
  41. %
  42. % You should have received a copy of the GNU General Public License
  43. % along with this program. If not, see <http://www.gnu.org/licenses/>.
  44. %}
  45. % =========================================================================
  46. %% Recon Code - Iterative reconstruction: SART
  47. function allreconData3d = SART(proj,nIter,parameter)
  48. global showinfo animation
  49. numProjs = parameter.nProj;
  50. info.startDateAndTime = char(datetime('now','Format','MM-dd-yyyy'' ''HH:mm:ss'));
  51. info.reconMeth = 'SART';
  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 data
  56. reconData3d = zeros(parameter.ny, parameter.nx, parameter.nz,'single');
  57. % Pre calculation of Projection normalization
  58. tempvar = animation; animation = 0;
  59. proj_norm = projection(ones(parameter.ny, parameter.nx, parameter.nz, 'single'),parameter, []);
  60. animation = tempvar; clear tempvar;
  61. % Pre calculation of Backprojection normalization
  62. vol_norm = backprojection(ones(parameter.nv, parameter.nu, parameter.nProj, 'single'), parameter, []);
  63. if(showinfo)
  64. fprintf('----------------\nStarting SART Iterations... \n\n')
  65. end
  66. % Start Iterations
  67. for iter = 1:nIter(end)
  68. tStart = tic;
  69. % For each projection
  70. for p=1:numProjs
  71. % Error between raw data and projection of estimated data
  72. proj_diff = proj(:,:,p) - projection(reconData3d,parameter,p);
  73. proj_diff = proj_diff ./ proj_norm(:,:,p); % Projection normalization
  74. proj_diff(isnan(proj_diff)) = 0;
  75. proj_diff(isinf(proj_diff)) = 0;
  76. upt_term = backprojection(proj_diff,parameter,p);
  77. upt_term = upt_term ./ vol_norm; % Volume normalization
  78. upt_term(isnan(upt_term)) = 0;
  79. upt_term(isinf(upt_term)) = 0;
  80. % Updates the previous estimation
  81. reconData3d = reconData3d + upt_term;
  82. end
  83. % Truncate to highest and minimum value
  84. reconData3d(reconData3d>highestValue) = highestValue;
  85. reconData3d(reconData3d<0) = 0;
  86. allIterTime(iter,1) = toc(tStart);
  87. % Save data
  88. indIter = find(nIter == iter);
  89. if(indIter~=0)
  90. allreconData3d{1,indIter} = reconData3d(parameter.iROI,parameter.jROI,parameter.sliceRange);
  91. info.IterationNumber = num2str(iter);
  92. info.IterationTime = num2str(sum(allIterTime(:)));
  93. allreconData3d{2,indIter} = info;
  94. end
  95. if(showinfo)
  96. fprintf('Iteration %d Time: %.2f\n\n',iter,allIterTime(iter,1));
  97. end
  98. end
  99. end