phantom.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. %% Author: Aleks Prša
  2. % Date: July, 2022
  3. % alex.prsa@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % phantom(parameter)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function create a 3D virtual phantom.
  11. %
  12. % INPUT:
  13. % - parameter = Parameter of all geometry
  14. %
  15. % OUTPUT:
  16. % - phantom = Virtual phantom attenuation data.
  17. %
  18. % ---------------------------------------------------------------------
  19. %}
  20. % =========================================================================
  21. %% Create virtual phantom
  22. function data3d = phantom(parameter)
  23. data3d = zeros(parameter.nx, parameter.ny, parameter.nz);
  24. xyzr = readmatrix('Mikrokalcinacije.txt');
  25. for i = 1:size(xyzr, 1)
  26. mu = xyzr(i, 1); % Attenuation coefficient of microcalcification (1/mm)
  27. y0 = xyzr(i, 2); % y offset of microcalcification in pixels
  28. x0 = xyzr(i, 3); % x offset of microcalcification in pixels
  29. z0 = xyzr(i, 4); % z offset of microcalcification in slice number of original tomogram
  30. r = xyzr(i, 5) / 2000; % Radius of microcalcification (mm)
  31. z0 = (z0-1) * 10; % Transform z offset from slice number to pixel value
  32. a = r / parameter.dx; % Radius in x-axis
  33. b = r / parameter.dy; % Radius in y-axis
  34. c = r / parameter.dz; % Radius in z-axis
  35. a = a^2;
  36. b = b^2;
  37. c = c^2;
  38. for z = 1:parameter.nz
  39. for y = 1:parameter.ny
  40. for x = 1:parameter.nx
  41. if((x-x0)^2 / a + (y-y0)^2 / b + (z-z0)^2 / c <= 1)
  42. data3d(x,y,z) = data3d(x,y,z) + mu;
  43. end
  44. end
  45. end
  46. end
  47. end
  48. data3d = data3d - 0.03756; % Attenuation correction - microcalcification-H2O
  49. data3d(data3d < 0) = 0;
  50. %data3d(data3d == 0) = 0.0357776; % Attenuation coefficient of PMMA (1/mm) surrounding microcalcifications
  51. data3d = flip(data3d, 1);
  52. end