Пример #1
0
        public void AddToleranceTableCheck(string ProtocolTolTable)
        {
            var Warning = false;

            if (Field.ToleranceTable.ToUpper() != ProtocolTolTable.ToUpper())
            {
                Warning = true;
            }
            var TolTable = new TestListItem(string.Format(@"Tolerance Table (""{0}"")", Field.Id), string.Format("{0:0} HU", Field.ToleranceTable), string.Format("{0:0} HU", ProtocolTolTable), Warning, "");

            BeamTests.Tests.Add(TolTable);
        }
Пример #2
0
        public async Task <bool> AddBolusCheck()
        {
            int numBoluses = 0;

            foreach (Ctr.TxFieldItem.BolusInfo BI in Field.BolusInfos)
            {
                var    Warning       = false;
                string WarningString = "";
                numBoluses++;
                if (Math.Abs(BI.HU - RefBeam.RefBolusHU) > 0.1)
                {
                    Warning       = true;
                    WarningString = @"HU deviation";
                }
                if (RefBeam.BolusParameter == ParameterOptions.None)
                {
                    Warning       = true;
                    WarningString = @"Off-protocol bolus";
                }
                var HU = new TestListItem(string.Format(@"Bolus HU (""{0}"")", BI.Id), string.Format("{0:0} HU", BI.HU), string.Format("{0:0} HU", RefBolusHU), Warning, WarningString);
                BeamTests.Tests.Add(HU);

                //ThickCheck
                if (RefBeam.BolusParameter != ParameterOptions.None)
                {
                    var Thick = await Ctr.GetBolusThickness(Field.CourseId, Field.PlanId, BI.Id);

                    if (Thick < (RefBeam.BolusClinicalMinThickness - 0.1) || Thick > (RefBeam.BolusClinicalMaxThickness + 0.1))
                    {
                        Warning = true;
                    }
                    var ThickCheck = new TestListItem(string.Format(@"Bolus Thickness (""{0}"")", BI.Id), string.Format("{0:0.0#} cm", Thick),
                                                      string.Format("{0:0.#} - {1:0.#} cm", RefBeam.BolusClinicalMinThickness, RefBeam.BolusClinicalMaxThickness), Warning, "");
                    BeamTests.Tests.Add(ThickCheck);
                }
            }
            if (numBoluses == 0 && RefBeam.BolusParameter == ParameterOptions.Required)
            {
                var HU = new TestListItem(string.Format(@"Bolus Check"), string.Format(" - "), string.Format("{0:0} HU", RefBolusHU), true, "Bolus indicated but not found");
                BeamTests.Tests.Add(HU);
            }
            return(true);
        }
Пример #3
0
        private async void RefreshTests()
        {
            BeamTests.Tests.Clear(); // remove default model test beams
            if (Field == null)
            {
                return;
            }
            // Add default checks:
            if (!double.IsNaN(MU))
            {
                string MURange = ""; // no string if no reference
                if (RefBeam.MinMUWarning > 0 && (RefBeam.MaxMUWarning > 0 && (RefBeam.MaxMUWarning > RefBeam.MinMUWarning)))
                {
                    MURange = string.Format("{0:0} - {1:0}", RefBeam.MinMUWarning, RefBeam.MaxMUWarning);
                }
                BeamTests.Tests.Add(new TestListItem(string.Format(@"MU range"), string.Format("{0:0.#} MU", MU), MURange));
            }
            else
            {
                BeamTests.Tests.Add(new TestListItem(string.Format(@"MU range"), @"N/A", string.Format("{0} - {1} MU", RefBeam.MinMUWarning, RefBeam.MaxMUWarning), true, "Not calculated"));
            }
            var EnergyWarning       = !RefBeam.ValidEnergies.Contains(Field.Energy) && !RefBeam.ValidEnergies.Contains(Energies.Unset);
            var ValidEnergiesString = new List <string>();

            foreach (var E in RefBeam.ValidEnergies)
            {
                ValidEnergiesString.Add(E.Display());
            }
            BeamTests.Tests.Add(new TestListItem(@"Valid energies", Field.Energy.Display(), string.Join(", ", ValidEnergiesString), EnergyWarning, ""));
            bool   GeometryWarning       = true;
            string GeometryName          = "";
            string GeometryWarningString = "No valid beam geometry found";
            double eps = 0.1;

            if (RefBeam.ValidGeometries.Count > 0)
            {
                foreach (Ctr.BeamGeometry G in RefBeam.ValidGeometries)
                {
                    double InvariantMaxStart;
                    double InvariantMinStart;
                    double InvariantMaxEnd;
                    double InvariantMinEnd;

                    if (G.GetInvariantAngle(G.MaxStartAngle) > G.GetInvariantAngle(G.MinStartAngle))
                    {
                        InvariantMaxStart = G.GetInvariantAngle(G.MaxStartAngle);
                        InvariantMinStart = G.GetInvariantAngle(G.MinStartAngle);
                    }
                    else
                    {
                        InvariantMaxStart = G.GetInvariantAngle(G.MinStartAngle);
                        InvariantMinStart = G.GetInvariantAngle(G.MaxStartAngle);
                    }
                    if (G.GetInvariantAngle(G.MaxEndAngle) > G.GetInvariantAngle(G.MinEndAngle))
                    {
                        InvariantMaxEnd = G.GetInvariantAngle(G.MaxEndAngle);
                        InvariantMinEnd = G.GetInvariantAngle(G.MinEndAngle);
                    }
                    else
                    {
                        InvariantMaxEnd = G.GetInvariantAngle(G.MinEndAngle);
                        InvariantMinEnd = G.GetInvariantAngle(G.MaxEndAngle);
                    }

                    var FieldStart = G.GetInvariantAngle(Field.GantryStart);
                    var FieldEnd   = G.GetInvariantAngle(Field.GantryEnd);

                    if (FieldStart <= InvariantMaxStart + eps &&
                        FieldStart >= InvariantMinStart - eps &&
                        FieldEnd <= InvariantMaxEnd + eps &&
                        FieldEnd >= InvariantMinEnd - eps)
                    {
                        GeometryWarning       = false;
                        GeometryName          = G.GeometryName;
                        GeometryWarningString = "";
                    }
                }
            }
            var GeometryTest = new TestListItem(string.Format(@"Beam geometry"), string.Format("{0:0.#} - {1:0.#} degrees", StartAngle, EndAngle), GeometryName,
                                                GeometryWarning, GeometryWarningString);

            BeamTests.Tests.Add(GeometryTest);
            if (!double.IsNaN(CouchRotation_ref))
            {
                bool CouchRotationWarning = (Math.Abs(CouchRotation_ref - CouchRotation) > 1E-5);
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Couch rotation"), string.Format("{0:0.#} degrees", CouchRotation), string.Format("{0:0.#} degrees", RefBeam.CouchRotation),
                                                     CouchRotationWarning, ""));
            }
            if (RefBeam.VMAT_JawTracking == ParameterOptions.Required)
            {
                var    JawTrackingWarning = false;
                string Message;
                if (!Field.isJawTracking)
                {
                    JawTrackingWarning = true;
                    Message            = @"No tracking detected";
                }
                else
                {
                    Message = @"Tracking detected";
                }
                BeamTests.Tests.Add(new TestListItem(@"Jaw tracking", Message, RefBeam.VMAT_JawTracking.Display(), JawTrackingWarning, ""));
            }
            if (!double.IsNaN(MinColRotation))
            {
                bool   MinColRotationWarning;
                double Offset = ColRotation;
                if (ColRotation < 90)
                {
                    MinColRotationWarning = ColRotation < RefBeam.MinColRotation;
                }
                else if (ColRotation < 180)
                {
                    Offset = (180 - ColRotation);
                }
                else if (ColRotation < 270)
                {
                    Offset = (ColRotation - 180);
                }
                else
                {
                    Offset = 360 - ColRotation;
                }
                MinColRotationWarning = Offset < RefBeam.MinColRotation;
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Minimum MLC offset from axial plane"), string.Format("{0:0.#} degrees", Offset), string.Format("{0:0.#} degrees", RefBeam.MinColRotation),
                                                     MinColRotationWarning, ""));
            }
            if (!double.IsNaN(MinX_ref))
            {
                bool MinXWarning = MinX_ref > Xmin;
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Minimum X field size"), string.Format("{0:0.#} cm", Xmin), string.Format("{0:0.#} cm", RefBeam.MinX),
                                                     MinXWarning, ""));
            }
            if (!double.IsNaN(MinY_ref))
            {
                bool MinYWarning = MinY_ref > Ymin;
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Minimum Y field size"), string.Format("{0:0.#} cm", Ymin), string.Format("{0:0.#} cm", RefBeam.MinY),
                                                     MinYWarning, ""));
            }
            if (!double.IsNaN(MaxX_ref))
            {
                bool MaxXWarning = MaxX_ref < Xmax;
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Maximum X field size"), string.Format("{0:0.#} cm", Xmax), string.Format("{0:0.#} cm", RefBeam.MaxX),
                                                     MaxXWarning, ""));
            }
            if (!double.IsNaN(MaxY_ref))
            {
                bool MaxYWarning = MaxY_ref < Ymax;
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Maximum Y field size"), string.Format("{0:0.#} cm", Ymax), string.Format("{0:0.#} cm", RefBeam.MaxY),
                                                     MaxYWarning, ""));
            }
            if (ToleranceTable_ref != "")
            {
                bool TolTableWarning = ToleranceTable_ref.ToUpper() != ToleranceTable.ToUpper();
                BeamTests.Tests.Add(new TestListItem(string.Format(@"Tolerance table"), ToleranceTable, ToleranceTable_ref, TolTableWarning, ""));
            }
            var CompletedBolusCheck = await AddBolusCheck();
        }