def distribution(roi=nil)
      raise ArgumentError, "Invalid argument 'roi'. Expected ROI, got #{roi.class}." if roi && !roi.is_a?(ROI)
      raise ArgumentError, "Invalid argument 'roi'. The specified ROI does not have the same StructureSet parent as this DoseVolume." if roi && roi.struct != @dose_series.plan.struct
      if roi
        # Extract a binary volume from the ROI, based on this DoseVolume:
        bin_vol = roi.bin_volume(self)
      else
        # Create a binary volume which marks the entire dose volume:
        bin_vol = BinVolume.from_volume(self)
      end
      # Create a DoseDistribution from the BinVolume:
      dose_distribution = DoseDistribution.create(bin_vol)
    end
def distribution(roi=nil)
      raise ArgumentError, "Invalid argument 'roi'. Expected ROI, got #{roi.class}." if roi && !roi.is_a?(ROI)
      raise ArgumentError, "Invalid argument 'roi'. The specified ROI does not have the same StructureSet parent as this DoseVolume." if roi && roi.struct != @dose_series.plan.struct
      if roi
        # Extract a binary volume from the ROI, based on this DoseVolume:
        bin_vol = roi.bin_volume(self)
      else
        # Create a binary volume which marks the entire dose volume:
        bin_vol = BinVolume.from_volume(self)
      end
      # Create a DoseDistribution from the BinVolume:
      dose_distribution = DoseDistribution.create(bin_vol)
    end
Extracts the dose distribution for a specified ROI (or entire volume)
 and a specified beam (or all beams).

 @param [ROI] roi a specific ROI for which to evalute the dose in (if omitted, the entire volume is evaluted)
 @return [DoseDistribution] the dose distribution for the selected region of interest