humaneDVH.asv 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. function humaneDVH(planName245cm,planName0625cm)
  2. addpath('C:\Documents and Settings\Steve\My Documents\Research\matlab')
  3. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqUtil')
  4. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input')
  5. Ndvhbins = 1000; %number of dvh bins
  6. %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003linPrescVol\PTV70DosePlus.bin'); %open prescription in Matlab
  7. %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003rootPrescVol\PTV70DosePlus.bin');
  8. %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003quadPrescVol\PTV70DosePlus.bin');
  9. prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003gompPrescVol\PTV70DosePlus.bin');
  10. prescNormal = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\NormalDosePlus.bin');
  11. prescLarynx = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\larynxDosePlus.bin');
  12. prescRt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\RtparotidDosePlus.bin');
  13. prescLt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\LtparotidDosePlus.bin');
  14. prescCord = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\CordDosePlus.bin');
  15. %dim = 1; %2D
  16. dim = 30; %3D
  17. fid = fopen(planName245cm,'rb'); %open plans in Matlab
  18. plan245cm = reshape(fread(fid,'float'),72,72,dim);
  19. fclose(fid);
  20. fid = fopen(planName0625cm,'rb'); %open plans in Matlab
  21. plan0625cm = reshape(fread(fid,'float'),72,72,dim);
  22. fclose(fid);
  23. for i=1:prescNormal.Nind;
  24. prescNormal.non_zero_values(i)=1;
  25. end
  26. for i=1:prescLarynx.Nind;
  27. prescLarynx.non_zero_values(i)=1;
  28. end
  29. for i=1:prescRt.Nind;
  30. prescRt.non_zero_values(i)=1;
  31. end
  32. for i=1:prescLt.Nind;
  33. prescLt.non_zero_values(i)=1;
  34. end
  35. for i=1:prescCord.Nind;
  36. prescCord.non_zero_values(i)=1;
  37. end
  38. tumorMask = single(~~(full3D(prescTumor))); %define tissue masks
  39. normalMask = single(~~(full3D(prescNormal)));
  40. larynxMask = single(~~(full3D(prescLarynx)));
  41. rtMask = single(~~(full3D(prescRt)));
  42. ltMask = single(~~(full3D(prescLt)));
  43. cordMask = single(~~(full3D(prescCord)));
  44. tumorDose245cm = plan245cm.*tumorMask; %dose distributions in each ROI
  45. tumorDose0625cm = plan0625cm.*tumorMask;
  46. normalDose245cm = plan245cm.*normalMask;
  47. normalDose0625cm = plan0625cm.*normalMask;
  48. larynxDose245cm = plan245cm.*larynxMask;
  49. larynxDose0625cm = plan0625cm.*larynxMask;
  50. rtDose245cm = plan245cm.*rtMask;
  51. rtDose0625cm = plan0625cm.*rtMask;
  52. ltDose245cm = plan245cm.*ltMask;
  53. ltDose0625cm = plan0625cm.*ltMask;
  54. cordDose245cm = plan245cm.*cordMask;
  55. cordDose0625cm = plan0625cm.*cordMask;
  56. tumorDoseSparse245cm = sparse3D(tumorDose245cm); %convert 3D matrices to sparse matrices
  57. tumorDoseSparse0625cm = sparse3D(tumorDose0625cm);
  58. normalDoseSparse245cm = sparse3D(normalDose245cm);
  59. normalDoseSparse0625cm = sparse3D(normalDose0625cm);
  60. larynxDoseSparse245cm = sparse3D(larynxDose245cm);
  61. larynxDoseSparse0625cm = sparse3D(larynxDose0625cm);
  62. rtDoseSparse245cm = sparse3D(rtDose245cm);
  63. rtDoseSparse0625cm = sparse3D(rtDose0625cm);
  64. ltDoseSparse245cm = sparse3D(ltDose245cm);
  65. ltDoseSparse0625cm = sparse3D(ltDose0625cm);
  66. cordDoseSparse245cm = sparse3D(cordDose245cm);
  67. cordDoseSparse0625cm = sparse3D(cordDose0625cm);
  68. tumorNormDose245cm = ((tumorDoseSparse245cm.non_zero_values)./(prescTumor.non_zero_values)); %calculate equivalent uniform dose
  69. tumorAverageDose245cm = mean(prescTumor.non_zero_values);
  70. tumorEdose245cm = tumorNormDose245cm.*tumorAverageDose245cm;
  71. tumorNormDose0625cm = ((tumorDoseSparse0625cm.non_zero_values)./(prescTumor.non_zero_values)); %calculate equivalent uniform dose
  72. tumorAverageDose0625cm = mean(prescTumor.non_zero_values);
  73. tumorEdose0625cm = tumorNormDose0625cm.*tumorAverageDose245cm;
  74. tumorPrescNorm245cm =
  75. % NON UNIFORM PRESCRIPTIONS TO NORMAL TISSUE AND OAR
  76. % normalNormDose = ((normalDoseSparse.non_zero_values)./(prescNormal.non_zero_values));
  77. % normalAverageDose = mean(normalDoseSparse.non_zero_values);
  78. % normalEdose = normalNormDose.*normalAverageDose;
  79. %
  80. % eyesNormDose = ((eyesDoseSparse.non_zero_values)./(prescEyes.non_zero_values));
  81. % eyesAverageDose = mean(eyesDoseSparse.non_zero_values);
  82. % eyesEdose = eyesNormDose.*eyesAverageDose;
  83. dMax = 1.1*max(tumorEdose245cm);
  84. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  85. dHistTumor245cm = histc(tumorEdose245cm,dvhbins);
  86. dHistTumor0625cm = histc(tumorEdose0625cm,dvhbins);
  87. % dHistNormal = histc(normalEdose,dvhbins);
  88. % dHistEyes = histc(eyesEdose,dvhbins);
  89. dHistTumor = histc(tumorDoseSparse0625cm.non_zero_values,dvhbins);
  90. dHistPresc = histc(prescTumor.non_zero_values,dvhbins);
  91. dHistNormal245cm = histc(normalDoseSparse245cm.non_zero_values,dvhbins);
  92. dHistNormal0625cm = histc(normalDoseSparse0625cm.non_zero_values,dvhbins);
  93. dHistLarynx245cm = histc(larynxDoseSparse245cm.non_zero_values,dvhbins);
  94. dHistLarynx0625cm = histc(larynxDoseSparse0625cm.non_zero_values,dvhbins);
  95. dHistRt245cm = histc(rtDoseSparse245cm.non_zero_values,dvhbins);
  96. dHistRt0625cm = histc(rtDoseSparse0625cm.non_zero_values,dvhbins);
  97. dHistLt245cm = histc(ltDoseSparse245cm.non_zero_values,dvhbins);
  98. dHistLt0625cm = histc(ltDoseSparse0625cm.non_zero_values,dvhbins);
  99. dHistCord245cm = histc(cordDoseSparse245cm.non_zero_values,dvhbins);
  100. dHistCord0625cm = histc(cordDoseSparse0625cm.non_zero_values,dvhbins);
  101. dHistTumorNorm245cm = 100*dHistTumor245cm./(double(tumorDoseSparse245cm.Nind));
  102. dHistTumorNorm0625cm = 100*dHistTumor0625cm./(double(tumorDoseSparse0625cm.Nind));
  103. dHistNormalNorm245cm = 100*dHistNormal245cm./(double(normalDoseSparse245cm.Nind));
  104. dHistNormalNorm0625cm = 100*dHistNormal0625cm./(double(normalDoseSparse0625cm.Nind));
  105. dHistLarynxNorm245cm = 100*dHistLarynx245cm./(double(larynxDoseSparse245cm.Nind));
  106. dHistLarynxNorm0625cm = 100*dHistLarynx0625cm./(double(larynxDoseSparse0625cm.Nind));
  107. dHistRtNorm245cm = 100*dHistRt245cm./(double(rtDoseSparse245cm.Nind));
  108. dHistRtNorm0625cm = 100*dHistRt0625cm./(double(rtDoseSparse0625cm.Nind));
  109. dHistLtNorm245cm = 100*dHistLt245cm./(double(ltDoseSparse245cm.Nind));
  110. dHistLtNorm0625cm = 100*dHistLt0625cm./(double(ltDoseSparse0625cm.Nind));
  111. dHistCordNorm245cm = 100*dHistCord245cm./(double(cordDoseSparse245cm.Nind));
  112. dHistCordNorm0625cm = 100*dHistCord0625cm./(double(cordDoseSparse0625cm.Nind));
  113. dHistTumor = 100*dHistTumor/(prescTumor.Nind);
  114. dHistPresc = 100*dHistPresc/(prescTumor.Nind);
  115. DVHtumor = flipud(cumsum(flipud(dHistTumor)));
  116. DVHpresc = flipud(cumsum(flipud(dHistPresc)));
  117. DVHtumor245cm = flipud(cumsum(flipud(dHistTumorNorm245cm)));
  118. DVHtumor0625cm = flipud(cumsum(flipud(dHistTumorNorm0625cm)));
  119. DVHnormal245cm = flipud(cumsum(flipud(dHistNormalNorm245cm)));
  120. DVHnormal0625cm = flipud(cumsum(flipud(dHistNormalNorm0625cm)));
  121. DVHlarynx245cm = flipud(cumsum(flipud(dHistLarynxNorm245cm)));
  122. DVHlarynx0625cm = flipud(cumsum(flipud(dHistLarynxNorm0625cm)));
  123. DVHrt245cm = flipud(cumsum(flipud(dHistRtNorm245cm)));
  124. DVHrt0625cm = flipud(cumsum(flipud(dHistRtNorm0625cm)));
  125. DVHlt245cm = flipud(cumsum(flipud(dHistLtNorm245cm)));
  126. DVHlt0625cm = flipud(cumsum(flipud(dHistLtNorm0625cm)));
  127. DVHcord245cm = flipud(cumsum(flipud(dHistCordNorm245cm)));
  128. DVHcord0625cm = flipud(cumsum(flipud(dHistCordNorm0625cm)));
  129. humanfigure(dvhbins,DVHtumor,DVHpresc,DVHtumor245cm,DVHtumor0625cm)
  130. %
  131. %DVHnormal245cm,DVHnormal0625cm,DVHlarynx245cm,DVHlarynx0625cm,DVHrt245cm,DVHrt0625cm,DVHlt245cm,DVHlt0625cm,DVHcord245cm,DVHcord0625cm)
  132. end