private IEnumerable <double> GetLeafWidthsFromAria(
            Patient patient, PlanSetup plan, Beam beam)
        {
            var course = plan.Course;

            using (var ac = new AriaContext())
            {
                // Use ESAPI IDs to get to the ARIA Radiation row
                var dbPatient = ac.Patients.First(p => p.PatientId == patient.Id);
                var dbCourse  = dbPatient.Courses.First(c => c.CourseId == course.Id);
                var dbPlan    = dbCourse.PlanSetups.First(ps => ps.PlanSetupId == plan.Id);
                var dbRad     = dbPlan.Radiations.First(r => r.RadiationId == beam.Id);

                // Use the RadiationSer to get to the MLC add-on
                var dbFieldAddOns = ac.FieldAddOns.Where(f => f.RadiationSer == dbRad.RadiationSer);
                var dbMlcAddOn    = dbFieldAddOns.First(f => f.AddOn.AddOnType == "MLC");

                // Use the MLC row to get to the leaves (and their width)
                // Note: We only need to use one of the MLC banks because
                // the leaf widths are the same between leaf pairs
                var dbMlc       = dbMlcAddOn.AddOn.MLC;
                var dbMlcLeaves = dbMlc.MLCBanks.First().MLCLeaves;
                return(dbMlcLeaves.Select(lf => lf.Width));
            }
        }
 public double[] GetLeafWidths(Patient patient, PlanSetup plan, Beam beam)
 {
     try
     {
         return(GetLeafWidthsFromAria(patient, plan, beam).ToArray());
     }
     catch (Exception e)
     {
         throw new LeafWidthsNotFoundException
                   ("Unable to obtain leaf widths for beam " + beam.Id, e);
     }
 }
Esempio n. 3
0
        static void DrawDVH(DVHPlot.ViewModel.MainWindowModel viewModel, VMS.TPS.Common.Model.API.PlanSetup curps)
        {
            StructureSet structureSet = curps.StructureSet;

            foreach (var structure in structureSet.Structures)
            {
                DVHData dvhData = curps.GetDVHCumulativeData(structure,
                                                             DoseValuePresentation.Absolute,
                                                             VolumePresentation.Relative, 1);
                OxyPlot.OxyColor   color  = new OxyPlot.OxyColor();
                OxyPlot.MarkerType marker = new OxyPlot.MarkerType();
                viewModel.AddData(dvhData, structure.Id, color, marker);
            }
        }
Esempio n. 4
0
        public ESAPIPlanSetupViewModel(v.PlanSetup plansetup)
        {
            if (plansetup == null)
            {
                throw new ArgumentNullException("plansetup");
            }

            _apidataobject = plansetup;

            Properties.Add(new Property("Course Id", plansetup.Course.Id));
            Properties.Add(new Property("Id", plansetup.Id));
            Properties.Add(new Property("Approval Status", plansetup.ApprovalStatus));
            Properties.Add(new Property("Dose valid", plansetup.IsDoseValid));
        }
        public IEnumerable <Aperture> Create(Patient patient, PlanSetup plan, Beam beam)
        {
            List <Aperture> apertures = new List <Aperture>();

            double[] leafWidths = GetLeafWidths(patient, plan, beam);

            foreach (ControlPoint controlPoint in beam.ControlPoints)
            {
                double[,] leafPositions = GetLeafPositions(controlPoint);
                double[] jaw = CreateJaw(controlPoint);
                apertures.Add(new Aperture(leafPositions, leafWidths, jaw));
            }

            return(apertures);
        }
Esempio n. 6
0
        /* Constructor for FieldTest class to initialize the current plan object
         *
         * Updated: JB 6/13/18
         */
        public FieldTest(PlanSetup cPlan)
        {
            currentPlan = cPlan;

            setupFieldAngleTest = new TestCase("Setup Field Angle Test", "Test performed to enture 4 cardinal angle setup fields are provided.", TestCase.PASS);
            this.fieldTests.Add(setupFieldAngleTest);

            setupFieldNameTest = new TestCase("Setup Field Name Check", @"Test performed to ensure setup fields are 
                                                                                 named according to convention and tests angle values.", TestCase.PASS);
            this.fieldTests.Add(setupFieldNameTest);

            treatmentFieldNameTest = new TestCase("Treatment Field Name and Angle Check", "(3D plan) Test performed to verify treatment field names and corresponding gantry angles.", TestCase.PASS);
            this.fieldTests.Add(treatmentFieldNameTest);

            DRRAllFieldsTest = new TestCase("DRR Check", "Test performed to ensure that high resolution DRRs are present for all fields.", TestCase.PASS);
            this.fieldTests.Add(DRRAllFieldsTest);

            arcFieldNameTest = new TestCase("Arc Field Name Check", "(VMAT) Test performed to ensure ARC field names is consistent with direction (CW vs. CCW).", TestCase.PASS);
            this.fieldTests.Add(arcFieldNameTest);

            SetupFieldBolusTest = new TestCase("Setup Field Bolus Check", "Test performed to ensure setup fields are not linked with bolus, otherwise underliverable.", TestCase.PASS);
            this.fieldTests.Add(SetupFieldBolusTest);
        }
Esempio n. 7
0
        private static PlotModel CreatePlot(VM.PlanSetup plan)
        {
            var model = new PlotModel();

            //Add Dose Axis
            model.Axes.Add(new LinearAxis()
            {
                Title                  = "Dose [cGy]",
                Position               = AxisPosition.Bottom,
                MajorGridlineStyle     = LineStyle.Solid,
                MinorGridlineStyle     = LineStyle.Dot,
                MinorGridlineThickness = 1,
                MinorGridlineColor     = OxyColor.FromRgb(15, 15, 15),
            });
            //Add Volume Axis
            model.Axes.Add(new LinearAxis()
            {
                Title              = "Volume [%]",
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                MinorGridlineColor = OxyColor.FromRgb(15, 15, 15)
            });

            foreach (var str in plan.StructureSet.Structures)
            {
                var ser = new LineSeries();
                ser.Color = OxyColor.FromRgb(str.Color.R, str.Color.G, str.Color.B);
                foreach (var pt in plan.GetDVHCumulativeData(str, D.Absolute, V.Relative, 0.1).CurveData)
                {
                    ser.Points.Add(new DataPoint(pt.DoseValue.GetDoseCGy(), pt.Volume));
                }
                model.Series.Add(ser);
            }

            return(model);
        }
        private TPReportData GetReportData(string patientstring)
        {
            CurCursor = Cursors.Wait;

            TPReportData returnvalue = new TPReportData();

            VMS.TPS.Common.Model.API.Patient   curpat = null;
            VMS.TPS.Common.Model.API.PlanSetup curps  = null;

            if (patientstring.Split(',').Count() == 3)
            {
                string patient_id   = patientstring.Split(',')[0];
                string course_id    = patientstring.Split(',')[1];
                string plansetup_id = patientstring.Split(',')[2];
                curpat = cur_app.OpenPatientById(patient_id);
                if (curpat != null)
                {
                    curps = curpat.Courses.Where(x => x.Id == course_id).Single().PlanSetups.Where(x => x.Id == plansetup_id).Single();
                }
                if (curps != null)
                {
                    returnvalue.CurPatientInfo.FirstName = curpat.FirstName;
                    returnvalue.CurPatientInfo.LastName  = curpat.LastName;
                    returnvalue.CurPatientInfo.PatientID = curpat.Id;


                    returnvalue.CurPlanInfo.CourseID = curps.Course.Id;
                    returnvalue.CurPlanInfo.PlaneID  = curps.Id;


                    returnvalue.CurDosePrescription.NumberOfFraction           = curps.UniqueFractionation.NumberOfFractions.Value.ToString();
                    returnvalue.CurDosePrescription.PrescribedDoseFractination = Math.Round(curps.UniqueFractionation.PrescribedDosePerFraction.Dose, 1).ToString();
                    returnvalue.CurDosePrescription.PlanNormalization          = Math.Round(curps.PlanNormalizationValue, 1).ToString();
                    returnvalue.CurDosePrescription.TotalPrescribedDose        = Math.Round(curps.TotalPrescribedDose.Dose, 1).ToString();


                    FieldInfo curfi = new FieldInfo();
                    foreach (Beam b in curps.Beams)
                    {
                        curfi            = new FieldInfo();
                        curfi.BeamID     = b.Id;
                        curfi.Collimator = Math.Round(b.ControlPoints[0].CollimatorAngle, 1).ToString();
                        curfi.Gantry     = Math.Round(b.ControlPoints[0].GantryAngle, 1).ToString();
                        curfi.Couch      = Math.Round(b.ControlPoints[0].PatientSupportAngle, 1).ToString();
                        curfi.Energy     = b.EnergyModeDisplayName;
                        curfi.Machine    = b.TreatmentUnit.Id;
                        curfi.MU         = Math.Round(b.Meterset.Value, 1).ToString();
                        curfi.X1         = Math.Round(b.ControlPoints[0].JawPositions.X1 / 10.0f, 1).ToString();
                        curfi.X2         = Math.Round(b.ControlPoints[0].JawPositions.X2 / 10.0f, 1).ToString();
                        curfi.Y1         = Math.Round(b.ControlPoints[0].JawPositions.Y1 / 10.0f, 1).ToString();
                        curfi.Y2         = Math.Round(b.ControlPoints[0].JawPositions.Y2 / 10.0f, 1).ToString();
                        returnvalue.CurFieldInfoList.Add(curfi);
                    }

                    StructureData cursd = new StructureData();
                    DVHData       dvhd  = null;
                    foreach (Structure s in curps.StructureSet.Structures)
                    {
                        if (colors.ContainsKey(s.Id.ToLower()) || colors.ContainsKey(s.DicomType.ToLower()))
                        {
                            if (!s.IsEmpty && s.Volume > 0.0f)
                            {
                                cursd             = new StructureData();
                                cursd.StructureID = s.Id;
                                cursd.Type        = s.DicomType;
                                cursd.Volume      = Math.Round(s.Volume, 1).ToString();
                                dvhd = curps.GetDVHCumulativeData(s, DoseValuePresentation.Absolute, VolumePresentation.Relative, 1.0f);
                                if (dvhd != null)
                                {
                                    cursd.MaxDose = Math.Round(dvhd.MaxDose.Dose, 1).ToString();
                                    cursd.MinDose = Math.Round(dvhd.MinDose.Dose, 1).ToString();
                                }
                                returnvalue.CurStructureDataList.Add(cursd);
                            }
                        }
                    }
                }
            }
            cur_app.ClosePatient();
            CurCursor = Cursors.Arrow;
            return(returnvalue);
        }
Esempio n. 9
0
 // Fix UnauthorizedScriptingAPIAccessException
 public void DoNothing(VMS.TPS.Common.Model.API.PlanSetup plan)
 {
 }