1

I'm reading attributes from each dicom file in directory and it takes a lot of time. My code :

       var patient_id = k_di_.DataSet.GetAttribute(DicomTags.PatientId);

How can i do the same, but reading only in dicomdir?

Steve Wranovsky
  • 5,503
  • 4
  • 34
  • 52
user449921
  • 241
  • 1
  • 4
  • 14

1 Answers1

2

The ClearCanvas library has a DicomDirectory class for reading and writing DICOMDIRs. You can traverse a DICOMDIR and read the Patient ID something like this:


DicomDirectory reader = new DicomDirectory("DICOMDIR");
reader.Load("DICOMDIR Filename");
DirectoryRecordSequenceItem record = reader.RootDirectoryRecord;
while (record != null)
{
    var patientId = record[DicomTags.PatientId];
    record = record.NextDirectoryRecord;
}

Steve Wranovsky
  • 5,503
  • 4
  • 34
  • 52