Microcalcification.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. %% Author: Aleks Prša
  2. % Date: June, 2022
  3. % alex.prsa@gmail.com
  4. % =========================================================================
  5. %{
  6. %
  7. % DESCRIPTION:
  8. %
  9. % Program for inserting microcalcifications on breast projection images.
  10. %
  11. % Faculty of Mathematic and Physics
  12. % University in Ljubljana
  13. % Ljubljana, Slovenia
  14. %
  15. %}
  16. % =========================================================================
  17. %% Insertion code
  18. close all;clear;clc
  19. %% Load components
  20. addpath(genpath('Functions'));
  21. addpath(genpath('Parameters'));
  22. if(~exist('Output','dir'))
  23. mkdir('Output')
  24. end
  25. addpath('Output');
  26. ParameterSettings_MicroInsertion
  27. % Load projection data
  28. path_User = userpath;
  29. path_ProjData = uigetdir(path_User);
  30. if(path_ProjData == 0)
  31. fprintf('Cancelled by user \n');
  32. return;
  33. else
  34. userpath(path_ProjData)
  35. fprintf('Reading DICOMs ')
  36. answer = '0';
  37. [dataProj,infoDicom] = readDicom(path_ProjData,parameter,answer);
  38. parameter.bitDepth = infoDicom(:,1).BitDepth;
  39. end
  40. % Create phantom with inserted microcalcifications
  41. fprintf('\nPhantom...')
  42. microData = phantom(parameter);
  43. microData(microData<0) = eps;
  44. microData = flip(microData, 1); % Phantom in accordance with coordinate system
  45. microData = flip(microData, 2); % Source is on the left side
  46. % Perform virtual imaging of microcalcifications
  47. fprintf('\nProjections ')
  48. attenuationMicro = projectionMicro(microData,parameter);
  49. attenuationMicro = flip(attenuationMicro, 2); % Image captured with source on the right side
  50. %% Microcalcification insertion
  51. % Breast attenuation
  52. attenuationBreast = dataProj - parameter.mu;
  53. attenuationBreast(attenuationBreast < 0) = 0;
  54. % Additional attenuation due to microcalcifications
  55. microProj = attenuationBreast .* attenuationMicro + parameter.mu;
  56. %% Save data
  57. filestring = ['Output',filesep,'Microcalcifications',filesep,'Projections'];
  58. if(~exist(filestring))
  59. mkdir(filestring)
  60. end
  61. fprintf('\nWriting DICOM projections ')
  62. writeDicomProj(attenuationMicro,infoDicom,filestring,parameter);
  63. fprintf('\nSaving projections... \n')
  64. save(['Output',filesep,'Microcalcifications',filesep,'Microcalcifications.mat'],'microProj','-v7.3');
  65. infoDicom = [];
  66. fprintf('\nFINISHED - Data stored in "Microcalcification" folder\n')
  67. beep