views:

35

answers:

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?

A: 

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
Thanks! Your help is incalculable. I made almost everything with dicomdir what i wanted.