plot_DVH.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. % ---- DVH PLOT FUNCTION ----
  2. function plot_DVH(dose, optGoal, optGoal_idx, targetMinMax_idx)
  3. % this function plots the DVHs of the given dose
  4. nfrac=1;
  5. figure
  6. hold on
  7. for roi_idx=optGoal_idx
  8. % plot the histogram
  9. [dvh dosebins] = get_dvh_data(dose,optGoal{roi_idx}.ROI_idx,nfrac);
  10. plot(dosebins, dvh,'Color', optGoal{roi_idx}.dvh_col,'LineStyle', '-','DisplayName', optGoal{roi_idx}.ROI_name);
  11. end
  12. hold off
  13. % get % of volume above/below threshold
  14. num_vox = numel(optGoal{targetMinMax_idx(1)}.target);
  15. perc_vox_min = 100* numel(find((dose(optGoal{targetMinMax_idx(1)}.ROI_idx) - optGoal{targetMinMax_idx(1)}.target*0.95) <0)) ...
  16. / num_vox;
  17. perc_vox_max = 100* numel(find((dose(optGoal{targetMinMax_idx(2)}.ROI_idx) - optGoal{targetMinMax_idx(2)}.target*1.07) >0)) ...
  18. / num_vox;
  19. title([num2str(perc_vox_min) ' % below 0.95D_0, ' num2str(perc_vox_max) ' % above D 1.07D_0'])
  20. axis([0 100 0 100])
  21. end
  22. function plot_DVH_robust(dose, optGoal, optGoal_idx)
  23. % this function plots the DVHs of the given dose
  24. nfrac=1;
  25. figure
  26. hold on
  27. for goal_i=optGoal_idx
  28. % for all the perturbations
  29. for nrs_i = 1:optGoal{1}.NbrRandScenarios
  30. for sss_i = 1:optGoal{1}.NbrSystSetUpScenarios % syst. setup scenarios = ss
  31. for rrs_i = 1:optGoal{1}.NbrRangeScenarios % range scenario = rs
  32. % plot the histogram
  33. ROI_idx = optGoal{goal_i}.nrs{nrs_i}.sss{sss_i}.rrs{rrs_i}.ROI_idx;
  34. [dvh dosebins] = get_dvh_data(dose,ROI_idx,nfrac);
  35. plot(dosebins, dvh,'Color', optGoal{goal_i}.dvh_col,'LineStyle', '-','DisplayName', optGoal{goal_i}.ROI_name);
  36. end
  37. end
  38. end
  39. end
  40. hold off
  41. end
  42. function [dvh dosebins] = get_dvh_data(dose,roi_idx,nfrac);
  43. % this function calculates the data for the DVH
  44. dosevec = dose(roi_idx);
  45. [pdf dosebins] = hist(dosevec, 999);
  46. % clip negative bins
  47. pdf = pdf(dosebins >= 0);
  48. dosebins = dosebins(dosebins >= 0);
  49. dvh = fliplr(cumsum(fliplr(pdf))) / numel(dosevec) * 100;
  50. % append the last bin
  51. dosebins = [dosebins dosebins(end)+0.1];
  52. dvh = [dvh 0];
  53. end