tumorBeamletDVH.asv 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. function tumorBeamletDVH(lin245cm,lin100cm,lin0625cm,lin025cm)
  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. %open prescription in Matlab
  7. %prescTumorLin = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003powerLaw\HN003linPrescVol\PTV70DosePlus.bin');
  8. %prescTumorLin = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\powerLaw\linPrescJake039cm\tumorDosePlus.bin');
  9. prescTumorLin = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003powerLaw\normPower1\PTV70DosePlus.bin');
  10. %dim = 1; %2D
  11. dim = 30; %3D
  12. fid = fopen(lin245cm,'rb'); %open plans in Matlab
  13. planLin0625cm = reshape(fread(fid,'float'),72,72,dim);
  14. fclose(fid);
  15. fid = fopen(lin100cm,'rb'); %open plans in Matlab
  16. planRoot0625cm = reshape(fread(fid,'float'),,47,dim);
  17. fclose(fid);
  18. fid = fopen(lin0625cm,'rb'); %open plans in Matlab
  19. planQuad0625cm = reshape(fread(fid,'float'),47,47,dim);
  20. fclose(fid);
  21. fid = fopen(lin025cm,'rb'); %open plans in Matlab
  22. planGomp0625cm = reshape(fread(fid,'float'),47,47,dim);
  23. fclose(fid);
  24. tumorMaskLin = single(~~(full3D(prescTumorLin))); %define tissue masks
  25. tumorMaskRoot = single(~~(full3D(prescTumorLin)));
  26. tumorMaskQuad = single(~~(full3D(prescTumorLin)));
  27. tumorMaskGomp = single(~~(full3D(prescTumorLin)));
  28. tumorDoseLin0625cm = planLin0625cm.*tumorMaskLin; %dose distributions in each ROI
  29. tumorDoseRoot0625cm = planRoot0625cm.*tumorMaskRoot;
  30. tumorDoseQuad0625cm = planQuad0625cm.*tumorMaskQuad;
  31. tumorDoseGomp0625cm = planGomp0625cm.*tumorMaskGomp;
  32. %convert 3D matrices to sparse matrices
  33. tumorDoseSparseLin0625cm = sparse3D(tumorDoseLin0625cm);
  34. tumorDoseSparseRoot0625cm = sparse3D(tumorDoseRoot0625cm);
  35. tumorDoseSparseQuad0625cm = sparse3D(tumorDoseQuad0625cm);
  36. tumorDoseSparseGomp0625cm = sparse3D(tumorDoseGomp0625cm);
  37. tumorNormDoseLin0625cm = ((tumorDoseSparseLin0625cm.non_zero_values)./(prescTumorLin.non_zero_values)); %calculate equivalent uniform dose
  38. tumorAverageDoseLin0625cm = mean(prescTumorLin.non_zero_values);
  39. tumorEdoseLin0625cm = tumorNormDoseLin0625cm.*tumorAverageDoseLin0625cm;
  40. tumorEdoseLin0625cm = tumorNormDoseLin0625cm;
  41. tumorNormDoseRoot0625cm = ((tumorDoseSparseRoot0625cm.non_zero_values)./(prescTumorLin.non_zero_values)); %calculate equivalent uniform dose
  42. tumorAverageDoseRoot0625cm = mean(prescTumorLin.non_zero_values);
  43. tumorEdoseRoot0625cm = tumorNormDoseRoot0625cm.*tumorAverageDoseRoot0625cm;
  44. tumorEdoseRoot0625cm = tumorNormDoseRoot0625cm;
  45. tumorNormDoseQuad0625cm = ((tumorDoseSparseQuad0625cm.non_zero_values)./(prescTumorLin.non_zero_values)); %calculate equivalent uniform dose
  46. tumorAverageDoseQuad0625cm = mean(prescTumorLin.non_zero_values);
  47. tumorEdoseQuad0625cm = tumorNormDoseQuad0625cm.*tumorAverageDoseQuad0625cm;
  48. tumorEdoseQuad0625cm = tumorNormDoseQuad0625cm;
  49. tumorNormDoseGomp0625cm = ((tumorDoseSparseGomp0625cm.non_zero_values)./(prescTumorLin.non_zero_values)); %calculate equivalent uniform dose
  50. tumorAverageDoseGomp0625cm = mean(prescTumorLin.non_zero_values);
  51. tumorEdoseGomp0625cm = tumorNormDoseGomp0625cm.*tumorAverageDoseGomp0625cm;
  52. tumorEdoseGomp0625cm = tumorNormDoseGomp0625cm;
  53. dMax = 1.1*max(tumorEdoseRoot0625cm);
  54. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  55. dHistTumorLin0625cm = histc(tumorEdoseLin0625cm,dvhbins);
  56. dHistTumorRoot0625cm = histc(tumorEdoseRoot0625cm,dvhbins);
  57. dHistTumorQuad0625cm = histc(tumorEdoseQuad0625cm,dvhbins);
  58. dHistTumorGomp0625cm = histc(tumorEdoseGomp0625cm,dvhbins);
  59. dHistTumorNormLin0625cm = 100*dHistTumorLin0625cm./(double(tumorDoseSparseLin0625cm.Nind));
  60. dHistTumorNormRoot0625cm = 100*dHistTumorRoot0625cm./(double(tumorDoseSparseRoot0625cm.Nind));
  61. dHistTumorNormQuad0625cm = 100*dHistTumorQuad0625cm./(double(tumorDoseSparseQuad0625cm.Nind));
  62. dHistTumorNormGomp0625cm = 100*dHistTumorGomp0625cm./(double(tumorDoseSparseGomp0625cm.Nind));
  63. DVHtumorLin0625cm = flipud(cumsum(flipud(dHistTumorNormLin0625cm)));
  64. DVHtumorRoot0625cm = flipud(cumsum(flipud(dHistTumorNormRoot0625cm)));
  65. DVHtumorQuad0625cm = flipud(cumsum(flipud(dHistTumorNormQuad0625cm)));
  66. DVHtumorGomp0625cm = flipud(cumsum(flipud(dHistTumorNormGomp0625cm)));
  67. % %rescale 1.00 cm due to misregistration
  68. % DVHtumorRoot0625cm = DVHtumorRoot0625cm./(dvhbins.')-1.8719;
  69. tumorfigure(dvhbins,DVHtumorLin0625cm,DVHtumorRoot0625cm,DVHtumorQuad0625cm,DVHtumorGomp0625cm)
  70. end