gradQVH.asv 12 KB

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