예제 #1
0
 public static double GetVolumeAtDose(this PlanningItem pitem, Structure structure, DoseValue dose, VolumePresentation requestedVolumePresentation)
 {
     if (pitem is PlanSetup)
     {
         return(((PlanSetup)pitem).GetVolumeAtDose(structure, dose, requestedVolumePresentation));
     }
     else
     {
         DVHData dvh = pitem.GetDVHCumulativeData(structure, DoseValuePresentation.Absolute, requestedVolumePresentation, 0.001);
         return(DvhExtensions.VolumeAtDose(dvh, dose.Dose));
     }
 }
예제 #2
0
 public static double GetVolumeAtDose(this PlanningItem pitem, Structure structure, DoseValue dose, VolumePresentation requestedVolumePresentation)
 {
     if (pitem is PlanSetup)
     {
         //try catch statement to switch dose units to system presentation. Otherwise exception "Dose Units do not match to system settings
         try
         {
             return(((PlanSetup)pitem).GetVolumeAtDose(structure, dose, requestedVolumePresentation));
         }
         catch
         {
             if (dose.Unit.CompareTo(DoseValue.DoseUnit.cGy) == 0)
             {
                 return(((PlanSetup)pitem).GetVolumeAtDose(structure, new DoseValue(dose.Dose / 100, DoseValue.DoseUnit.Gy), requestedVolumePresentation));
             }
             else if (dose.Unit.CompareTo(DoseValue.DoseUnit.Gy) == 0)
             {
                 return(((PlanSetup)pitem).GetVolumeAtDose(structure, new DoseValue(dose.Dose * 100, DoseValue.DoseUnit.cGy), requestedVolumePresentation));
             }
             else
             {
                 return(((PlanSetup)pitem).GetVolumeAtDose(structure, dose, requestedVolumePresentation));
             }
         }
     }
     else
     {
         DVHData dvh = pitem.GetDVHCumulativeData(structure, DoseValuePresentation.Absolute, requestedVolumePresentation, 0.001);
         //convert dose unit to system unit: otherwise false output without warning
         try
         {
             ((PlanSum)pitem).PlanSetups.First().GetVolumeAtDose(structure, dose, requestedVolumePresentation);
             return(DvhExtensions.VolumeAtDose(dvh, dose.Dose));
         }
         catch
         {
             if (dose.Unit.CompareTo(DoseValue.DoseUnit.cGy) == 0)
             {
                 return(DvhExtensions.VolumeAtDose(dvh, dose.Dose / 100));
             }
             else if (dose.Unit.CompareTo(DoseValue.DoseUnit.Gy) == 0)
             {
                 return(DvhExtensions.VolumeAtDose(dvh, dose.Dose * 100));
             }
             else
             {
                 return(DvhExtensions.VolumeAtDose(dvh, dose.Dose));
             }
         }
     }
 }
예제 #3
0
        public static double GetVolumeAtDose(this PlanningItem pitem, Structure structure, DoseValue dose, VolumePresentation requestedVolumePresentation, DoseValue?planSumRx = null)
        {
            //Get units that the dose is represented in within Eclipse but can't call that function if it's requesting % for a plan sum, so if that's the case it must be set manually
            DoseValue.DoseUnit systemUnits = DoseValue.DoseUnit.Percent;
            if (dose.Unit != DoseValue.DoseUnit.Percent)
            {
                systemUnits = pitem.GetDVHCumulativeData(structure, dose.Unit == DoseValue.DoseUnit.Percent ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute, VolumePresentation.Relative, 1).MeanDose.Unit;
            }

            //When calling GetVolumeAtDose, the dose must be in the same units as the system is set to

            //If "dose" is in %, they should be equal, but we will convert them if they are not equal to each other
            if (dose.Unit != systemUnits)
            {
                if (dose.Unit == DoseValue.DoseUnit.cGy && systemUnits == DoseValue.DoseUnit.Gy)
                {
                    dose = new DoseValue(dose.Dose / 100.0, DoseValue.DoseUnit.Gy);
                }
                else if (dose.Unit == DoseValue.DoseUnit.Gy && systemUnits == DoseValue.DoseUnit.cGy)
                {
                    dose = new DoseValue(dose.Dose * 100.0, DoseValue.DoseUnit.cGy);
                }
                else
                {
                    MessageBox.Show(String.Format("There was an error converting {0}, with units of {1} into the units used by Eclipse, {2}\n\nExpected values were cGy and Gy", dose.ToString(), dose.Unit.ToString(), systemUnits.ToString()), String.Format("Error during calculation of V{0}", dose.ToString()), MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            //Now functions can be called as normal
            if (pitem is PlanSetup)
            {
                return(((PlanSetup)pitem).GetVolumeAtDose(structure, dose, requestedVolumePresentation));
            }
            else
            {
                DVHData dvh = pitem.GetDVHCumulativeData(structure, DoseValuePresentation.Absolute, requestedVolumePresentation, 0.001);

                if (dose.Unit == DoseValue.DoseUnit.Percent)
                {
                    //MessageBox.Show(String.Format("Only absolute dose is supported for Plan Sums.  A prescription dose of {1} will be assumed to convert the V{0} for {2} into a percentage.", dosecGy.ToString(), planSumRx.ToString(), structure.Id), String.Format("Error during calculation of V{0}", dosecGy.ToString()), MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(DvhExtensions.VolumeAtDose(dvh, dose.Dose, planSumRx));
                }
                else
                {
                    return(DvhExtensions.VolumeAtDose(dvh, dose.Dose));
                }
            }
        }
예제 #4
0
        //---------------------------------------------------------------------------------------------
        void UpdateDvhLookup()
        {
            if (m_closing || SelectedStructure == null)
            {
                return;
            }

            bool doseAbsolute = m_absDoseCheckbox.IsChecked.Value;
            bool volAbsolute  = m_absVolCheckbox.IsChecked.Value;

            m_volumeAtDoseResultLabel.Content = "";
            m_doseAtVolumeResultLabel.Content = "";

            m_resultVolumeAtDose.Content = "";
            m_resultDoseAtVolume.Content = "";
            m_structureVolume.Text       = "";

            double inputVolume = Double.NaN;

            if (m_volumeTextBox.Text != null)
            {
                Double.TryParse(m_volumeTextBox.Text, out inputVolume);
            }

            double inputDose = Double.NaN;

            if (m_doseTextBox.Text != null)
            {
                Double.TryParse(m_doseTextBox.Text, out inputDose);
            }

            DoseValuePresentation dosePres = doseAbsolute ? DoseValuePresentation.Absolute : DoseValuePresentation.Relative;
            VolumePresentation    volPres  = volAbsolute ? VolumePresentation.AbsoluteCm3 : VolumePresentation.Relative;

            DVHData dvhData = SelectedPlanningItem.GetDVHCumulativeData(SelectedStructure, dosePres, volPres, s_binWidth);

            m_structureVolume.Text = dvhData.Volume.ToString("F5");

            if (SelectedPlanningItem != null && SelectedPlanningItem.Dose != null && SelectedStructure != null)
            {
                if (!Double.IsNaN(inputVolume))
                {
                    DoseValue val        = SelectedPlanningItem.GetDoseAtVolume(SelectedStructure, inputVolume, volPres, dosePres);
                    DoseValue controlVal = DvhExtensions.DoseAtVolume(dvhData, inputVolume);
                    double    err        = Math.Abs((val.Dose - controlVal.Dose) / val.Dose);
                    if (err > 0.001)
                    {
                        MessageBox.Show("Value : " + val.ToString() + " Control Val : " + controlVal.ToString());
                    }
                    m_resultDoseAtVolume.Content = val.ToString();

                    string doseAtVolumeResultType = volAbsolute ? "cm3 D(" : "% D(";
                    doseAtVolumeResultType           += inputVolume.ToString("F1") + (volAbsolute ? "cm3" : "%") + ") =";
                    m_doseAtVolumeResultLabel.Content = doseAtVolumeResultType;
                }
                if (!Double.IsNaN(inputDose))
                {
                    DoseValue.DoseUnit doseUnit = dvhData.MaxDose.Unit;
                    double             vol      = SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(inputDose, doseUnit), volPres);

                    double controlVal = DvhExtensions.VolumeAtDose(dvhData, inputDose);
                    double err        = Math.Abs((vol - controlVal) / vol);
                    if (err > 0.001)
                    {
                        MessageBox.Show("Value : " + vol.ToString("F3") + " Control Val : " + controlVal.ToString("F3"));
                    }

                    m_resultVolumeAtDose.Content = vol.ToString("F5") + (volAbsolute ? "cm3" : "%");

                    string volumeAtDoseResultType = doseUnit.ToString() + " V(";
                    volumeAtDoseResultType           += inputDose.ToString("F1") + doseUnit.ToString() + " ) =";
                    m_volumeAtDoseResultLabel.Content = volumeAtDoseResultType;
                }
            }
        }