DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Tue, 2017-04-25, 15:35

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu, 2012-02-09, 08:57 
Offline

Joined: Thu, 2010-02-18, 09:54
Posts: 112
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu, 2012-02-09, 11:30 
Offline

Joined: Thu, 2010-02-18, 09:54
Posts: 112
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu, 2012-02-09, 17:04 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1805
Location: Oldenburg, Germany
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:
 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;
 }


Top
 Profile  
 
 Post subject:
PostPosted: Fri, 2012-02-10, 05:20 
Offline

Joined: Thu, 2010-02-18, 09:54
Posts: 112
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri, 2012-02-10, 08:50 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1805
Location: Oldenburg, Germany
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group