Example #1
0
        /// <summary>
        ///     This method exists to guess the prescription of a plan sum by summing all plan setup prescribed doses and
        ///     generating a
        ///     relative dvh curve. Can't technically do relative dose with plan sum...but let's try to do it anyway
        /// </summary>
        /// <param name="ps">the plan sum where relative dose dvh curve is desired</param>
        /// <param name="s">the structure to sample</param>
        /// <param name="vPres">the volume presentation to create the curve</param>
        /// <param name="binWidth">the bin width to create the curve</param>
        /// <returns></returns>
        public static DVHPoint[] GetRelativeDVHCumulativeData(this PlanSum ps, Structure s, VolumePresentation vPres,
                                                              double binWidth)
        {
            var guessedRxGy  = ps.TotalPrescribedDoseGy();
            var psDVH        = ps.GetDVHCumulativeData(s, DoseValuePresentation.Absolute, vPres, binWidth);
            var scalingPoint = new DoseValue(guessedRxGy, DoseValue.DoseUnit.Gy);
            var dvhCurve     = psDVH.CurveData.ConvertToRelativeDose(scalingPoint);

            return(dvhCurve);
        }
Example #2
0
        public string NTCPreturn(string strnum, string gradename, StructureSet list, PlanSum plan, double n, double m, double td50)
        {
            Structure retstructure = null;
            int       bit          = 0;
            double    EUD          = 0;
            double    Ntcp         = 0;
            string    NTCPstring   = "";

            foreach (Structure scan in list.Structures)
            {
                if (scan.Id == strnum)
                {
                    retstructure = scan;
                    bit          = 1;
                    if (retstructure.IsEmpty == true)
                    {
                        bit = 2; break;
                    }
                    DVHData dvh     = plan.GetDVHCumulativeData(retstructure, DoseValuePresentation.Absolute, VolumePresentation.Relative, 1);
                    var     dvhdata = dvh.CurveData.ToList();
                    string  volume  = dvh.Volume.ToString();
                    string  dvhstr  = volume;
                    double  fEUD    = 0;
                    string  dvhnums = dvhdata.Count.ToString();
                    for (int i = 0; i < dvhdata.Count - 1; i++)
                    {
                        fEUD += (dvhdata[i].Volume - dvhdata[i + 1].Volume) / 100 * Math.Pow(dvhdata[i].DoseValue.Dose / 100, 1 / n);
                    }
                    EUD = Math.Pow(fEUD, n);
                    double t = treturn(EUD, m, td50);
                    Ntcp        = NTCP(t);
                    NTCPstring += string.Format("NTCP of {0}, {1} is {2}%\n", strnum, gradename, (Ntcp * 100).ToString("F2"));
                }
            }
            if (bit == 0)
            {
                NTCPstring += "";
                return(NTCPstring);
            }
            else if (bit == 2)
            {
                NTCPstring += ""; return(NTCPstring);
            }
            else
            {
                return(NTCPstring);
            }
        }
Example #3
0
        public Task <double> GetMeanDose(string StructureId, VolumePresentation VP, DoseValuePresentation DVP, double binwidth)
        {
            switch (PlanType)
            {
            case ComponentTypes.Plan:
                return(A.ExecuteAsync(new Func <PlanSetup, double>((p) =>
                {
                    DVHData dvh = p.GetDVHCumulativeData(_Structures[StructureId], DVP, VP, binwidth);
                    if (!ReferenceEquals(null, dvh))
                    {
                        return dvh.MeanDose.Dose;
                    }
                    else
                    {
                        return -1;
                    }
                }), p));

            case ComponentTypes.Sum:
                return(A.ExecuteAsync(new Func <PlanSum, double>((ps) =>
                {
                    DVHData dvh = ps.GetDVHCumulativeData(_Structures[StructureId], DVP, VP, binwidth);
                    if (!ReferenceEquals(null, dvh))
                    {
                        return dvh.MeanDose.Dose;
                    }
                    else
                    {
                        return -1;
                    }
                }), ps));

            default:
                return(null);
            }
        }
Example #4
0
        public string Absmean(string strnum, double criteria, int updown, StructureSet list, PlanSum plan)//updown(1up,0down)
        {
            Structure retstructure = null;
            int       bit          = 0;
            double    binwidth     = 0.1;
            string    doostr       = "";
            string    judge        = "";

            foreach (Structure scan in list.Structures)
            {
                if (scan.Id == strnum)
                {
                    retstructure = scan;
                    if (retstructure.IsEmpty)
                    {
                        bit = 2; break;
                    }
                    bit = 1;
                    DVHData   dvhData = plan.GetDVHCumulativeData(retstructure, DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, binwidth);
                    DoseValue bbb     = dvhData.MeanDose;
                    double    Doo     = bbb.Dose;
                    doostr = (Doo / 100).ToString("F2");
                    if (updown == 1)//upper dose
                    {
                        if (Doo <= criteria)
                        {
                            judge = "o";
                        }
                        else
                        {
                            judge = "x";
                        }
                    }
                    else
                    {
                        if (Doo > criteria)
                        {
                            judge = "o";
                        }
                        else
                        {
                            judge = "x";
                        }
                    }
                    break;
                }
            }
            string doseindexreturn = "";
            string judgement       = "";
            string retstring       = "";

            if (bit == 1)
            {
                retstring       = retstructure.Id;
                doseindexreturn = doostr;
                judgement       = judge;
                string ud = "0";
                if (updown == 1)
                {
                    ud = "<";
                }
                else
                {
                    ud = ">";
                }
                retstring = string.Format("{0}\t\tDmean{4}{1}Gy\t{2}Gy\t{3}\n", retstructure.Id, (criteria / 100).ToString("F0"), doseindexreturn, judgement, ud);
            }
            else if (bit == 2)
            {
                retstring = strnum + "\tis Empty structure" + "\n";
            }
            else
            {
                retstring = "No Structure named " + strnum + "\n";
            }
            return(retstring);
        }