public static bool MetricUsesGy(string metricName) { if (metricName == null) { return(false); } //first find if in custom metrics CustomMetricsConfiguration config = Myconfig.GetCustomMetricsSection(); foreach (CustomMetricElement custMetric in config.Metrics) { if (custMetric.Name == metricName) { if (custMetric.Base.Contains("Gy")) { return(true); } else { return(false); } } } //not a custom metric if (metricName.Contains("Gy") || metricName.Contains("Mean")) { return(true); } else { return(false); } }
private void chkBioDose_Checked(object sender, RoutedEventArgs e) { VMMetric metric = ((FrameworkElement)sender).DataContext as VMMetric; CheckBox chkbox = sender as CheckBox; DataGridRow row = dtaMetrics.ContainerFromElement(chkbox) as DataGridRow; if (row == null) { return; } int rowIndex = row.GetIndex(); VMStructure struc = dtaMetrics.Items[rowIndex] as VMStructure; //Get NTCP Parameters if (metric.NTCPParameters.AlphaBeta == 0) { BioDoseConfiguration bioConfig = Myconfig.GetBioDoseConfiguration(); if (struc.IsTarget) { metric.NTCPParameters.AlphaBeta = bioConfig.TargetAlphaBeta; } else { metric.NTCPParameters.AlphaBeta = bioConfig.OrganAlphaBeta; } } UpdateDoseMetrics(struc, metric); }
public static double CustomMetric(Structure structure, VMMetric metric, PlanSetup plan, bool useRapPlanEstimate) { CustomMetricsConfiguration config = Myconfig.GetCustomMetricsSection(); foreach (CustomMetricElement custMetric in config.Metrics) { if (metric.Name == custMetric.Name) { if (custMetric.Base == "D#%(Gy)") { return(GetDoseToVolume(structure, plan, custMetric.Parameter, DoseValuePresentation.Absolute, VolumePresentation.Relative, metric, useRapPlanEstimate)); } else if (custMetric.Base == "D#%(%)") { return(GetDoseToVolume(structure, plan, custMetric.Parameter, DoseValuePresentation.Relative, VolumePresentation.Relative, metric, useRapPlanEstimate)); } else if (custMetric.Base == "D#cc(Gy)") { return(GetDoseToVolume(structure, plan, custMetric.Parameter, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, metric, useRapPlanEstimate)); } else if (custMetric.Base == "D#cc(%)") { return(GetDoseToVolume(structure, plan, custMetric.Parameter, DoseValuePresentation.Relative, VolumePresentation.AbsoluteCm3, metric, useRapPlanEstimate)); } else if (custMetric.Base == "V#%(cc)") { return(GetVolumeWithDose(structure, plan, custMetric.Parameter, DoseValuePresentation.Relative, VolumePresentation.AbsoluteCm3, metric, useRapPlanEstimate)); } else if (custMetric.Base == "V#%(%)") { return(GetVolumeWithDose(structure, plan, custMetric.Parameter, DoseValuePresentation.Relative, VolumePresentation.Relative, metric, useRapPlanEstimate)); } else if (custMetric.Base == "V#Gy(cc)") { return(GetVolumeWithDose(structure, plan, custMetric.Parameter, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, metric, useRapPlanEstimate)); } else if (custMetric.Base == "V#Gy(%)") { return(GetVolumeWithDose(structure, plan, custMetric.Parameter, DoseValuePresentation.Absolute, VolumePresentation.Relative, metric, useRapPlanEstimate)); } } } //not one of the defined custom metric bases return(-1); }
private void chkStructures_Checked(object sender, RoutedEventArgs e) { CheckBox check = sender as CheckBox; TextBlock txt = check.Content as TextBlock; string strucId = txt.Text; VMStructure struc = _viewModel.Structures.FirstOrDefault(s => s.Id == strucId); DefaultMetricsConfiguration config = Myconfig.GetDefaultMetricsSection(); if (config != null) { foreach (DefaultMetricElement met in config.Metrics) { if (struc.Id.ToUpper().Contains(met.Structure.ToUpper())) { struc.DoseMetrics[0].Name = met.Metric; UpdateDoseMetrics(struc, struc.DoseMetrics[0]); break; } } } }
//MainControl constructor. This is where execution of this control starts public MainControl() { InitializeComponent(); _viewModel = new ViewModel(); this.DataContext = _viewModel; //populate default metric list MetricList = new List <string>(); foreach (Enum dmetric in Enum.GetValues(typeof(DoseMetrics))) { MetricList.Add(EnumUtils.stringValueOf(dmetric)); } //add custom defined metrics CustomMetricsConfiguration config = Myconfig.GetCustomMetricsSection(); foreach (CustomMetricElement metric in config.Metrics) { MetricList.Add(metric.Name); } }
public void LoadDVH(Structure structure, PlanSetup plan, DoseValuePresentation dosePresentation, VolumePresentation volPresentation, bool useRapPlanEstim = false) { BinSize = Convert.ToDouble(Myconfig.GetAppKey("DVHBinSize")); DVHData apiDVH = null; EstimatedDVH upEstDVH = null; EstimatedDVH lowEstDVH = null; if (volPresentation == VolumePresentation.AbsoluteCm3) { VolumeUnit = MyDVHData.VolumeUnits.cc; } else if (volPresentation == VolumePresentation.Relative) { VolumeUnit = MyDVHData.VolumeUnits.Percent; } else { VolumeUnit = MyDVHData.VolumeUnits.Unknown; } if (useRapPlanEstim) { upEstDVH = plan.DVHEstimates.FirstOrDefault(s => s.Structure.Id == structure.Id && s.Type == DVHEstimateType.Upper); lowEstDVH = plan.DVHEstimates.FirstOrDefault(s => s.Structure.Id == structure.Id && s.Type == DVHEstimateType.Lower); if (upEstDVH == null || lowEstDVH == null) { CurveData = null; return; } //TODO calc these from estimated DVH MaxDose = 0; MeanDose = 0; DoseUnit = (MyDVHData.DoseUnits)lowEstDVH.CurveData[0].DoseValue.Unit; CurveData = new DVHPoint[lowEstDVH.CurveData.Count()]; for (int i = 0; i < lowEstDVH.CurveData.Count(); i++) { double dose = lowEstDVH.CurveData[i].DoseValue.Dose; double volume = 0.5 * (lowEstDVH.CurveData[i].Volume + upEstDVH.CurveData[i].Volume); CurveData[i] = new DVHPoint { Dose = dose, Volume = volume }; } } else { apiDVH = plan.GetDVHCumulativeData(structure, dosePresentation, volPresentation, BinSize); if (apiDVH == null) { MessageBox.Show("Plan " + plan.Id + " contains no dose\nCannot calculate metrics", "Invalid data", MessageBoxButton.OK, MessageBoxImage.Information); return; } MaxDose = apiDVH.MaxDose.Dose; MeanDose = apiDVH.MeanDose.Dose; DoseUnit = (MyDVHData.DoseUnits)apiDVH.CurveData[0].DoseValue.Unit; CurveData = new DVHPoint[apiDVH.CurveData.Count()]; for (int i = 0; i < apiDVH.CurveData.Count(); i++) { CurveData[i] = new DVHPoint { Dose = apiDVH.CurveData[i].DoseValue.Dose, Volume = apiDVH.CurveData[i].Volume }; } } }