QVH.asv 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. addpath('C:\Documents and Settings\Steve\My Documents\Research\matlab')
  2. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqUtil')
  3. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input')
  4. Ndvhbins = 1000; %number of dvh bins
  5. prescFile = 'presc.img';
  6. planFile1 = 'plan1.img';
  7. planFile2 = 'plan2.img';
  8. planFile3 = 'plan3.img';
  9. dim1 = 512;
  10. dim2 = dim1;
  11. dim3 = 35; %3D matrix dimensions
  12. fid = fopen(prescFile,'rb'); %open plans in Matlab
  13. presc = reshape(fread(fid,'float'),dim1,dim2,dim3);
  14. fclose(fid);
  15. fid = fopen(planFile1,'rb'); %open plans in Matlab
  16. plan1 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  17. fclose(fid);
  18. fid = fopen(planFile2,'rb'); %open plans in Matlab
  19. plan2 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  20. fclose(fid);
  21. fid = fopen(prescFile3,'rb'); %open plans in Matlab
  22. plan3 = reshape(fread(fid,'float'),dim1,dim2,dim3);
  23. fclose(fid);
  24. PTVmask = single(~~(full3D(presc))); %define tissue masks
  25. PTVdose1 = plan1.*tumorMask; %dose distributions in each ROI
  26. PTVdose2 = plan2.*tumorMask; %dose distributions in each ROI
  27. PTVdose3 = plan3.*tumorMask; %dose distributions in each ROI
  28. PTVdoseSparse1 = sparse3D(PTVdose1);
  29. PTVdoseSparse2 = sparse3D(PTVdose2);
  30. PTVdoseSparse3 = sparse3D(PTVdose3);
  31. PTVnormDose1 = ((PTVdoseSparse1.non_zero_values)./(PTVpresc.non_zero_values)); %calculate equivalent uniform dose
  32. ind1 = find(((PTVnormDose1-1.).^2).^(1/2) >= 0.05); %find voxels whose plans deviate from prescription > 5 percent
  33. vol1 = 100.-double(length(ind1))./(double(PTVnormDose1.Nind))*100; %calculate PTV percentage whose plan is within 5 percent prescription
  34. PTVnormDose2 = ((PTVdoseSparse2.non_zero_values)./(PTVpresc.non_zero_values)); %calculate equivalent uniform dose
  35. ind2 = find(((PTVnormDose2-1.).^2).^(1/2) >= 0.05); %find voxels whose plans deviate from prescription > 5 percent
  36. vol2 = 100.-double(length(ind2))./(double(PTVnormDose2.Nind))*100; %calculate PTV percentage whose plan is within 5 percent prescription
  37. PTVnormDose3 = ((PTVdoseSparse3.non_zero_values)./(PTVpresc.non_zero_values)); %calculate equivalent uniform dose
  38. ind3 = find(((PTVnormDose3-1.).^2).^(1/2) >= 0.05); %find voxels whose plans deviate from prescription > 5 percent
  39. vol3 = 100.-double(length(ind3))./(double(PTVnormDose3.Nind))*100; %calculate PTV percentage whose plan is within 5 percent prescription
  40. dMax = 1.1*max(PTVnormDose1); %define maximum bin for QVH
  41. dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins; %define bins
  42. dHistPTVnormDose1 = histc(PTVnormDose1,dvhbins); %bin normalized PTV dose
  43. dHistPTVnormDose1 = 100*dHistPTVnormDose1./(double(PTVnormDose1.Nind)); %calculate frequency percentage of integral
  44. dHistPTVnormDose2 = histc(PTVnormDose2,dvhbins); %bin normalized PTV dose
  45. dHistPTVnormDose2 = 100*dHistPTVnormDose2./(double(PTVnormDose2.Nind)); %calculate frequency percentage of integral
  46. dHistPTVnormDose3 = histc(PTVnormDose3,dvhbins); %bin normalized PTV dose
  47. dHistPTVnormDose3 = 100*dHistPTVnormDose1./(double(PTVnormDose1.Nind)); %calculate frequency percentage of integral
  48. QVHptv = flipud(cumsum(flipud(dHistPTVnormDose))); %cumulatively sum histogram from max min to min bin
  49. plotQVH(dvhbins,QVHptv) %plot QVH