コード例 #1
0
ファイル: PQMs.cs プロジェクト: fishdda/VarianDeveloper
        public void addPQMInfo(PlanningItem plan, Structure organ, XmlWriter writer)
        {
            DVHData dvh = plan.GetDVHCumulativeData(organ, dvp, VolumePresentation.Relative, 0.1);

            if (dvh != null)
            {
                DoseValue dv = dvh.MeanDose;
                if (name.Length > 0)
                {
                    PQMUtilities.addDosePQMInfo(name, PQMUtilities.DosePQMType.MeanDose, dv, doseConstraint, upperLimit, writer);
                }
                else
                {
                    PQMUtilities.addDosePQMInfo(PQMUtilities.DosePQMType.MeanDose, dv, doseConstraint, upperLimit, writer);
                }
            }
            else
            {
                XElement pqm = new XElement("PQM",
                                            new XAttribute("type", "MeanDose"),
                                            new XAttribute("name", "Dmean < " + doseConstraint.ToString()),
                                            new XElement("Error", string.Format("Error calculating DVH for structure '{0}'.", organ.Id))
                                            );
                pqm.WriteTo(writer);
            }
        }
コード例 #2
0
        static void Execute(Application app)
        {
            // loop through all patients in the database, open each one and iterate
            // through all courses. For each course with Id == "Varian", print
            // info and approval status.
            foreach (PatientSummary ps in app.PatientSummaries)
            {
                Patient p = app.OpenPatient(ps);
                foreach (Course c in p.Courses)
                {
                    if (c.Id == "Varian")
                    {
                        foreach (PlanSetup plan in c.PlanSetups)
                        {
                            Console.WriteLine("{0}/{1}/{2} ({3})",
                                              p.Id, c.Id, plan.Id, plan.ApprovalStatus.ToString());
                            // print the max dose for each plan
                            if (plan.Dose != null)
                            {
                                plan.DoseValuePresentation = DoseValuePresentation.Absolute;
                                DoseValue dv = plan.Dose.DoseMax3D;
                                Console.WriteLine("  ->max dose = {0}", dv.ToString());
                            }
                            // code for Step 4 follows this comment:
                            foreach (Beam beam in plan.Beams)
                            {
                                Console.WriteLine("  {0}: {1} control points.", beam.Id, beam.ControlPoints.Count());

                                foreach (ControlPoint cp in beam.ControlPoints)
                                {
                                    Console.WriteLine("\tControl pt meterset = {0}", cp.MetersetWeight);
                                }
                            }
                        }
                    }
                }
                app.ClosePatient();
            }
        }
コード例 #3
0
        /// <summary>
        /// Computes the planned value of each constraint in the selected protocol
        /// </summary>
        private void ComputePlanValues()
        {
            //make sure structures are valid
            PlanResult = "";
            if (SelectedStructure.Name.Contains("Couch"))
            {
                PlanResult = "Couch structure cannot be used";
            }
            else if (SelectedStructure.IsEmpty)
            {
                PlanResult = "Structure is empty";
            }
            else if (SelectedStructure.DicomType == "MARKER")
            {
                PlanResult = "Structure is a Patient Marker";
            }
            else
            {
                DoseValue.DoseUnit systemUnits = _viewModel.SelectedPlanningItem.GetDVHCumulativeData(SelectedStructure, DoseValuePresentation.Absolute, VolumePresentation.Relative, 1).MeanDose.Unit;

                if (ConstraintType == ConstraintType.Dose)
                {
                    VolumePresentation    volPres  = ConstraintUnits == "%" ? VolumePresentation.Relative : VolumePresentation.AbsoluteCm3;
                    DoseValuePresentation dosePres = LimitUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;

                    DoseValue val    = _viewModel.SelectedPlanningItem.GetDoseAtVolume(SelectedStructure, Constraint, volPres, dosePres, _viewModel.PlanSumTotalDose);
                    DoseValue varVal = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetDoseAtVolume(SelectedStructure, VariationConstraint, volPres, dosePres, _viewModel.PlanSumTotalDose) : val;

                    //convert to correct units for display
                    if (!LimitUnits.Contains("%"))
                    {
                        val    = ConvertDoseUnits(val, LimitUnits);
                        varVal = ConvertDoseUnits(varVal, LimitUnits);
                    }

                    PlanValue              = val.Dose;
                    PlanValueText          = val.ToString();
                    PlanVariationValue     = varVal.Dose;
                    PlanVariationValueText = varVal.ToString();
                }
                else if (ConstraintType == ConstraintType.Volume)
                {
                    DoseValuePresentation dosePres = ConstraintUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;
                    VolumePresentation    volPres  = LimitUnits == "%" ? VolumePresentation.Relative : VolumePresentation.AbsoluteCm3;

                    DoseValue.DoseUnit doseUnit       = ConstraintUnits.ToLower().Contains("cgy") ? DoseValue.DoseUnit.cGy : DoseValue.DoseUnit.Gy;
                    double             tempConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempConstraint = Constraint * 100;
                    }

                    double tempVariationConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempVariationConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempVariationConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempVariationConstraint = Constraint * 100;
                    }

                    double vol    = dosePres == DoseValuePresentation.Absolute ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(tempConstraint, systemUnits), volPres) : _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(Constraint, DoseValue.DoseUnit.Percent), volPres, _viewModel.PlanSumTotalDose);
                    double varVol = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(tempVariationConstraint, systemUnits), volPres, _viewModel.PlanSumTotalDose) : vol;

                    PlanValue              = Math.Round(vol, 1);
                    PlanValueText          = PlanValue.ToString() + (volPres == VolumePresentation.Relative ? " %" : " cc");
                    PlanVariationValue     = Math.Round(varVol, 1);
                    PlanVariationValueText = PlanVariationValue.ToString() + (volPres == VolumePresentation.Relative ? " %" : " cc");
                }
                else if (ConstraintType == ConstraintType.Mean)
                {
                    DoseValuePresentation dosePres = dosePres = LimitUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;

                    DoseValue val    = _viewModel.SelectedPlanningItem.GetMeanDose(SelectedStructure, dosePres);
                    DoseValue varVal = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetMeanDose(SelectedStructure, dosePres) : val;

                    //convert to correct units for display
                    if (!LimitUnits.Contains("%"))
                    {
                        val    = ConvertDoseUnits(val, LimitUnits);
                        varVal = ConvertDoseUnits(varVal, LimitUnits);
                    }

                    PlanValue              = val.Dose;
                    PlanValueText          = val.ToString();
                    PlanVariationValue     = varVal.Dose;
                    PlanVariationValueText = varVal.ToString();
                }
                else if (ConstraintType == ConstraintType.Max)
                {
                    DoseValuePresentation dosePres = dosePres = LimitUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;

                    DoseValue val    = _viewModel.SelectedPlanningItem.GetMaxDose(SelectedStructure, dosePres);
                    DoseValue varVal = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetMaxDose(SelectedStructure, dosePres) : val;

                    //convert to correct units for display
                    if (!LimitUnits.Contains("%"))
                    {
                        val    = ConvertDoseUnits(val, LimitUnits);
                        varVal = ConvertDoseUnits(varVal, LimitUnits);
                    }

                    PlanValue              = val.Dose;
                    PlanValueText          = val.ToString();
                    PlanVariationValue     = varVal.Dose;
                    PlanVariationValueText = varVal.ToString();
                }
                else if (ConstraintType == ConstraintType.Min)
                {
                    DoseValuePresentation dosePres = dosePres = LimitUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;

                    DoseValue val    = _viewModel.SelectedPlanningItem.GetMinDose(SelectedStructure, dosePres);
                    DoseValue varVal = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetMinDose(SelectedStructure, dosePres) : val;

                    //convert to correct units for display
                    if (!LimitUnits.Contains("%"))
                    {
                        val    = ConvertDoseUnits(val, LimitUnits);
                        varVal = ConvertDoseUnits(varVal, LimitUnits);
                    }

                    PlanValue              = val.Dose;
                    PlanValueText          = val.ToString();
                    PlanVariationValue     = varVal.Dose;
                    PlanVariationValueText = varVal.ToString();
                }
                else if (ConstraintType == ConstraintType.ColdVolume)
                {
                    DoseValuePresentation dosePres = ConstraintUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;
                    VolumePresentation    volPres  = LimitUnits == "%" ? VolumePresentation.Relative : VolumePresentation.AbsoluteCm3;

                    DoseValue.DoseUnit doseUnit       = ConstraintUnits.ToLower().Contains("cgy") ? DoseValue.DoseUnit.cGy : DoseValue.DoseUnit.Gy;
                    double             tempConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempConstraint = Constraint * 100;
                    }

                    double tempVariationConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempVariationConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempVariationConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempVariationConstraint = Constraint * 100;
                    }

                    double vol    = dosePres == DoseValuePresentation.Absolute ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(tempConstraint, systemUnits), volPres) : _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(Constraint, DoseValue.DoseUnit.Percent), volPres, _viewModel.PlanSumTotalDose);
                    double varVol = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(tempVariationConstraint, systemUnits), volPres, _viewModel.PlanSumTotalDose) : vol;

                    //this is the normal volume getting the requested dose, to get cold volume we want the remaining volume in the structure getting less than the requested dose, so subtract it from the total structure volume
                    vol    = volPres == VolumePresentation.AbsoluteCm3 ? SelectedStructure.Volume - vol : 100 - vol;
                    varVol = volPres == VolumePresentation.AbsoluteCm3 ? SelectedStructure.Volume - varVol : 100 - varVol;

                    PlanValue              = Math.Round(vol, 1);
                    PlanValueText          = PlanValue.ToString() + (volPres == VolumePresentation.Relative ? " %" : " cc");
                    PlanVariationValue     = Math.Round(varVol, 1);
                    PlanVariationValueText = PlanVariationValue.ToString() + (volPres == VolumePresentation.Relative ? " %" : " cc");
                }
                else if (ConstraintType == ConstraintType.CI)
                {
                    Structure External;

                    if (_viewModel.SelectedStructureSet.Structures.Where(struc => struc.Id == "External" || struc.Id == "BODY" || struc.Id == "Body").Count() > 0)
                    {
                        External = _viewModel.SelectedStructureSet.Structures.Where(struc => struc.Id == "External" || struc.Id == "BODY" || struc.Id == "Body").FirstOrDefault();
                    }
                    else
                    {
                        MessageBox.Show("No body contour found for isodose volumes for CI calculation", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        throw new FormatException("No body contour found for isodose volumes for CI calculation");
                    }

                    DoseValuePresentation dosePres = ConstraintUnits == "%" ? DoseValuePresentation.Relative : DoseValuePresentation.Absolute;
                    VolumePresentation    volPres  = VolumePresentation.AbsoluteCm3;

                    DoseValue.DoseUnit doseUnit       = ConstraintUnits.ToLower().Contains("cgy") ? DoseValue.DoseUnit.cGy : DoseValue.DoseUnit.Gy;
                    double             tempConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempConstraint = Constraint * 100;
                    }

                    double tempVariationConstraint = 0;
                    if (doseUnit == systemUnits || doseUnit == DoseValue.DoseUnit.Percent)
                    {
                        tempVariationConstraint = Constraint;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.cGy)
                    {
                        tempVariationConstraint = Constraint / 100;
                    }
                    else if (doseUnit == DoseValue.DoseUnit.Gy)
                    {
                        tempVariationConstraint = Constraint * 100;
                    }

                    double vol    = dosePres == DoseValuePresentation.Absolute ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(External, new DoseValue(tempConstraint, systemUnits), volPres) : _viewModel.SelectedPlanningItem.GetVolumeAtDose(External, new DoseValue(Constraint, DoseValue.DoseUnit.Percent), volPres, _viewModel.PlanSumTotalDose);
                    double varVol = VariationConstraint != -1 ? _viewModel.SelectedPlanningItem.GetVolumeAtDose(External, new DoseValue(tempVariationConstraint, systemUnits), volPres, _viewModel.PlanSumTotalDose) : vol;

                    PlanValue     = Math.Round(vol / SelectedStructure.Volume, 1);
                    PlanValueText = PlanValue.ToString();
                }
                else
                {
                    MessageBox.Show("Invalid constraint type: " + ConstraintType + " for structure " + Structure, "Invalid Constraint Type", MessageBoxButton.OK, MessageBoxImage.Error);
                    throw new FormatException("Invalid constraint type: " + ConstraintType + " for structure " + Structure);
                }
            }

            //make it show up on the DVH
            //if it is contoured
            if (_viewModel.DVHStructures.Where(s => s.structure == SelectedStructure).Count() > 0)
            {
                _viewModel.DVHStructures.Where(s => s.structure == SelectedStructure).First().OnDVH = true;
            }
        }
コード例 #4
0
        public void Execute(ScriptContext context /*, System.Windows.Window window*/)
        {
            string finalSummary = "";


            PlanSetup plan        = context.PlanSetup;
            Patient   patient     = context.Patient;
            Structure PTV         = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("ptv")).First();
            Structure cord        = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("cord")).First();
            Structure cord05      = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("cord +0.5")).Single();
            Structure proxbronch  = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("proxbronchtree")).First();
            Structure proxbronch2 = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("proxbronchtree+2")).SingleOrDefault();
            Structure lungR       = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("lung r")).First();
            Structure lungL       = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("lung l")).First();
            Structure heart       = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("heart")).First();
            //Structure ITV = plan.StructureSet.Structures.Where(s=> s.Id.ToLower().Contains("itv")).First();
            //Structure GTV = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("gtvp")).First();
            Structure esophagus   = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("esophagus")).First();
            Structure proxtrachea = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("prox trachea")).First();
            Structure aorta       = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("aorta")).Single();
            Structure cm2         = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("2cm")).Single();
            Structure chestwall   = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("chestwall")).Single();
            //Structure ptvgtv = plan.StructureSet.Structures.Where(s=> s.Id.ToLower().Contains("ptv-gtv do")).Single();
            Structure brachiplex = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("brachial plexus")).Single();
            Structure skin       = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("skin")).Single();
            Structure body       = plan.StructureSet.Structures.Where(s => s.Id == "BODY").Single();
            Structure mm2        = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("2mm")).Single();
            Structure lungTotal  = plan.StructureSet.Structures.Where(s => s.Id.ToLower().Contains("lung total")).Single();

            DoseValue cordDG    = new DoseValue(2250, DoseValue.DoseUnit.cGy);
            DoseValue cordPG    = new DoseValue(3000, DoseValue.DoseUnit.cGy);
            DoseValue esophaDG  = new DoseValue(2750, DoseValue.DoseUnit.cGy);
            DoseValue esophaPG  = new DoseValue(3500, DoseValue.DoseUnit.cGy);
            DoseValue aortaDG   = new DoseValue(4700, DoseValue.DoseUnit.cGy);
            DoseValue aortaPG   = new DoseValue(1500, DoseValue.DoseUnit.cGy);
            DoseValue brachiDG  = new DoseValue(3000, DoseValue.DoseUnit.cGy);
            DoseValue brachiPG  = new DoseValue(3200, DoseValue.DoseUnit.cGy);
            DoseValue PTVG      = new DoseValue(5000, DoseValue.DoseUnit.cGy);
            DoseValue v50G      = new DoseValue(2500, DoseValue.DoseUnit.cGy);
            DoseValue v105      = new DoseValue(5250, DoseValue.DoseUnit.cGy);
            DoseValue v100G     = new DoseValue(5000, DoseValue.DoseUnit.cGy);
            DoseValue v20G      = new DoseValue(2000, DoseValue.DoseUnit.cGy);
            DoseValue tracheaDG = new DoseValue(1800, DoseValue.DoseUnit.cGy);
            DoseValue stomachDG = new DoseValue(2800, DoseValue.DoseUnit.cGy);
            DoseValue lung15    = new DoseValue(1250, DoseValue.DoseUnit.cGy);
            DoseValue lung10    = new DoseValue(1350, DoseValue.DoseUnit.cGy);
            DoseValue chestVD   = new DoseValue(3000, DoseValue.DoseUnit.cGy);
            DoseValue v90       = new DoseValue(4500, DoseValue.DoseUnit.cGy);

            double cordVG   = plan.GetVolumeAtDose(cord, cordDG, VolumePresentation.AbsoluteCm3);
            double PTV_vol  = PTV.Volume;
            double D50_vol  = plan.GetVolumeAtDose(body, v50G, VolumePresentation.AbsoluteCm3);
            double D100_vol = plan.GetVolumeAtDose(body, v100G, VolumePresentation.AbsoluteCm3);
            double V20      = plan.GetVolumeAtDose(lungTotal, v20G, VolumePresentation.Relative);

            double esophagV = plan.GetVolumeAtDose(esophagus, esophaDG, VolumePresentation.AbsoluteCm3);
            double brachiV  = plan.GetVolumeAtDose(brachiplex, brachiDG, VolumePresentation.AbsoluteCm3);
            double heartV   = plan.GetVolumeAtDose(heart, brachiPG, VolumePresentation.AbsoluteCm3);
            double tracheaV = plan.GetVolumeAtDose(proxtrachea, tracheaDG, VolumePresentation.AbsoluteCm3);
            double skinV    = plan.GetVolumeAtDose(skin, cordPG, VolumePresentation.AbsoluteCm3);
            //double stomachV = plan.GetVolumeAtDose(stomach, stomachDG, VolumePresentation.AbsoluteCm3);
            double chestV   = plan.GetVolumeAtDose(chestwall, cordPG, VolumePresentation.AbsoluteCm3);
            double lung15RV = plan.GetVolumeAtDose(lungR, lung15, VolumePresentation.AbsoluteCm3);
            double lung15LV = plan.GetVolumeAtDose(lungL, lung15, VolumePresentation.AbsoluteCm3);
            double lung10RV = plan.GetVolumeAtDose(lungR, lung10, VolumePresentation.AbsoluteCm3);
            double lung10LV = plan.GetVolumeAtDose(lungL, lung10, VolumePresentation.AbsoluteCm3);
            double cov100   = plan.GetVolumeAtDose(PTV, v100G, VolumePresentation.Relative);
            double cov90    = plan.GetVolumeAtDose(PTV, v90, VolumePresentation.Relative);
            double aortaV   = plan.GetVolumeAtDose(aorta, aortaDG, VolumePresentation.AbsoluteCm3);
            double cm2v     = plan.GetVolumeAtDose(cm2, v105, VolumePresentation.AbsoluteCm3);
            double bronchV  = plan.GetVolumeAtDose(proxbronch, esophaPG, VolumePresentation.AbsoluteCm3);


            DoseValue ptvmax   = plan.GetDVHCumulativeData(PTV, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue cm2P     = plan.GetDVHCumulativeData(cm2, DoseValuePresentation.Relative, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue esophagP = plan.GetDVHCumulativeData(esophagus, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue cordP    = plan.GetDVHCumulativeData(cord, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue mm2P     = plan.GetDVHCumulativeData(mm2, DoseValuePresentation.Relative, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue aortaP   = plan.GetDVHCumulativeData(aorta, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue brachiP  = plan.GetDVHCumulativeData(brachiplex, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue heartP   = plan.GetDVHCumulativeData(heart, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue tracheaP = plan.GetDVHCumulativeData(proxtrachea, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue skinP    = plan.GetDVHCumulativeData(skin, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            //DoseValue stomachP = plan.GetDVHCumulativeData(stomach, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue chestP  = plan.GetDVHCumulativeData(chestwall, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;
            DoseValue bronchP = plan.GetDVHCumulativeData(proxbronch, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.1).MaxDose;


            double hetero = 500000 / ptvmax.Dose;

            finalSummary += "Objective,Actual,Pass-Fail\nCoverage\n";
            finalSummary += "95% of PTV covered by 100% of Pres Dose," + Math.Round(cov100, 2) + "%," + PWF(20, 5, 100 - cov100) + '\n';
            finalSummary += "99% of PTV receives minimum of 90% prescribed dose," + Math.Round(cov90, 2) + "%," + PWF(5, 1, 100 - cov90) + '\n';
            finalSummary += "Dose Heterogeneity - Target Dose > 60% 0f PTV Max," + Math.Round(hetero, 2) + "%," + PWF(60, 40, 100 - hetero) + '\n';
            finalSummary += "High Dose Spillage - No Dose Greater than 105% outside PTV," + cm2P.ToString() + ',' + PWF(130, 105, cm2P.Dose) + '\n';
            finalSummary += "Spillage Volume:," + Math.Round(cm2v, 2) + " cc," + PWF(10, 1, cm2v) + '\n';
            finalSummary += "PTV Volume:," + Math.Round(PTV_vol, 2) + " cc" + '\n';
            finalSummary += "V100 / PTV:," + Math.Round(D100_vol / PTV_vol, 2) + ',' + PWF(1.5, 1.2, D100_vol / PTV_vol) + '\n';
            finalSummary += "V50 Volume:," + Math.Round(D50_vol, 2) + " cc\n";
            finalSummary += "D50_volume / PTV volume:," + Math.Round(D50_vol / PTV_vol, 2) + ',' + PWF(-.743 * Math.Log(PTV_vol) + 7.7335, -.668 * Math.Log(PTV_vol) + 6.4269, D50_vol / PTV_vol) + '\n';

            finalSummary += "2cm max dose:," + mm2P.ToString() + ',' + PWF(-4E-9 * Math.Pow(PTV_vol, 5) + 2E-6 * Math.Pow(PTV_vol, 4) - 4E-4 * Math.Pow(PTV_vol, 3) + 265E-4 * Math.Pow(PTV_vol, 2) - 2045E-4 * PTV_vol + 57.527, -4E-9 * Math.Pow(PTV_vol, 5) + 2E-6 * Math.Pow(PTV_vol, 4) - 2E-4 * Math.Pow(PTV_vol, 3) + 149E-4 * Math.Pow(PTV_vol, 2) - .0578 * PTV_vol + 49.81, mm2P.Dose) + '\n';
            finalSummary += "Critical Structures\n";
            finalSummary += "Lung V20: (percent of Volume <20%)," + Math.Round(V20, 2) + '%' + ',' + PWF(15, 10, V20) + '\n';
            finalSummary += "Spinal Cord Point Max: (< 30 Gy)," + cordP.ToString() + ',' + PWF(3000, 2800, cordP.Dose) + '\n';
            finalSummary += "Spinal Cord [email protected] Gy: (<.25cc)," + Math.Round(cordVG, 5) + " cc," + PWF(.25, .1, cordVG) + "\n";

            finalSummary += "Esophagus Max Point Dose: (<35Gy)," + esophagP.ToString() + ',' + PWF(3500, 3000, esophagP.Dose) + '\n';
            finalSummary += "Esophagus V@ 27.5 Gy: (<5cc)," + Math.Round(esophagV, 2) + "cc," + PWF(5, 4, esophagV) + '\n';
            finalSummary += "Brachial Plexus max point dose: (<32 Gy)," + brachiP.ToString() + ',' + PWF(3200, 3000, brachiP.Dose) + '\n';
            finalSummary += "Brachial Plexus volume @30Gy: (<3cc)," + Math.Round(brachiV, 2) + " cc," + PWF(3, 2.5, brachiV) + "\n";

            finalSummary += "Heart Point Max: (<38 Gy)," + heartP.ToString() + ',' + PWF(3800, 3500, heartP.Dose) + '\n';
            finalSummary += "Heart V@32 Gy: (<3cc)," + Math.Round(heartV, 2) + " cc," + PWF(15, 10, heartV) + "\n";

            finalSummary += "Aorta max point dose: (<53 Gy)," + aortaP.ToString() + ',' + PWF(5300, 5100, aortaP.Dose) + '\n';
            finalSummary += "Aorta V@ 47Gy: (<10cc)," + Math.Round(aortaV, 2) + ',' + PWF(10, 8, aortaV) + '\n';
            finalSummary += "Trachea Point Max: (<38 Gy)," + tracheaP.ToString() + ',' + PWF(3800, 3500, tracheaP.Dose) + '\n';
            finalSummary += "Trachea V@18 Gy: (<4cc)," + Math.Round(tracheaV, 2) + " cc," + PWF(4, 3, tracheaV) + "\n";
            finalSummary += "Bronchus Point Max: (<38 Gy)," + bronchP.ToString() + ',' + PWF(3800, 3500, bronchP.Dose) + '\n';
            finalSummary += "Bronchus V@18 Gy: (< 4cc), " + Math.Round(bronchV, 2) + " cc," + PWF(4, 3, bronchV) + "\n";
            finalSummary += "Skin Point Max: (<32 Gy)," + skinP.ToString() + ',' + PWF(3200, 3000, skinP.Dose) + '\n';
            finalSummary += "Skin V@30 Gy: (<30cc)," + Math.Round(skinV, 2) + " cc," + PWF(10, 8, skinV) + "\n";

            //finalSummary += "Stomach V@28 Gy: " + Math.Round(stomachV, 2) + " cc,"+ PWF(10, 8, stomachV) +"\n";
            //finalSummary += "Stomach Point Max: " + stomachP.ToString() +','+ PWF(3200, 3000) +'\n';

            //finalSummary += "Chest Wall Point Max: ()," + chestP.ToString() + ',' + '\n';
            finalSummary += "Chest Wall V@30 Gy: (<30cc)," + Math.Round(chestV, 2) + " cc," + PWF(30, 25, chestV) + "\n";

            finalSummary += "Right Lung [email protected] Gy: (<1500cc)," + Math.Round(lung15RV, 2) + " cc," + PWF(1500, 1250, lung15RV) + "\n";
            finalSummary += "Left Lung [email protected] Gy: (<1500cc)," + Math.Round(lung15LV, 2) + " cc," + PWF(1500, 1250, lung15LV) + "\n";
            finalSummary += "Right Lung [email protected] Gy: (<1000cc)," + Math.Round(lung10RV, 2) + " cc," + PWF(1000, 800, lung10RV) + "\n";
            finalSummary += "Left Lung [email protected] Gy: (<1000cc)," + Math.Round(lung10LV, 2) + " cc," + PWF(1000, 800, lung10LV) + "\n";
            StreamWriter Sw = new StreamWriter("v:\\Special_Phys_Reports\\" + patient.LastName + '_' + patient.Id + "Lung_5x10.csv");

            Sw.WriteLine(finalSummary);
            Sw.Close();
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
0
ファイル: PQMs.cs プロジェクト: fishdda/VarianDeveloper
        public static void addDosePQMInfo(DosePQMType type, DoseValue dv, DoseValue doseConstraint, double upperLimit, XmlWriter writer)
        {
            string dosePQMName = string.Format("{0} < {1}", (type == DosePQMType.MaxDose) ? "Dmax" : "Dmean", doseConstraint.ToString());

            XElement pqm = new XElement("PQM",
                                        new XAttribute("type", type.ToString()),
                                        new XAttribute("name", dosePQMName),
                                        getDVXML(dv),
                                        getEvaluateXML(dv, doseConstraint, upperLimit));

            pqm.WriteTo(writer);
        }