c++stringtagsdicomdcmtk

showing the full content of ImageType in DCMTK


I'm trying to read a number of Siemens DICOM images with DCMTK, some of which are mosaic images. I'm looking for a quick way to find those.

What I can see with mosaic images is that this is specified in the ImageType tag, e.g.

$ dcmdump ${im0} | grep ImageType
(0008,0008) CS [ORIGINAL\PRIMARY\ASL\NONE\ND\NORM\MOSAIC] #  40, 7 ImageType

Most of the tags are easily read with findAndGetOFString() (or similar for floats etc), but if I do

tmpdata->findAndGetOFString(DCM_ImageType, tmpstring);
std::cout << "image type: " << tmpstring << "\n";           

for DcmDataset* tmpdata and OFString tmpstring, then the content of tmpstring is only ORIGINAL so the rest of the value is never printed.

In dcmdump it is printed, but there the value of DCM_ImageType never seems to be stored in a string, which I do need it to be.

Would there be a similar command to findAndGetOFString() for 'code strings'? Maybe I'm missing something obvious!


Solution

  • Image Type (0008,0008) is a multi-valued attribute. That is, it may include several values which are separated by the backslash character. Note, that "officially", the backslash is not part of the attribute's value. It is a delimiter between several values of the attribute. This is what you have. So in terms of DICOM, there is no "one value" but multiple ones. The DCMTK API allows you to handle this (of course).

    findAndGetOFString() has a third parameter ("index") to define which of the multiple values you want to obtain.

    The behavior that you probably expect is what findAndGetOFStringArray() does.

    As an alternative, you could iterate through the multiple values of the attribute by obtaining the "Value Multiplicity" first and then loop through the values like

    DcmElement* element = tmpdata->findAndGetElement(DCM_ImageType);
    int numberOfValues = element->getVM();
    for(int index = 0; index < numberOfValues; index++)
    {
        OFString valueAtIndex;
        element->GetOfString(valueAtIndex, index);
        /// ... your concatenation goes here...
    }