tumorDVH.asv 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. function tumorDVH(lin0625cm,root0625cm,quad0625cm)
  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\HN003uniPrescVolNew\PTV70DosePlus.bin');
  7. prescTumorLin = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003powerLaw\HN003linPrescVol\PTV70DosePlus.bin'); %open prescription in Matlab
  8. prescTumorRoot = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003powerLaw\HN003rootPrescVol\PTV70DosePlus.bin');
  9. prescTumorQuad = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003powerLaw\HN003quadPrescVol\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(uni245cm,'rb'); %open plans in Matlab
  18. % planUni245cm = reshape(fread(fid,'float'),72,72,dim);
  19. % fclose(fid);
  20. fid = fopen(lin0625cm,'rb'); %open plans in Matlab
  21. planLin245cm = reshape(fread(fid,'float'),72,72,dim);
  22. fclose(fid);
  23. fid = fopen(root0625cm,'rb'); %open plans in Matlab
  24. planLin0625cm = reshape(fread(fid,'float'),72,72,dim);
  25. fclose(fid);
  26. fid = fopen(quad025cm,'rb'); %open plans in Matlab
  27. planLin025cm = reshape(fread(fid,'float'),72,72,dim);
  28. fclose(fid);
  29. for i=1:prescNormal.Nind;
  30. prescNormal.non_zero_values(i)=1;
  31. end
  32. for i=1:prescLarynx.Nind;
  33. prescLarynx.non_zero_values(i)=1;
  34. end
  35. for i=1:prescRt.Nind;
  36. prescRt.non_zero_values(i)=1;
  37. end
  38. for i=1:prescLt.Nind;
  39. prescLt.non_zero_values(i)=1;
  40. end
  41. for i=1:prescCord.Nind;
  42. prescCord.non_zero_values(i)=1;
  43. end
  44. tumorMaskUni = single(~~(full3D(prescTumorUni)));
  45. tumorMaskLin = single(~~(full3D(prescTumorLin))); %define tissue masks
  46. tumorMaskRoot = single(~~(full3D(prescTumorRoot)));
  47. tumorMaskQuad = single(~~(full3D(prescTumorQuad)));
  48. % tumorDoseUni245cm = planUni245cm.*tumorMaskUni;
  49. tumorDoseLin0625cm = planLin0625cm.*tumorMaskLin; %dose distributions in each ROI
  50. tumorDoseRoot0625cm = planRoot0625cm.*tumorMaskLin;
  51. tumorDoseQuad0625cm = planQuad025cm.*tumorMaskLin;
  52. % tumorDoseSparseUni245cm = sparse3D(tumorDoseUni245cm); %convert 3D matrices to sparse matrices
  53. tumorDoseSparseLin0625cm = sparse3D(tumorDoseLin0625cm);
  54. tumorDoseSparseRoot0625cm = sparse3D(tumorDoseRoot0625cm);
  55. tumorDoseSparseQuad0625cm = sparse3D(tumorDoseQuad0625cm);
  56. tumorNormDoseLin0625cm = ((tumorDoseSparseLin0625cm.non_zero_values)./(prescTumorLin.non_zero_values)); %calculate equivalent uniform dose
  57. tumorAverageDoseLin0625cm = mean(prescTumorLin.non_zero_values);
  58. tumorEdoseLin0625cm = tumorNormDoseLin0625cm.*tumorAverageDoseLin0625cm;
  59. tumorNormDoseRoot0625cm = ((tumorDoseSparseRoot0625cm.non_zero_values)./(prescTumorRoot.non_zero_values)); %calculate equivalent uniform dose
  60. tumorAverageDoseLin245cm = mean(prescTumorRoot.non_zero_values);
  61. tumorEdoseLin0625cm = tumorNormDoseRoot0625cm.*tumorAverageDoseRoot0625cm;
  62. tumorNormDoseQuad0625cm = ((tumorDoseSparseQuad0625cm.non_zero_values)./(prescTumorQuad.non_zero_values)); %calculate equivalent uniform dose
  63. tumorAverageDoseQuad0625cm = mean(prescTumorQuad.non_zero_values);
  64. tumorEdoseQuad0625cm = tumorNormDoseQuad0625cm.*tumorAverageDoseQuad0625cm;
  65. % tumorNormDoseRoot245cm = ((tumorDoseSparseRoot245cm.non_zero_values)./(prescTumorRoot.non_zero_values)); %calculate equivalent uniform dose
  66. % tumorAverageDoseRoot245cm = mean(prescTumorRoot.non_zero_values);
  67. % tumorEdoseRoot245cm = tumorNormDoseRoot245cm.*tumorAverageDoseRoot245cm;
  68. %
  69. % tumorNormDoseQuad245cm = ((tumorDoseSparseQuad245cm.non_zero_values)./(prescTumorQuad.non_zero_values)); %calculate equivalent uniform dose
  70. % tumorAverageDoseQuad245cm = mean(prescTumorQuad.non_zero_values);
  71. % tumorEdoseQuad245cm = tumorNormDoseQuad245cm.*tumorAverageDoseQuad245cm;
  72. %
  73. % tumorNormDoseGomp245cm = ((tumorDoseSparseGomp245cm.non_zero_values)./(prescTumorGomp.non_zero_values)); %calculate equivalent uniform dose
  74. % tumorAverageDoseGomp245cm = mean(prescTumorGomp.non_zero_values);
  75. % tumorEdoseGomp245cm = tumorNormDoseGomp245cm.*tumorAverageDoseGomp245cm;
  76. dMax = 1.1*max(tumorEdoseLin245cm);
  77. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  78. dHistTumorLin245cm = histc(tumorEdoseLin245cm,dvhbins);
  79. dHistTumorLin0625cm = histc(tumorEdoseLin0625cm,dvhbins);
  80. dHistTumorLin025cm = histc(tumorEdoseLin025cm,dvhbins);
  81. % dHistTumorRoot245cm = histc(tumorEdoseRoot245cm,dvhbins);
  82. % dHistTumorQuad245cm = histc(tumorEdoseQuad245cm,dvhbins);
  83. % dHistTumorGomp245cm = histc(tumorEdoseGomp245cm,dvhbins);
  84. %
  85. %
  86. % % dHistTumorUni245cm = histc(tumorDoseSparseUni245cm.non_zero_values,dvhbins);
  87. % dHistTumorLin1 = histc(tumorDoseSparseLin245cm.non_zero_values,dvhbins);
  88. % dHistTumorLin2 = histc(tumorDoseSparseLin0625cm.non_zero_values,dvhbins);
  89. % dHistTumorLin3 = histc(tumorDoseSparseLin025cm.non_zero_values,dvhbins);
  90. %
  91. %
  92. % dHistTumorNormUni245cm = 100*dHistTumorUni245cm./(double(tumorDoseSparseUni245cm.Nind));
  93. dHistTumorNormLin245cm = 100*dHistTumorLin245cm./(double(tumorDoseSparseLin245cm.Nind));
  94. dHistTumorNormLin0625cm = 100*dHistTumorLin0625cm./(double(tumorDoseSparseLin0625cm.Nind));
  95. dHistTumorNormLin025cm = 100*dHistTumorLin025cm./(double(tumorDoseSparseLin025cm.Nind));
  96. % dHistTumorNormLin1 = 100*dHistTumorLin1./(double(tumorDoseSparseLin245cm.Nind));
  97. % dHistTumorNormLin2 = 100*dHistTumorLin2./(double(tumorDoseSparseLin245cm.Nind));
  98. % dHistTumorNormLin3 = 100*dHistTumorLin3./(double(tumorDoseSparseLin245cm.Nind));
  99. % DVHtumorUni245cm = flipud(cumsum(flipud(dHistTumorNormUni245cm)));
  100. DVHtumorLin245cm = flipud(cumsum(flipud(dHistTumorNormLin245cm)));
  101. DVHtumorLin0625cm = flipud(cumsum(flipud(dHistTumorNormLin0625cm)));
  102. DVHtumorLin025cm = flipud(cumsum(flipud(dHistTumorNormLin025cm)));
  103. % DVHtumorLin = flipud(cumsum(flipud(dHistTumorNormLin)));
  104. % DVHtumorRoot = flipud(cumsum(flipud(dHistTumorNormRoot)));
  105. % DVHtumorQuad = flipud(cumsum(flipud(dHistTumorNormQuad)));
  106. % DVHtumorGomp = flipud(cumsum(flipud(dHistTumorNormGomp)));
  107. tumorfigure(dvhbins,DVHtumorLin245cm,DVHtumorLin0625cm,DVHtumorLin025cm)
  108. end