saveData.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. %% Author: Rodrigo de Barros Vimieiro
  2. % Date: Jun, 2018
  3. % rodrigo.vimieiro@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % saveData(dataRecon3d,parameter,title,folder,infoDicom)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function save projections of a virtual phantom or
  11. % reconstructed data.
  12. %
  13. %
  14. % INPUT:
  15. % - dataRecon3d = Reconstructed data
  16. % - parameter = Parameter of all geometry
  17. % - title = Title of the data (Dicom, Shepp-Logan, VCT)
  18. % - infoDicom = Dicom header from projections
  19. % - folder = Folder to save the data
  20. %
  21. % ---------------------------------------------------------------------
  22. % Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
  23. %
  24. % This program is free software: you can redistribute it and/or modify
  25. % it under the terms of the GNU General Public License as published by
  26. % the Free Software Foundation, either version 3 of the License, or
  27. % (at your option) any later version.
  28. %
  29. % This program is distributed in the hope that it will be useful,
  30. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. % GNU General Public License for more details.
  33. %
  34. % You should have received a copy of the GNU General Public License
  35. % along with this program. If not, see <http://www.gnu.org/licenses/>.
  36. %}
  37. % =========================================================================
  38. %% Save data
  39. function saveData(dataRecon3d,varargin)
  40. optionals = {[],[],[],[]}; % Placeholder for inputs
  41. numInputs = nargin - 1; % Minus number of required inputs
  42. inputVar = 1;
  43. while numInputs > 0
  44. if ~isempty(varargin{inputVar})
  45. optionals{inputVar} = varargin{inputVar};
  46. end
  47. inputVar = inputVar + 1;
  48. numInputs = numInputs - 1;
  49. end
  50. parameter = optionals{1};
  51. title = optionals{2};
  52. folder = optionals{3};
  53. infoDicom = optionals{4};
  54. if(isempty(folder))
  55. folder='Output';
  56. else
  57. mkdir([folder,filesep,title]);
  58. end
  59. % Some more informations to save
  60. for k=1:size(dataRecon3d,2)
  61. info = dataRecon3d{2,k};
  62. info.Title = title;
  63. dataRecon3d{2,k} = info;
  64. end
  65. filestring = [folder,filesep,title,filesep,'Reconstruction-',info.reconMeth];
  66. % Dicom breast/virtual phantom images
  67. if(~isempty(infoDicom))
  68. fprintf('\nWriting images ')
  69. writeDicom(dataRecon3d,infoDicom,filestring,info.reconMeth,parameter);
  70. else
  71. writeDcm(dataRecon3d,filestring,parameter)
  72. end
  73. fprintf('\nSaving data...')
  74. save(filestring,'dataRecon3d','-v7.3')
  75. end