public double GetDoseAtVolumeForUncertainties(curve DVH, double Volume, VolumePresentation VolPres, DoseValuePresentation RequestedDosePresentation) { double dose; if (DVH.VolumePresentation == VolumePresentation.AbsoluteCm3 && VolPres == VolumePresentation.Relative) { Volume = Volume * DVH.AbsoluteStructureVolume / 100.0; } if (DVH.VolumePresentation == VolumePresentation.Relative && VolPres == VolumePresentation.AbsoluteCm3) { Volume = Volume / DVH.AbsoluteStructureVolume * 100.0; } int ind1 = DVH.CurveData.Select(x => x.Volume).Count() - DVH.CurveData.Where(x => x.Volume < Volume).Select(x => x.Volume).Count() - 1; int ind2 = DVH.CurveData.Select(x => x.Volume).Count() - DVH.CurveData.Where(x => x.Volume < Volume).Select(x => x.Volume).Count(); DVHPoint DVP1 = DVH.CurveData.ElementAt(ind1); DVHPoint DVP2 = DVH.CurveData.ElementAt(ind2); dose = Interpolate(DVP1.Volume, DVP2.Volume, DVP1.DoseValue.Dose, DVP2.DoseValue.Dose, Volume); if (DVH.DoseValuePresentation == DoseValuePresentation.Absolute && RequestedDosePresentation == DoseValuePresentation.Relative) { dose = dose / DVH.PrescribedDose * 100.0; } if (DVH.DoseValuePresentation == DoseValuePresentation.Relative && RequestedDosePresentation == DoseValuePresentation.Absolute) { dose = dose * DVH.PrescribedDose / 100.0; } return(dose); }
/// <summary> /// Function used to group Plan DVH with Uncertainty DVHs and retun the set as a list of curves. /// </summary> /// <param name="IP"></param> /// <param name="ST"></param> /// <returns></returns> public List <curve> GetDVHDataWithUncertainties(IonPlanSetup IP, Structure ST, VolumePresentation VP, DoseValuePresentation DP, double BinWidth) { List <curve> Curves = new List <curve>(); curve temp_curve = new curve(); temp_curve.Id = "U0"; temp_curve.DoseValuePresentation = DP; temp_curve.VolumePresentation = VP; temp_curve.StructureName = ST.Id; temp_curve.AbsoluteStructureVolume = ST.Volume; temp_curve.PrescribedDose = IP.TotalDose.Dose / IP.TreatmentPercentage; temp_curve.CurveData = IP.GetDVHCumulativeData(ST, temp_curve.DoseValuePresentation, temp_curve.VolumePresentation, BinWidth).CurveData; Curves.Add(temp_curve); if (IP.PlanUncertainties.Count() != 0) { foreach (PlanUncertainty PU in IP.PlanUncertainties) { try { temp_curve = new curve(); temp_curve.Id = PU.Id; temp_curve.IsocenterShift = PU.IsocenterShift; temp_curve.DoseValuePresentation = DP; temp_curve.VolumePresentation = VP; temp_curve.StructureName = ST.Id; temp_curve.AbsoluteStructureVolume = ST.Volume; temp_curve.PrescribedDose = IP.TotalDose.Dose / IP.TreatmentPercentage; temp_curve.CalibrationCurveError = PU.CalibrationCurveError; temp_curve.DisplayName = PU.DisplayName; temp_curve.CurveData = PU.GetDVHCumulativeData(ST, temp_curve.DoseValuePresentation, temp_curve.VolumePresentation, BinWidth).CurveData; Curves.Add(temp_curve); } catch { } } } return(Curves); }