eDVH.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. function eDVH(planName)
  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\jake')
  5. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input')
  6. Ndvhbins = 1000; %number of dvh bins
  7. prescTumor = open_presc('PTV70DosePlus.bin'); %open prescription in Matlab
  8. prescNormal = open_presc('NormalDosePlus.bin');
  9. prescEyes = open_presc('EyesDosePlus.bin');
  10. %dim = 1; %2D
  11. dim = 35; %3D
  12. fid = fopen(planName,'rb'); %open plan in Matlab
  13. plan = reshape(fread(fid,'float'),93,93,dim);
  14. fclose(fid);
  15. for i=1:prescNormal.Nind;
  16. prescNormal.non_zero_values(i)=1;
  17. end
  18. for i=1:prescEyes.Nind;
  19. prescEyes.non_zero_values(i)=1;
  20. end
  21. tumorMask = single(~~(full3D(prescTumor))); %define tissue masks
  22. normalMask = single(~~(full3D(prescNormal)));
  23. eyesMask = single(~~(full3D(prescEyes)));
  24. tumorDose = plan.*tumorMask; %dose distributions in each ROI
  25. normalDose = plan.*normalMask;
  26. eyesDose = plan.*eyesMask;
  27. tumorDoseSparse = sparse3D(tumorDose); %convert 3D matrices to sparse matrices
  28. normalDoseSparse = sparse3D(normalDose);
  29. eyesDoseSparse = sparse3D(eyesDose);
  30. tumorNormDose = ((tumorDoseSparse.non_zero_values)./(prescTumor.non_zero_values)); %calculate equivalent uniform dose
  31. tumorAverageDose = mean(prescTumor.non_zero_values);
  32. tumorEdose = tumorNormDose.*tumorAverageDose;
  33. % NON UNIFORM PRESCRIPTIONS TO NORMAL TISSUE AND OAR
  34. % normalNormDose = ((normalDoseSparse.non_zero_values)./(prescNormal.non_zero_values));
  35. % normalAverageDose = mean(normalDoseSparse.non_zero_values);
  36. % normalEdose = normalNormDose.*normalAverageDose;
  37. %
  38. % eyesNormDose = ((eyesDoseSparse.non_zero_values)./(prescEyes.non_zero_values));
  39. % eyesAverageDose = mean(eyesDoseSparse.non_zero_values);
  40. % eyesEdose = eyesNormDose.*eyesAverageDose;
  41. dMax = 1.1*max(tumorEdose);
  42. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins;
  43. dHistTumor = histc(tumorEdose,dvhbins);
  44. % dHistNormal = histc(normalEdose,dvhbins);
  45. % dHistEyes = histc(eyesEdose,dvhbins);
  46. %dHistTumor = histc(tumorDoseSparse.non_zero_values,dvhbins);
  47. dHistNormal = histc(normalDoseSparse.non_zero_values,dvhbins);
  48. dHistEyes = histc(eyesDoseSparse.non_zero_values,dvhbins);
  49. dHistTumorNorm = 100*dHistTumor./(double(tumorDoseSparse.Nind));
  50. dHistNormalNorm = 100*dHistNormal./(double(normalDoseSparse.Nind));
  51. dHistEyesNorm = 100*dHistEyes./(double(eyesDoseSparse.Nind));
  52. DVHtumor = flipud(cumsum(flipud(dHistTumorNorm)));
  53. DVHnormal = flipud(cumsum(flipud(dHistNormalNorm)));
  54. DVHeyes = flipud(cumsum(flipud(dHistEyesNorm)));
  55. createfigure(dvhbins,DVHtumor,DVHnormal,DVHeyes)
  56. end