get_RTset_specific3D.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % Summary:
  3. % This script generates a phantom for heterogeneity analysis, as specified
  4. % by the parameters below.
  5. % See also article DOI: 10.2967/jnumed.116.181859
  6. % !! needs files from phantom_lesions Git !!
  7. %
  8. % cd('E:\010-work\003-localGit\intra_hetero\genPhantom');
  9. % Matlab version:
  10. % 2015a
  11. % Initially created: 5/15/2017 by Peter Ferjancic
  12. % last updated: 5/15/2017
  13. % Version: 1.0
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15. function get_RTset_specific3D
  16. imsize=[32, 32, 16];
  17. bckgrnd = 0;
  18. bckstd = 20;
  19. smoothR=1;
  20. plot='n'; % plot='y';
  21. % list all the lesion params you want
  22. % y,x,z r,intensity, std of lesion
  23. llist = ...
  24. [16,16,8, 8, 1000, 50.0;
  25. 16,16,8, 3, 100, 1.0
  26. 16,8,8, 3, 100, 1.0
  27. ];
  28. % -- no touchy fishy after this line --
  29. %% create canvas (determenistic phantom image)
  30. canvas = bckgrnd*ones(imsize);
  31. stds = bckstd *ones(imsize);
  32. contourTarget = zeros(imsize);
  33. contourROI = zeros(imsize);
  34. for i=1:size(llist,1)
  35. [canvas, stds] = supp_addSphere(canvas, stds, llist(i,1),llist(i,2),llist(i,3),llist(i,4), llist(i,5), llist(i,6));
  36. end
  37. [contourTarget, ~] = supp_addSphere(contourTarget, stds, llist(2,1),llist(2,2),llist(2,3),llist(2,4), 1, 0);
  38. [contourROI, ~] = supp_addSphere(contourROI, stds, llist(3,1),llist(3,2),llist(3,3),llist(3,4), 1, 0);
  39. %% Make it random and smooth it
  40. image=zeros(size(canvas));
  41. for yi=1:size(canvas, 1)
  42. for xi=1:size(canvas, 2)
  43. for zi=1:size(canvas, 3)
  44. image(yi,xi,zi) = canvas(yi,xi,zi) + stds(yi,xi,zi)*randn;
  45. end
  46. end
  47. end
  48. imageF=imgaussfilt(image,smoothR);
  49. if plot == 'y'
  50. %% plot result
  51. subplot(2,2,1)
  52. imagesc(canvas, [0,15])
  53. title('Signal')
  54. colorbar
  55. subplot(2,2,2)
  56. imagesc(stds, [0,10])
  57. title('STD')
  58. colorbar
  59. subplot(2,2,3)
  60. imagesc(image)
  61. title('Added noise')
  62. colorbar
  63. colormap('hot')
  64. subplot(2,2,4)
  65. imagesc(imageF)
  66. title('Final phantom')
  67. colorbar
  68. colormap('hot')
  69. end
  70. pixelspacing = [0.16,0.16,0.16];
  71. origin = [-1.1,-2.2,-3.3];
  72. encoding = 'ascii';
  73. filename = 'C:\010-work\003_localGit\WiscPlan_v2\PhantomData\test_ct.nrrd';
  74. matrix = imageF;
  75. nrrdWriter(filename, matrix, pixelspacing, origin, encoding);
  76. filename = 'C:\010-work\003_localGit\WiscPlan_v2\PhantomData\test_seg.nrrd';
  77. matrix = contourTarget;
  78. nrrdWriter(filename, matrix, pixelspacing, origin, encoding);
  79. filename = 'C:\010-work\003_localGit\WiscPlan_v2\PhantomData\test_ROI.nrrd';
  80. matrix = contourROI;
  81. nrrdWriter(filename, matrix, pixelspacing, origin, encoding);
  82. end