コード例 #1
0
        public double VolumeAverageDose()
        {
            double sum = 0.0;

            for (int i = 0; i <= LengthSize; i++)
            {
                //factor for trapezoidal rule
                double lengthFactor = 1.0;
                if (i == 0 || i == LengthSize)
                {
                    lengthFactor = 0.5;
                }
                double l = i * LengthDelta - Length * 0.5;
                for (int j = 0; j <= RadiusSize; j++)
                {
                    //factor for trapezoidal rule
                    double radiusFactor = 1.0;
                    if (j == 0 || j == RadiusSize)
                    {
                        radiusFactor = 0.5;
                    }
                    double r = j * RadiusDelta;
                    for (int k = 0; k <= ThetaSize; k++)
                    {
                        //factor for trapezoidal rule
                        double thetaFactor = 1.0;
                        if (k == 0 || k == ThetaSize)
                        {
                            thetaFactor = 0.5;
                        }
                        double theta = k * ThetaDelta;

                        double x = XCenter + r * Math.Cos(theta) + XShift;
                        double y = YCenter + r * Math.Sin(theta) + YShift;
                        double z = ZCenter + l + ZShift;

                        double dose = DoseVoxel.GetVoxelValue(x, y, z);

                        sum += lengthFactor * radiusFactor * thetaFactor * dose * r;
                    }
                }
            }
            sum *= RadiusDelta * ThetaDelta * LengthDelta;
            double volume = Math.PI * Radius * Radius * Length;

            //double volume = Math.PI * Radius * Radius * (Length * Length * Length/3.0/4.0);
            //double volume = 0.5 * Radius * Radius * (2 * Math.PI * 2 * Math.PI * 2 * Math.PI / 3) * Length;

            AverageDoseValue = sum / volume;

            return(AverageDoseValue);
        }
コード例 #2
0
        static void Execute(VMS.TPS.Common.Model.API.Application app)
        {
            var folderPath = @"\\10.208.223.10\Eclipse";

            folderPath = Path.Combine(folderPath, "ResearchProjects", "AverageDose");

            // For Non-clinical Eclipse
            var computerName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
            var homePath     = System.Environment.GetEnvironmentVariable("HOMEPATH");
            var homeDrive    = System.Environment.GetEnvironmentVariable("HOMEDRIVE");

            if (computerName == "ECQ275" || computerName == "ECM516NC" || computerName == "XPS13")
            {
                folderPath = homeDrive + Path.Combine(homePath, @"Desktop\AverageDose");
            }

            var patientId = "Physics";
            var courseId  = "DLG_TEST_06X";
            var planId    = "06X";

            var currentPatient   = app.OpenPatientById(patientId);
            var currentCourse    = EsapiHelpers.GetCourse(currentPatient, courseId);
            var currentPlanSetup = EsapiHelpers.GetPlanSetup(currentCourse, planId);

            var mainWindowViewModel = new MainWindowViewModel();

            mainWindowViewModel.FolderPath = folderPath;
            mainWindowViewModel.FileName   = "AverageDose.csv";

            if (currentPlanSetup.Beams.Count() > 0)
            {
                var query = currentPlanSetup.Beams.First().FieldReferencePoints.Where(p => !double.IsNaN(p.RefPointLocation.x));
                foreach (var p in query)
                {
                    var xDcs = p.RefPointLocation.x;
                    var yDcs = p.RefPointLocation.y;
                    var zDcs = p.RefPointLocation.z;

                    var pUcs = EsapiHelpers.DicomToUserCoordinates(xDcs, yDcs, zDcs, currentPlanSetup);

                    var x = pUcs[0];
                    var y = pUcs[1];
                    var z = pUcs[2];


                    mainWindowViewModel.FieldReferencePoints.Add(new AverageDoseInSensitiveVolume.Models.FieldReferencePoint(x, y, z, xDcs, yDcs, zDcs, p.ReferencePoint.Id));
                }
            }

            if (mainWindowViewModel.FieldReferencePoints.Count > 0)
            {
                mainWindowViewModel.SelectedFieldReferencePoint = mainWindowViewModel.FieldReferencePoints.First();
            }
            else
            {
                throw new InvalidOperationException("No reference point");
            }

            var doseVoxel = new DoseVoxel(currentPlanSetup);

            var voxel = doseVoxel.Voxel;

            // Add PinPoint 3D
            mainWindowViewModel.Cylinders.Add(new Cylinder("PinPoint 3D", 1.45, 2.9, voxel, 20, 20, 40));
            mainWindowViewModel.Cylinders.Add(new Cylinder("Semiflex 3D", 2.4, 4.8, voxel, 20, 20, 40));
            mainWindowViewModel.Cylinders.Add(new Cylinder("Semiflex", 2.75, 6.5, voxel, 20, 20, 40));
            mainWindowViewModel.Cylinders.Add(new Cylinder("Farmer", 3.05, 23, voxel, 20, 20, 40));

            var mainWindow = new MainWindow(mainWindowViewModel);

            mainWindow.ShowDialog();
        }