Ejemplo n.º 1
0
 // build slice list for a given patient
 private void ProcessAllCTs(string aPatientName, IODRepository mIODRepository)
 {
     foreach (string SOPClass in mIODRepository.GetSOPClassNames(aPatientName))
     {
         foreach (string Study in mIODRepository.GetStudies(aPatientName, SOPClass))
         {
             foreach (string Series in mIODRepository.GetSeries(aPatientName, SOPClass, Study))
             {
                 foreach (IOD IOD in mIODRepository.GetIODs(aPatientName, SOPClass, Study, Series))
                 {
                     if (IOD.IsPixelDataProcessable())
                     {
                         CTSliceInfo aCTSliceInfo = new Helper.CTSliceInfo(IOD.XDocument, IOD.FileName);
                         _scol.Add(aCTSliceInfo);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void MenuItem_LoadClick(object sender, RoutedEventArgs e)
        {
            /// var dialog = new System.Windows.Forms.FolderBrowserDialog();

            /// System.Windows.Forms.DialogResult result = dialog.ShowDialog();
            if (true /*result == System.Windows.Forms.DialogResult.OK*/)
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                IODRepository mIODRepository = new IODRepository();
                this._IODTree.Items.Clear();

                string   selectedFilePath = "C:\\Users\\Oleg\\Desktop\\DM1";// dialog.SelectedPath;
                string[] fileNameList     = Directory.GetFiles(selectedFilePath, "*.dcm", SearchOption.AllDirectories);

                // For each physical DICOM file, an own IOD object is created.
                // After parsing the DICOM file, the newly created IOD is added to the IOD Repository.
                foreach (string fileName in fileNameList)
                {
                    mIODRepository.Add(new IOD(fileName));
                }

                // All DICOM files are now parsed.
                // The IOD Repository is queried in order to build up the IOD model.
                // The grouping of the IOD's is as follows: Patient-SOPClass-Study-Series.
                foreach (string patientName in mIODRepository.GetPatients())
                {
                    TreeViewItem patientItem = new TreeViewItem()
                    {
                        Header = patientName
                    };
                    this._IODTree.Items.Add(patientItem);

                    foreach (string aSOPClass in mIODRepository.GetSOPClassNames(patientName))
                    {
                        TreeViewItem SOPClassItem = new TreeViewItem()
                        {
                            Header = aSOPClass
                        };
                        patientItem.Items.Add(SOPClassItem);

                        foreach (string aStudy in mIODRepository.GetStudies(patientName, aSOPClass))
                        {
                            TreeViewItem studyItem = new TreeViewItem()
                            {
                                Header = string.Format(@"Study: '{0}'", aStudy)
                            };
                            SOPClassItem.Items.Add(studyItem);

                            foreach (string aSeries in mIODRepository.GetSeries(patientName, aSOPClass, aStudy))
                            {
                                TreeViewItem SeriesItem = new TreeViewItem()
                                {
                                    Header = string.Format(@"Series: '{0}'", aSeries)
                                };
                                studyItem.Items.Add(SeriesItem);

                                foreach (IOD IOD in mIODRepository.GetIODs(patientName, aSOPClass, aStudy, aSeries))
                                {
                                    TreeViewItem anIOD = new TreeViewItem()
                                    {
                                        Header = string.Format(@"{0}", IOD.SOPInstanceUID)
                                    };
                                    anIOD.Tag = IOD;
                                    SeriesItem.Items.Add(anIOD);
                                }
                            }
                        }
                    }
                }

                _IODRepo = mIODRepository;

                Mouse.OverrideCursor = null;

                List <string> patients = mIODRepository.GetPatients();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Hand;

                ProcessAllCTs(patients.ElementAt(0), _IODRepo);

                Mouse.OverrideCursor = null;

                _scol.GenerateAllHounsfields();
            }
        }