tumorDVH.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. planLin0625cm = reshape(fread(fid,'float'),72,72,dim);
  22. fclose(fid);
  23. fid = fopen(root0625cm,'rb'); %open plans in Matlab
  24. planRoot0625cm = reshape(fread(fid,'float'),72,72,dim);
  25. fclose(fid);
  26. fid = fopen(quad0625cm,'rb'); %open plans in Matlab
  27. planQuad0625cm = 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.*tumorMaskRoot;
  51. tumorDoseQuad0625cm = planQuad0625cm.*tumorMaskQuad;
  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. tumorAverageDoseRoot0625cm = mean(prescTumorRoot.non_zero_values);
  61. tumorEdoseRoot0625cm = 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. dMax = 1.1*max(tumorEdoseRoot0625cm);
  66. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  67. dHistTumorLin0625cm = histc(tumorEdoseLin0625cm,dvhbins);
  68. dHistTumorRoot0625cm = histc(tumorEdoseRoot0625cm,dvhbins);
  69. dHistTumorQuad0625cm = histc(tumorEdoseQuad0625cm,dvhbins);
  70. % dHistTumorNormUni245cm = 100*dHistTumorUni245cm./(double(tumorDoseSparseUni245cm.Nind));
  71. dHistTumorNormLin0625cm = 100*dHistTumorLin0625cm./(double(tumorDoseSparseLin0625cm.Nind));
  72. dHistTumorNormRoot0625cm = 100*dHistTumorRoot0625cm./(double(tumorDoseSparseRoot0625cm.Nind));
  73. dHistTumorNormQuad0625cm = 100*dHistTumorQuad0625cm./(double(tumorDoseSparseQuad0625cm.Nind));
  74. % DVHtumorUni245cm = flipud(cumsum(flipud(dHistTumorNormUni245cm)));
  75. DVHtumorLin0625cm = flipud(cumsum(flipud(dHistTumorNormLin0625cm)));
  76. DVHtumorRoot0625cm = flipud(cumsum(flipud(dHistTumorNormRoot0625cm)));
  77. DVHtumorQuad0625cm = flipud(cumsum(flipud(dHistTumorNormQuad0625cm)));
  78. tumorfigure(dvhbins,DVHtumorLin0625cm,DVHtumorRoot0625cm,DVHtumorQuad0625cm)
  79. end