gradQVH.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. function gradQVH(uni,sig1,sig2,sig3,sig4,sig5,sig6,sig7,sig8)
  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. % prescTumorUni = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep1\phantrad1\boostrad2\contrast1\gradient2\input\G1DosePlus.bin');
  7. % prescTumorSig1 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep2\phantrad1\boostrad2\contrast1\gradient1\input\B1DosePlus.bin'); %open prescription in Matlab
  8. % prescTumorSig2 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep5\phantrad1\boostrad2\contrast1\gradient1\input\B1DosePlus.bin');
  9. % prescTumorSig3 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep10\phantrad1\boostrad2\contrast1\gradient1\input\B1DosePlus.bin');
  10. % prescTumorSig4 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradContinuous\phantrad1\boostrad2\contrast1\gradient1\input\B1DosePlus.bin');
  11. % prescTumorSig5 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep2\phantrad1\boostrad2\contrast1\gradient1\input\G1DosePlus.bin');
  12. % prescTumorSig6 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep5\phantrad1\boostrad2\contrast1\gradient1\input\G1DosePlus.bin');
  13. % prescTumorSig7 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\linGradStep10\phantrad1\boostrad2\contrast1\gradient1\input\G1DosePlus.bin');
  14. prescTumorSig8 = open_presc('C:\Documents and Settings\Steve\My Documents\Research\Phantom\optResults\laplaceContinuous\phantrad0\boostrad0\contrast0\a4\input\TumorMinusBoostDosePlus.bin');
  15. prescTumorUni = prescTumorSig8;
  16. prescTumorSig1 = prescTumorSig8;
  17. prescTumorSig2 = prescTumorSig8;
  18. prescTumorSig3 = prescTumorSig8;
  19. prescTumorSig4 = prescTumorSig8;
  20. prescTumorSig5 = prescTumorSig8;
  21. prescTumorSig6 = prescTumorSig8;
  22. prescTumorSig7 = prescTumorSig8;
  23. prescNormal = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\NormalDosePlus.bin');
  24. prescLarynx = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\larynxDosePlus.bin');
  25. prescRt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\RtparotidDosePlus.bin');
  26. prescLt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\LtparotidDosePlus.bin');
  27. prescCord = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\CordDosePlus.bin');
  28. dim1 = 170;
  29. dim2 = dim1;
  30. dim3 = 1; %3D
  31. fid = fopen(uni,'rb'); %open plans in Matlab
  32. planUni = reshape(fread(fid,'float'),dim1,dim2,dim3);
  33. fclose(fid);
  34. fid = fopen(sig1,'rb'); %open plans in Matlab
  35. planSig1 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  36. fclose(fid);
  37. fid = fopen(sig2,'rb'); %open plans in Matlab
  38. planSig2 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  39. fclose(fid);
  40. fid = fopen(sig3,'rb'); %open plans in Matlab
  41. planSig3 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  42. fclose(fid);
  43. fid = fopen(sig4,'rb'); %open plans in Matlab
  44. planSig4 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  45. fclose(fid);
  46. fid = fopen(sig5,'rb'); %open plans in Matlab
  47. planSig5 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  48. fclose(fid);
  49. fid = fopen(sig6,'rb'); %open plans in Matlab
  50. planSig6 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  51. fclose(fid);
  52. fid = fopen(sig7,'rb'); %open plans in Matlab
  53. planSig7 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  54. fclose(fid);
  55. fid = fopen(sig8,'rb'); %open plans in Matlab
  56. planSig8 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  57. fclose(fid);
  58. for i=1:prescNormal.Nind;
  59. prescNormal.non_zero_values(i)=1;
  60. end
  61. for i=1:prescLarynx.Nind;
  62. prescLarynx.non_zero_values(i)=1;
  63. end
  64. for i=1:prescRt.Nind;
  65. prescRt.non_zero_values(i)=1;
  66. end
  67. for i=1:prescLt.Nind;
  68. prescLt.non_zero_values(i)=1;
  69. end
  70. for i=1:prescCord.Nind;
  71. prescCord.non_zero_values(i)=1;
  72. end
  73. tumorMaskUni = single(~~(full3D(prescTumorUni)));
  74. tumorMaskSig1 = single(~~(full3D(prescTumorSig1))); %define tissue masks
  75. tumorMaskSig2 = single(~~(full3D(prescTumorSig2)));
  76. tumorMaskSig3 = single(~~(full3D(prescTumorSig3)));
  77. tumorMaskSig4 = single(~~(full3D(prescTumorSig4)));
  78. tumorMaskSig5 = single(~~(full3D(prescTumorSig5)));
  79. tumorMaskSig6 = single(~~(full3D(prescTumorSig6)));
  80. tumorMaskSig7 = single(~~(full3D(prescTumorSig7)));
  81. tumorMaskSig8 = single(~~(full3D(prescTumorSig8)));
  82. larynxMask = single(~~(full3D(prescLarynx)));
  83. rtMask = single(~~(full3D(prescRt)));
  84. cordMask = single(~~(full3D(prescCord)));
  85. tumorDoseUni = planUni.*tumorMaskUni;
  86. tumorDoseSig1 = planSig1.*tumorMaskSig1; %dose distributions in each ROI
  87. tumorDoseSig2 = planSig2.*tumorMaskSig2;
  88. tumorDoseSig3 = planSig3.*tumorMaskSig3;
  89. tumorDoseSig4 = planSig4.*tumorMaskSig4;
  90. tumorDoseSig5 = planSig5.*tumorMaskSig5;
  91. tumorDoseSig6 = planSig6.*tumorMaskSig6;
  92. tumorDoseSig7 = planSig7.*tumorMaskSig7;
  93. tumorDoseSig8 = planSig8.*tumorMaskSig8;
  94. tumorDoseSparseUni = sparse3D(tumorDoseUni);
  95. tumorDoseSparseSig1 = sparse3D(tumorDoseSig1);
  96. tumorDoseSparseSig2 = sparse3D(tumorDoseSig2);
  97. tumorDoseSparseSig3 = sparse3D(tumorDoseSig3);
  98. tumorDoseSparseSig4 = sparse3D(tumorDoseSig4);
  99. tumorDoseSparseSig5 = sparse3D(tumorDoseSig5);
  100. tumorDoseSparseSig6 = sparse3D(tumorDoseSig6);
  101. tumorDoseSparseSig7 = sparse3D(tumorDoseSig7);
  102. tumorDoseSparseSig8 = sparse3D(tumorDoseSig8);
  103. tumorNormDoseUni = ((tumorDoseSparseUni.non_zero_values)./(prescTumorUni.non_zero_values)); %calculate equivalent uniform dose
  104. tumorAverageDoseUni = mean(prescTumorUni.non_zero_values);
  105. tumorEdoseUni = tumorNormDoseUni.*tumorAverageDoseUni;
  106. tumorEdoseUni = tumorNormDoseUni;
  107. indUni = find(((tumorNormDoseUni-1.).^2).^(1/2) >= 0.05);
  108. volUni = 100.-double(length(indUni))./(double(tumorDoseSparseUni.Nind))*100
  109. tumorNormDoseSig1 = ((tumorDoseSparseSig1.non_zero_values)./(prescTumorSig1.non_zero_values)); %calculate equivalent uniform dose
  110. tumorAverageDoseSig1 = mean(prescTumorSig1.non_zero_values);
  111. tumorEdoseSig1 = tumorNormDoseSig1.*tumorAverageDoseSig1;
  112. tumorEdoseSig1 = tumorNormDoseSig1;
  113. indSig1 = find(((tumorNormDoseSig1-1.).^2).^(1/2) >= 0.05);
  114. volSig1 = 100.-double(length(indSig1))./(double(tumorDoseSparseSig1.Nind))*100
  115. tumorNormDoseSig2 = ((tumorDoseSparseSig2.non_zero_values)./(prescTumorSig2.non_zero_values)); %calculate equivalent uniform dose
  116. tumorAverageDoseSig2 = mean(prescTumorSig2.non_zero_values);
  117. tumorEdoseSig2 = tumorNormDoseSig2.*tumorAverageDoseSig2;
  118. tumorEdoseSig2 = tumorNormDoseSig2;
  119. indSig2 = find(((tumorNormDoseSig2-1.).^2).^(1/2) >= 0.05);
  120. volSig2 = 100.-double(length(indSig2))./(double(tumorDoseSparseSig2.Nind))*100
  121. tumorNormDoseSig3 = ((tumorDoseSparseSig3.non_zero_values)./(prescTumorSig3.non_zero_values)); %calculate equivalent uniform dose
  122. tumorAverageDoseSig3 = mean(prescTumorSig3.non_zero_values);
  123. tumorEdoseSig3 = tumorNormDoseSig3.*tumorAverageDoseSig3;
  124. tumorEdoseSig3 = tumorNormDoseSig3;
  125. indSig3 = find(((tumorNormDoseSig3-1.).^2).^(1/2) >= 0.05);
  126. volSig3 = 100.-double(length(indSig3))./(double(tumorDoseSparseSig3.Nind))*100
  127. tumorNormDoseSig4 = ((tumorDoseSparseSig4.non_zero_values)./(prescTumorSig4.non_zero_values)); %calculate equivalent uniform dose
  128. tumorAverageDoseSig4 = mean(prescTumorSig4.non_zero_values);
  129. tumorEdoseSig4 = tumorNormDoseSig4.*tumorAverageDoseSig4;
  130. tumorEdoseSig4 = tumorNormDoseSig4;
  131. indSig4 = find(((tumorNormDoseSig4-1.).^2).^(1/2) >= 0.05);
  132. volSig4 = 100.-double(length(indSig4))./(double(tumorDoseSparseSig4.Nind))*100
  133. tumorNormDoseSig5 = ((tumorDoseSparseSig5.non_zero_values)./(prescTumorSig5.non_zero_values)); %calculate equivalent uniform dose
  134. tumorAverageDoseSig5 = mean(prescTumorSig5.non_zero_values);
  135. tumorEdoseSig5 = tumorNormDoseSig5.*tumorAverageDoseSig5;
  136. tumorEdoseSig5 = tumorNormDoseSig5;
  137. indSig5 = find(((tumorNormDoseSig5-1.).^2).^(1/2) >= 0.05);
  138. volSig5 = 100.-double(length(indSig5))./(double(tumorDoseSparseSig5.Nind))*100
  139. tumorNormDoseSig6 = ((tumorDoseSparseSig6.non_zero_values)./(prescTumorSig6.non_zero_values)); %calculate equivalent uniform dose
  140. tumorAverageDoseSig6 = mean(prescTumorSig6.non_zero_values);
  141. tumorEdoseSig6 = tumorNormDoseSig6.*tumorAverageDoseSig6;
  142. tumorEdoseSig6 = tumorNormDoseSig6;
  143. indSig6 = find(((tumorNormDoseSig6-1.).^2).^(1/2) >= 0.05);
  144. volSig6 = 100.-double(length(indSig6))./(double(tumorDoseSparseSig6.Nind))*100
  145. tumorNormDoseSig7 = ((tumorDoseSparseSig7.non_zero_values)./(prescTumorSig7.non_zero_values)); %calculate equivalent uniform dose
  146. tumorAverageDoseSig7 = mean(prescTumorSig7.non_zero_values);
  147. tumorEdoseSig7 = tumorNormDoseSig7.*tumorAverageDoseSig7;
  148. tumorEdoseSig7 = tumorNormDoseSig7;
  149. indSig7 = find(((tumorNormDoseSig7-1.).^2).^(1/2) >= 0.05);
  150. volSig7 = 100.-double(length(indSig7))./(double(tumorDoseSparseSig7.Nind))*100
  151. tumorNormDoseSig8 = ((tumorDoseSparseSig8.non_zero_values)./(prescTumorSig8.non_zero_values)); %calculate equivalent uniform dose
  152. tumorAverageDoseSig8 = mean(prescTumorSig8.non_zero_values);
  153. tumorEdoseSig8 = tumorNormDoseSig8.*tumorAverageDoseSig8;
  154. tumorEdoseSig8 = tumorNormDoseSig8;
  155. indSig8 = find(((tumorNormDoseSig8-1.).^2).^(1/2) >= 0.05);
  156. volSig8 = 100.-double(length(indSig8))./(double(tumorDoseSparseSig8.Nind))*100
  157. dMax = 1.1*max(tumorEdoseSig1);
  158. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  159. dHistTumorUni = histc(tumorEdoseUni,dvhbins);
  160. dHistTumorSig1 = histc(tumorEdoseSig1,dvhbins);
  161. dHistTumorSig2 = histc(tumorEdoseSig2,dvhbins);
  162. dHistTumorSig3 = histc(tumorEdoseSig3,dvhbins);
  163. dHistTumorSig4 = histc(tumorEdoseSig4,dvhbins);
  164. dHistTumorSig5 = histc(tumorEdoseSig5,dvhbins);
  165. dHistTumorSig6 = histc(tumorEdoseSig6,dvhbins);
  166. dHistTumorSig7 = histc(tumorEdoseSig7,dvhbins);
  167. dHistTumorSig8 = histc(tumorEdoseSig8,dvhbins);
  168. dHistTumorNormUni = 100*dHistTumorUni./(double(tumorDoseSparseUni.Nind));
  169. dHistTumorNormSig1 = 100*dHistTumorSig1./(double(tumorDoseSparseSig1.Nind));
  170. dHistTumorNormSig2 = 100*dHistTumorSig2./(double(tumorDoseSparseSig2.Nind));
  171. dHistTumorNormSig3 = 100*dHistTumorSig3./(double(tumorDoseSparseSig3.Nind));
  172. dHistTumorNormSig4 = 100*dHistTumorSig4./(double(tumorDoseSparseSig4.Nind));
  173. dHistTumorNormSig5 = 100*dHistTumorSig5./(double(tumorDoseSparseSig5.Nind));
  174. dHistTumorNormSig6 = 100*dHistTumorSig6./(double(tumorDoseSparseSig6.Nind));
  175. dHistTumorNormSig7 = 100*dHistTumorSig7./(double(tumorDoseSparseSig7.Nind));
  176. dHistTumorNormSig8 = 100*dHistTumorSig8./(double(tumorDoseSparseSig8.Nind));
  177. DVHtumorUni = flipud(cumsum(flipud(dHistTumorNormUni)));
  178. DVHtumorSig1 = flipud(cumsum(flipud(dHistTumorNormSig1)));
  179. DVHtumorSig2 = flipud(cumsum(flipud(dHistTumorNormSig2)));
  180. DVHtumorSig3 = flipud(cumsum(flipud(dHistTumorNormSig3)));
  181. DVHtumorSig4 = flipud(cumsum(flipud(dHistTumorNormSig4)));
  182. DVHtumorSig5 = flipud(cumsum(flipud(dHistTumorNormSig5)));
  183. DVHtumorSig6 = flipud(cumsum(flipud(dHistTumorNormSig6)));
  184. DVHtumorSig7 = flipud(cumsum(flipud(dHistTumorNormSig7)));
  185. DVHtumorSig8 = flipud(cumsum(flipud(dHistTumorNormSig8)));
  186. % tumorSigFigure(dvhbins,DVHtumorUni,DVHtumorSig1,DVHtumorSig2,DVHtumorSig3,DVHtumorSig4,DVHtumorSig5,DVHtumorSig6,DVHtumorSig7,DVHtumorSig8)
  187. end