Checking for existense of tags in a multi-frame dicom set

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
zeinsalah
Posts: 5
Joined: Mon, 2016-06-27, 12:14

Checking for existense of tags in a multi-frame dicom set

#1 Post by zeinsalah »

Hello,

I am actually not an expert and this is my first topic in the forum, so pleas forgive me if the question is silly. I was using a call like

Code: Select all

 if (dataset->findAndGetOFStringArray(tag, value).good()) 

to check if a specific tag is existing in a dataset. This was working fine for single-frage dicom. For multi-frame disoms, this fails if the tag does not exist in the common tags. So, I wrote a function (see below) to generalize the test. The function is (first) supposed to the same test above and if it fails, it searches in the SharedFunctionalGroupsSequence.

The function does not seem to work properly. I used it to check for DCM_PixelSpacing. The input file contains the tag within the Shared Functional Groups Sequence, as I can see this by opening the file using MicroDicom software. Following the printed debugging text, the sequence itself is being found, but the last test always fails.

Do you see any reason for this? Am I writing something wrong?

Much thanks,

Zein

PS: This is my function

Code: Select all

  bool DicomClass::isTagPresentInDataset(DcmDataset* dataset, const DcmTagKey& tag, OFString& value)
  {
    if (!dataset)
      return false;

    if (dataset->findAndGetOFStringArray(tag, value).good())
    {
      return true;
    }
    else
    {
      printf("Tag: %s\n", tag.toString());
      DcmItem* dcmItem;

      if (dataset->findAndGetSequenceItem(DCM_SharedFunctionalGroupsSequence, dcmItem, 0).good())
      {
        printf("SharedFunctionalGroupsSequence found\n");
        if (dcmItem->findAndGetOFStringArray(tag, value).good())   // this seems to not work !!!!!!!!
        {
          printf("tag found in SharedFunctionalGroupsSequence\n");
          return true;
        }
      }
    }

    return false;
  }

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Checking for existense of tags in a multi-frame dicom se

#2 Post by Michael Onken »

Hi,

the code looks good to me at first glance.

Maybe the tag's VR (data type) does not allow to be returned as an OFStringArray? Actually most support that call, but that's the only thing that I can imagine now.

By the way, if you only want to know whether the tag is in the dataset, there is no need to search the element tree yourself. Instead, use dataset->findAndGetOFStringArray(tag, value, OFTrue) -- the third parameter means that DCMTK will search the whole element tree, returning the value of first occurence it can find.

Best,
Michael

J. Riesmeier
DCMTK Developer
Posts: 2503
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Checking for existense of tags in a multi-frame dicom se

#3 Post by J. Riesmeier »

To the OP: PixelSpacing is not contained in the first item of the SharedFunctionalGroupsSequence but in the nested substructure PixelMeasuresSequence.

Here's an example:

Code: Select all

(5200,9229) SQ (Sequence with explicit length #=1)      # 102, 1 SharedFunctionalGroupsSequence
  (fffe,e000) na (Item with explicit length #=2)          #  94, 1 Item
    (0028,9110) SQ (Sequence with explicit length #=1)      #  52, 1 PixelMeasuresSequence
      (fffe,e000) na (Item with explicit length #=2)          #  44, 1 Item
        (0018,0050) DS [1.11]                                   #   4, 1 SliceThickness
        (0028,0030) DS [0.000452448\0.000452448]                #  24, 2 PixelSpacing
      (fffe,e00d) na (ItemDelimitationItem for re-encoding)   #   0, 0 ItemDelimitationItem
    (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) #   0, 0 SequenceDelimitationItem
  [...]

zeinsalah
Posts: 5
Joined: Mon, 2016-06-27, 12:14

Re: Checking for existense of tags in a multi-frame dicom se

#4 Post by zeinsalah »

Thank you!

Both answers were helpfull.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest