Esempio n. 1
0
        public async void BeginOpenDicomDoseAsync()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = false;
            openFileDialog.Title       = "Open Dicom Dose";
            if (openFileDialog.ShowDialog() == true)
            {
                var             progressItem = ProgressService.CreateNew("Loading Dose File...", false);
                var             progress     = new Progress <double>(x => { progressItem.ProgressAmount = (int)x; });
                DicomDoseObject openedObject = null;
                await Task.Run(async() =>
                {
                    try
                    {
                        openedObject = await DicomLoader.LoadDicomDoseAsync(openFileDialog.FileName, progress);
                    }
                    catch (Exception e)
                    {
                        Messenger.Default.Send(new NotificationMessage("Could not open file: " + e.Message));
                    }
                });

                if (openedObject != null)
                {
                    Messenger.Default.Send(new RTDicomViewer.Message.RTObjectAddedMessage <DicomDoseObject>(openedObject));
                }

                ProgressService.End(progressItem);
            }
        }
Esempio n. 2
0
        public static DicomDoseObject LoadDicomDoseSync(DicomFile dicomFile)
        {
            var loader = new DicomDoseLoader();
            var dose   = new DicomDoseObject();

            loader.Load(dicomFile, dose, null);
            return(dose);
        }
Esempio n. 3
0
        public void Load(DicomFile[] files, DicomDoseObject dicomObject, IProgress <double> progress)
        {
            //Load standard DICOM stuff.
            base.Load(files, dicomObject, progress);

            DicomFile file0 = files[0];

            Load(file0, dicomObject, progress);
        }
Esempio n. 4
0
        public void Load(DicomFile[] files, DicomDoseObject dicomObject)
        {
            DicomFile file0 = files[0];

            dicomObject.DoseGridScaling = file0.Dataset.Get <double>(DicomTag.DoseGridScaling, 1.0d);
            dicomObject.Units           = file0.Dataset.Get <string>(DicomTag.DoseUnits, "None");
            var gridLoader = new GridBasedStructureDicomLoader();

            dicomObject.Grid = gridLoader.Load(files);
        }
Esempio n. 5
0
        public static async Task <DicomDoseObject> LoadDicomDoseAsync(string[] fileNames, IProgress <double> progress)
        {
            var files = await getFilesAsync(fileNames);

            var loader = new DicomDoseLoader();
            var dose   = new DicomDoseObject();

            loader.Load(files, dose, progress);
            return(dose);
        }
Esempio n. 6
0
        public void Load(DicomFile[] files, DicomDoseObject dicomObject, IProgress <double> progress)
        {
            //Load standard DICOM stuff.
            base.Load(files, dicomObject, progress);

            DicomFile file0      = files[0];
            var       gridLoader = new GridBasedStructureDicomLoader();

            dicomObject.Grid           = gridLoader.Load(files, progress);
            dicomObject.Grid.Scaling   = file0.Dataset.Get <float>(DicomTag.DoseGridScaling, 1.0f);
            dicomObject.Grid.ValueUnit = unitFromString(file0.Dataset.Get <string>(DicomTag.DoseUnits, "Relative"));
            dicomObject.Grid.Name      = Path.GetFileNameWithoutExtension(file0.File.Name);
        }
Esempio n. 7
0
        public async void SubtractDoses()
        {
            if (SelectedMathDose1 == null || SelectedMathDose2 == null)
            {
                return;
            }
            DicomDoseObject newDoseObject = new DicomDoseObject();
            var             math          = new GridMath();

            IsComputing = true;
            var               progressItem = ProgressSerice.CreateNew("Performing Gamma Calculation...", false);
            var               progress     = new Progress <int>(x => { progressItem.ProgressAmount = x; });
            VectorField       vf           = null;
            GammaDistribution gamma        = null;
            await Task.Run(() =>
            {
                gamma = math.Gamma(SelectedMathDose1.Grid, SelectedMathDose2.Grid, progress, (float)DtaTol, (float)DoseDiffTol, 10);
                vf    = gamma.Vectors;
                newDoseObject.Grid = gamma.Gamma;
            });

            ProgressSerice.End(progressItem);

            /*var dd = new DicomDoseObject();
             *
             * dd.Grid = gamma.Jacobian;
             * dd.Grid.Name = "Jacobian";
             * MessengerInstance.Send<RTObjectAddedMessage<DicomDoseObject>>(new RTObjectAddedMessage<DicomDoseObject>(dd));*/

            Workspace.Workspace.Current.Axial.VectorFields.Add(vf);
            Workspace.Workspace.Current.Sagittal.VectorFields.Add(vf);
            Workspace.Workspace.Current.Coronal.VectorFields.Add(vf);

            newDoseObject.Grid.ValueUnit = Unit.Gamma;
            newDoseObject.Grid.Name      = "Gamma Result";
            IsComputing = false;
            MessengerInstance.Send <RTObjectAddedMessage <DicomDoseObject> >(new RTObjectAddedMessage <DicomDoseObject>(newDoseObject));
        }
Esempio n. 8
0
        public void Load(DicomFile file, DicomDoseObject dicomObject, IProgress <double> progress)
        {
            var gridLoader = new GridBasedStructureDicomLoader();

            dicomObject.SerriesNumber      = file.Dataset.GetSingleValueOrDefault <string>(DicomTag.SeriesNumber, "");
            dicomObject.SerriesDescription = file.Dataset.GetSingleValueOrDefault <string>(DicomTag.SeriesDescription, "");
            dicomObject.ClassUID           = file.Dataset.GetSingleValueOrDefault <string>(DicomTag.SOPClassUID, "");
            dicomObject.InstanceUID        = file.Dataset.GetSingleValueOrDefault <string>(DicomTag.SOPInstanceUID, "");
            String tempstring = file.Dataset.GetSingleValueOrDefault <string>(DicomTag.ReferencedRTPlanSequence, "");

            DicomReferencedSOP tt = file.Dataset.GetReferencedSOP(DicomTag.ReferencedRTPlanSequence);

            if (tt != null)
            {
                dicomObject.ReferencedClassUID    = tt.Class.UID;
                dicomObject.ReferencedInstanceUID = tt.Instance.UID;
            }

            dicomObject.Grid           = gridLoader.Load(file);
            dicomObject.Grid.Scaling   = file.Dataset.GetSingleValueOrDefault <float>(DicomTag.DoseGridScaling, 1.0f);
            dicomObject.Grid.ValueUnit = unitFromString(file.Dataset.GetSingleValueOrDefault <string>(DicomTag.DoseUnits, "Relative"));
            dicomObject.Grid.Name      = Path.GetFileNameWithoutExtension(file.File.Name);
        }