0
votes

I am new to CC as well as DICOM world, am trying out to read the patient name and study details in the DICOMDIR file and save it in database, here is my code, am doing it in console application in C#

enter code here
{

        DicomDirectory reader = new DicomDirectory("DICOMDIR");
        reader.Load(@"D:\Sunil\Dataset\Metapex\pix\DICOMDIR");
        DirectoryRecordSequenceItem record = reader.RootDirectoryRecord;
        while (record != null)
        {
            String PatientId = record[DicomTags.PatientId];
            String PatientName = record[DicomTags.PatientsName];
            Console.WriteLine("Id - {0}\n Name - {1}", PatientId, PatientName);
            record = record.NextDirectoryRecord;
        }
        Console.ReadLine();}

when i execute it there is no error, but DirectoryRecordSequenceItem "record" value is returning null in line 3, hence it is not entering the loop.

can anyone help why it is returning null value, am not able to find out even i put breakpoint n debug it.

thanks in advance

SUNIL

1

1 Answers

0
votes

This is the correct way to access the patient level directory records within a DICOMDIR. The code should work. Are you sure DICOMDIR itself is encoded properly?

You should be able to call reader.Dump() and investigate the directory record sequence to see if there are proper directory records there and they've been parsed. It would be difficult to confirm that the the actual points in the directory record are correct, but you should at least be able to see if there are records present.