#1
Posted
:
Thursday, February 8, 2018 10:45:19 AM(UTC)
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.
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.