discreteLinQVH.m 10 KB

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