Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, February 8, 2018 10:45:19 AM(UTC)
Nick Villalobos

Groups: Registered
Posts: 119

Was thanked: 4 time(s) in 4 post(s)

Below you will find a code snippet for grabbing DICOM files from a folder then turning those into a DicomDir. The DICOMDIR file contains Dicom Directory information, which makes it easier to access the information contained in the other DICOM files in the file-set. The DICOM files in the file-set are assigned File IDs, so that they can be referenced by the DICOMDIR File, which itself, is identified by a File ID of DICOMDIR.

Code:

static void CreateDicomDir(string directory)
      {
         DicomEngine.Startup();
         DicomDir m_DicomDir = new DicomDir();
         m_DicomDir.Reset(directory);
         DicomDirOptions options;
         options = m_DicomDir.Options;
         options.IncludeSubfolders = true;
         m_DicomDir.Options = options;

         foreach (var file in Directory.GetFiles(directory))
         {
            //if there is already a DICOMDIR file in the folder, skip it
            if (Path.GetFileName(file) == "DICOMDIR")
               continue;

            //do a try-catch around a DICOM Dataset load to ensure we're only using DICOM files
            try
            {
               using (DicomDataSet ds = new DicomDataSet())
                  ds.Load(file, DicomDataSetLoadFlags.None);

               m_DicomDir.InsertFile(file);
            }
            catch { }
         }
         m_DicomDir.Save();
         DicomEngine.Shutdown();
      }

Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.127 seconds.