0

I am using GDCM library to create a DICOMDIR file. I implemented the code as shown in GDCM docs:

http://gdcm.sourceforge.net/html/GenerateDICOMDIR_8cs-example.html

In the code:

    private int GenerateDicomDir(string directory, string outFileName)
    {
        gdcm.Directory d = new gdcm.Directory();
        uint nfiles = d.Load(directory, true);
        if (nfiles == 0) return 1;

        string descriptor = "Descriptor";
        FilenamesType filenames = d.GetFilenames();

        gdcm.Trace.DebugOn();
        gdcm.DICOMDIRGenerator gen = new DICOMDIRGenerator();
        gen.SetFilenames(filenames);
        gen.SetDescriptor(descriptor);
        if (!gen.Generate())
        {
            return 1;
        }

        gdcm.FileMetaInformation.SetSourceApplicationEntityTitle("GenerateDICOMDIR");
        gdcm.Writer writer = new Writer();
        writer.SetFile(gen.GetFile());

        writer.SetFileName(outFileName);
        if (!writer.Write())
        {
            return 1;
        }

        return 0;
    }

The function returns and does not generate a DICOMDIR file. I have added trace debug on but still cannot debug or get any output message.

Is there any way to generate DICOMDIR file for bunch of DICOM files ?

Ozan Deniz
  • 1,087
  • 7
  • 22

1 Answers1

0

As per the documentation, did you made sure that:

Warning: : PS 3.11 - 2008 / D.3.1 SOP Classes and Transfer Syntaxes Composite Image & Stand-alone Storage are required to be stored as Explicit VR Little Endian Uncompressed (1.2.840.10008.1.2.1). When a DICOM file is found using another Transfer Syntax the generator will simply stops. Input files should be Explicit VR Little Endian filenames should be valid VR::CS value (16 bytes, upper case ...)

If you turn verbose debugging you could log the exact error message, see gdcm::Trace for usage.

As per the documentation of gdcm::Trace, you need to pay attention to the following:

Warning: All string messages are removed during compilation time when compiled with CMAKE_BUILD_TYPE being set to either: Release MinSizeRel It is recommended to compile with RelWithDebInfo and/or Debug during prototyping of applications.

You could also use gdcm::Trace::SetStreamToFile, to properly redirect any messages to a file (instead of stdout by default).

Since you use the recursion option of gdcm.Directory, you need to also pay attention that sub-directory name are valid (VR::CS, 16bytes, upper case...).

See also the gdcmgendir man page for more info.

malat
  • 12,152
  • 13
  • 89
  • 158
  • I have added as you said and updated the latest versionof the code in the question section. However, there is still no debug message in output console. @malat – Ozan Deniz Jan 08 '15 at 13:12
  • I do not know why you cannot get the error message on your side, but I bet the problem lies in the original post I made. Your filename convention is either wrong (99% chance), or you forgot to convert the DCM file to Explicit Little Endian Transfer Syntax first. – malat Jan 08 '15 at 13:42
  • I am using 1.2.840.10008.1.2.1 uid which is Explicit VR Little Endian. My file name is IM180. – Ozan Deniz Jan 08 '15 at 13:50
  • I redirect the stream to the file and does not produce any trace messages to the file. – Ozan Deniz Jan 08 '15 at 14:00
  • @OzanDeniz please join the gdcm mailing list: https://lists.sourceforge.net/lists/listinfo/gdcm-developers and send me some DICOM DataSet – malat Jan 08 '15 at 16:26
  • I have send a mail to the group. I have attached dcm file I have converted from jpeg file. Thank you for your interest. – Ozan Deniz Jan 09 '15 at 08:08