writeDicomProj.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. %% Author: Aleks Prša
  2. % Date: May, 2022
  3. % alex.prsa@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % writeDicomProj(dataProj,infoDicom,filestring,parameter)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function write a set of Dicom images with respective headers.
  11. %
  12. %
  13. % INPUT:
  14. % - dataProj = Projection images
  15. % - infoDicomProjs = Dicom header from projections
  16. % - filestring = Path to save
  17. % - parameter = Parameter of all geometry
  18. %
  19. % ---------------------------------------------------------------------
  20. %}
  21. % =========================================================================
  22. %% Write Dicom images
  23. function writeDicomProj(dataProj,infoDicom,filestring,parameter)
  24. for k=1:size(dataProj,3)
  25. dataProj = 65535*mat2gray(dataProj);
  26. dataProj = uint16(dataProj);
  27. end
  28. % Write dicom files in respective folder
  29. fprintf('%3d/%3d', 1, parameter.nProj)
  30. for i=1:size(dataProj,3)
  31. fprintf('\b\b\b\b\b\b\b%3d/%3d', i, parameter.nProj)
  32. if(i<10)
  33. fileimg = [filestring,filesep,'0',num2str(i),'.dcm'];
  34. else
  35. fileimg = [filestring,filesep,num2str(i),'.dcm'];
  36. end
  37. dicomwrite(dataProj(:,:,i), fileimg, infoDicom(:,1), 'CreateMode', 'copy');
  38. end
  39. end