error_DVHs.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. close all
  2. pat_path='C:\010-work\003_localGit\WiscPlan_v2\data\PatientData';
  3. % geometry
  4. load([pat_path '\matlab_files\Geometry.mat'])
  5. load([pat_path '\matlab_files\optResults.mat'])
  6. CTin=Geometry.data;
  7. dose_01 = optResults.dose{end};
  8. % colorwash(CTin, dose_01, [-500, 500], [0,60])
  9. %% Get the original image DVH
  10. roi_idx = 1;
  11. color_01 = [0.9,0.1,0.1];
  12. ROI_01 = logical(zeros(size(CTin)));
  13. ROI_01(Geometry.ROIS{1, roi_idx}.ind) = 1;
  14. % orthoslice(ROI, [0,1])
  15. %% get the DVH for a shifted image (but no corrections)
  16. % Shift up
  17. color_10 = [0.9,0.1,0.9];
  18. for plotIdx =1:8;
  19. shiftAngleList= [0, pi/2, pi, 1.5*pi];
  20. shiftAngle = shiftAngleList(1);
  21. shiftmag = 0.25 *plotIdx;
  22. shift = shiftmag * [cos(shiftAngle), sin(shiftAngle)];
  23. dose_s1 = imtranslate(dose_01, shift, 'FillValues', 0);
  24. [dvh_10{plotIdx}, dosebins_10{plotIdx}] = dvhist(dose_s1, ROI_01);
  25. end
  26. % colorwash(CTin, dose_s1, [-500, 500], [0,60])
  27. color_11 = [0.5,0.2,0.3];
  28. for plotIdx=1:10;
  29. shiftmag = 1;
  30. shiftAngle= 2*pi*rand();
  31. shift = shiftmag*rand() * [cos(shiftAngle), sin(shiftAngle)];
  32. dose_s1 = imtranslate(dose_01, shift, 'FillValues', 0);
  33. [dvh_11{plotIdx}, dosebins_11{plotIdx}] = dvhist(dose_s1, ROI_01);
  34. end
  35. %% get DVH for shifted CT images
  36. color_20 = [0.5,0.2,0.8];
  37. load('dosePert_01.mat')
  38. [dvh_20{1}, dosebins_20{1}] = dvhist(D, ROI_01);
  39. load('dosePert_02.mat')
  40. [dvh_20{2}, dosebins_20{2}] = dvhist(D, ROI_01);
  41. load('dosePert_03.mat')
  42. [dvh_20{3}, dosebins_20{3}] = dvhist(D, ROI_01);
  43. load('dosePert_04.mat')
  44. [dvh_20{4}, dosebins_20{4}] = dvhist(D, ROI_01);
  45. %% get DVH for shifted CT images
  46. color_30 = [0.2,0.9,0.2];
  47. load('dosePert_11.mat')
  48. [dvh_30{1}, dosebins_30{1}] = dvhist(D, ROI_01);
  49. load('dosePert_12.mat')
  50. [dvh_30{2}, dosebins_30{2}] = dvhist(D, ROI_01);
  51. load('dosePert_13.mat')
  52. [dvh_30{3}, dosebins_30{3}] = dvhist(D, ROI_01);
  53. load('dosePert_14.mat')
  54. [dvh_30{4}, dosebins_30{4}] = dvhist(D, ROI_01);
  55. load('dosePert_15.mat')
  56. [dvh_30{5}, dosebins_30{5}] = dvhist(D, ROI_01);
  57. load('dosePert_16.mat')
  58. [dvh_30{6}, dosebins_30{6}] = dvhist(D, ROI_01);
  59. %% Plot stuff
  60. % colorwash(CTin, D, [-500, 500], [0,60])
  61. % original image
  62. [dvh_01, dosebins_01] = dvhist(dose_01, ROI_01);
  63. figure
  64. hold on
  65. % % ---- shifted dose
  66. for i=1:size(dosebins_10,2)
  67. plot(dosebins_10{i}, dvh_10{i}, 'Color', color_10 , 'LineStyle', '--', 'DisplayName', 'test');
  68. end
  69. for i=1:size(dosebins_11,2)
  70. plot(dosebins_11{i}, dvh_11{i}, 'Color', color_11 , 'LineStyle', '--', 'DisplayName', 'test');
  71. end
  72. for i=1:4
  73. plot(dosebins_20{i}, dvh_20{i}, 'Color', color_20 , 'LineStyle', '--', 'DisplayName', 'test');
  74. end
  75. %
  76. % for i=1:6
  77. % plot(dosebins_30{i}, dvh_30{i}, 'Color', color_30 , 'LineStyle', '--', 'DisplayName', 'test');
  78. % end
  79. plot(dosebins_01, dvh_01, 'Color', color_01 , 'LineStyle', '-', 'DisplayName', 'test');
  80. hold off
  81. xlabel('Dose (Gy)')
  82. ylabel('Volume (%)')