tagExistsAndValue(DCM_PixelData) returns false for Enhanced Multi Frame Images

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

tagExistsAndValue(DCM_PixelData) returns false for Enhanced Multi Frame Images

#1 Post by angad » Thu, 2012-02-09, 08:57

Hi All,

I have some dicom files in which there is no pixel data. Pixel data tag is present but there is no value.

I want some API which will tell me either pixel data tag exists or not, if exists value is present or not. If value is present either pixel data is correct or not. I don't want to read the complete pixel data and then check either that pixel data is correct or not. If i read pixel data for each image, then it will slow down my application.

I tried to use

dataset->tagExistsWithValue(DCM_PixelData)

Depending upon the return type, i treat the files. If above API returns me false, i move such dicom files to corrupted dicom folder. Above API returns false for above dicom files.

But it is returning false for Enhanced multiframe MRI images. But these enhanced MRI images are absolutely fine. dcmdump for these enhanced MRI images as :

(7fe0,0010) OB (PixelSequence #=10) # u/l, 1 PixelData
(fffe,e000) pi 00\00\00\00\d2\dd\00\00\44\c2\01\00\80\9c\02\00\da\71\03\00\34\48... # 36, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 56778, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 58474, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 55860, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 54610, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 54866, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 54470, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 52252, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 52004, 1 Item
(fffe,e000) pi ff\d8\ff\e0\00\10\4a\46\49\46\00\01\01\00\00\01\00\01\00\00\ff\c3... # 52188, 1 Item
(fffe,e0dd) na (SequenceDelimitationItem) # 0, 0 SequenceDelimitationItem


Ayy idea what thing i am doing wrong with tagExistsAndValue? or is there any other approach or any other API for my problem..

Thanks,
Angad Nath

angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

#2 Post by angad » Thu, 2012-02-09, 11:30

For Enhanced MRI images, pixel data is coming as a sequence. In my last post i mentioned that,

(7fe0,0010) OB (PixelSequence #=10) # u/l, 1 PixelData.

This line clearly says that Pixel data is coming in sequence tag. But how to extract this value.. i am not able to find any dcmtk API which will return me such type of informations(like either it is PixelSequence or not. if yes, how to get this value 10).

Waiting for positive reply.

Thanks in advance.

Angad Nath

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

#3 Post by J. Riesmeier » Thu, 2012-02-09, 17:04

It seems that tagExistsWithValue() does not work correctly for encapsulated pixel data (i.e. for the PixelSequence). What about the following patch to "dcitem.cc" (based on the current development version):

Code: Select all

 OFBool DcmItem::tagExistsWithValue(const DcmTagKey &key,
                                    OFBool searchIntoSub)
 {
-    DcmElement *elem = NULL;
-    Uint32 len = 0;
     DcmStack stack;
+    OFBool result = OFFalse;

-    OFCondition ec = search(key, stack, ESM_fromHere, searchIntoSub);
-    elem = OFstatic_cast(DcmElement *, stack.top());
-    if (ec.good() && elem != NULL)
-        len = elem->getLength();
+    if (search(key, stack, ESM_fromHere, searchIntoSub).good())
+    {
+        DcmElement *elem = OFstatic_cast(DcmElement *, stack.top());
+        if (elem != NULL)
+            result = !(elem->isEmpty());
+    }

-    return (ec.good()) && (len > 0);
+    return result;
 }

angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

#4 Post by angad » Fri, 2012-02-10, 05:20

Hi ,

Thanks for your reply.

I don't want to do changes in dcmtk code base.

Instead of using tagExistsAndValue, i used isEmpty() function. Following is the code :

DcmElement * pixelDataElement;
dataset->findAndGetElement(DCM_PixelData,pixelDataElement);
if(pixelDataElement != NULL)
{
if(pixelDataElement->isEmpty())
{
RAD_LOG_CRITICAL("DCM_PixelData tag is empty. Moving file to Corruped_Dicom folder.");
this->isFileLoadedSuccessfully = 0;
return;
}
}
else
{
RAD_LOG_CRITICAL("DCM_PixelData tag not found. Moving file to Corrupted_Dicom folder");
this->isFileLoadedSuccessfully = 0;
return;
}

pixelDataElement = NULL;


I think above code works same as tagExistsAndValue function. If above function handles all the corner scenarios, then i will go with above code only. If any corner scenario is left, then i can do code changes in dcmtk code also.

Waiting for your reply.

Thanks,
Angad Nath

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

#5 Post by J. Riesmeier » Fri, 2012-02-10, 08:50

You should probably also check the return value of findAndgetElement().

Btw, the above patch is now committed, so it will be part of the next development snapshot. Thanks again for the report.

Post Reply

Who is online

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