Unable to to use search more than once in DcmDataSet

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
MicroFace
Posts: 15
Joined: Thu, 2005-10-27, 21:46

Unable to to use search more than once in DcmDataSet

#1 Post by MicroFace »

I am using the DCMFileObject to load in the DICOM File, which has been verified with DVTK DCMView to have avertyhing.
But when I use DcmDataSet->search using the ESM_fromStackTop
I still have to make sure and access the DICOM Tag and Elements in numerical order.
For instance if a i Access DCM_PatientOrientation (0x0020, 0x0020) everything is find the OFCond is normal
IF I then use the Same Function to try and find
DCM_ReferringPhysiciansName (0x0008, 0x0090) If recieve the OFCond
Tag Not Found , but I know the information is there.
I tried to put them in numerical order, but it did not make any difference
The Code I am using Looks Like This

bool DCMFileBase::ParseDicomIntoMember(DcmDataset* pDcmStack)
{
bool bResult = false;

unsigned short uSamplesPerPixel=0, uBitsPerPixel=0;

OFCondition condResult;
DcmStack dcmStack;

condResult = pDcmStack->search(DCM_Modality,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_Modality %s\n",condResult.text());
bResult = false;
return bResult;
}
else
{
OFString strResult;
DcmCodeString * pResult = (DcmCodeString*)dcmStack.elem(0);
pResult->getOFString(strResult,0);
strcpy(m_cModality,strResult.c_str());
bResult = true;
}

m_bReferringDoctorSet = false;
condResult = pDcmStack->search(DCM_ReferringPhysiciansName,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_ReferringPhysiciansName %s\n",condResult.text());
}
else
{
m_bReferringDoctorSet = true;
}



m_bPatientOrientationSet = false;
condResult = pDcmStack->search(DCM_PatientOrientation,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_PatientOrientation %s\n",condResult.text());

}
else
{
m_bPatientOrientationSet = true;
}

condResult = pDcmStack->search(DCM_SamplesPerPixel,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_SamplesPerPixel %s\n",condResult.text());
bResult = false;
return bResult;
}
else
{
DcmUnsignedShort * pResult = (DcmUnsignedShort*)dcmStack.elem(0);
pResult->getUint16(uSamplesPerPixel);


}

condResult = pDcmStack->search(DCM_BitsStored,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_BitsStored %s\n",condResult.text());
bResult = false;
return bResult;
}
else
{
DcmUnsignedShort * pResult = (DcmUnsignedShort*)dcmStack.elem(0);
pResult->getUint16(uBitsPerPixel);
m_uBitsPerPixel = uBitsPerPixel * uSamplesPerPixel;
bResult = true;

}


return bResult;
}

Any clues would be helpful

MicroFace
Posts: 15
Joined: Thu, 2005-10-27, 21:46

I solved the problem by using a localized dcmStack

#2 Post by MicroFace »

I solved my problem by changing the above code to
{
OFCondition condResult;
DcmStack dcmStack;

condResult = pDcmStack->search(DCM_SamplesPerPixel,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_SamplesPerPixel %s\n",condResult.text());
bResult = false;
return bResult;
}
else
{
DcmUnsignedShort * pResult = (DcmUnsignedShort*)dcmStack.elem(0);
pResult->getUint16(uSamplesPerPixel);


}
}
{
OFCondition condResult;
DcmStack dcmStack;

condResult = pDcmStack->search(DCM_BitsStored,dcmStack,ESM_fromStackTop);
if(!condResult.good())
{
printf("DCM_BitsStored %s\n",condResult.text());
bResult = false;
return bResult;
}
else
{
DcmUnsignedShort * pResult = (DcmUnsignedShort*)dcmStack.elem(0);
pResult->getUint16(uBitsPerPixel);
m_uBitsPerPixel = uBitsPerPixel * uSamplesPerPixel;
bResult = true;

}
}
This forces a new dcmStack to be used with each search
since the DcmStack Constructor and Desctructor are called for each pair of braces.
Who knew ??
Is this behaviour documented anywhere ?

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#3 Post by Jörg Riesmeier »

First of all, why don't you use the helper functions DcmItem::findAndGetXXX() for this purpose? Furthermore, if you specify to search from stack top and your stack is not empty then, of course, the search starts from stack top (i.e. from the element of your last search) :-)
Last edited by Jörg Riesmeier on Fri, 2007-06-08, 16:42, edited 1 time in total.

MicroFace
Posts: 15
Joined: Thu, 2005-10-27, 21:46

#4 Post by MicroFace »

I am sorry, but since when did start at teh top of teh stack, not mean start at the beginning ?
I know that english is not my primary language, but I thought the top of something was the top, not the currrent location.
Anyway, as I said I have found a workaround, so I really don't care about this issue, but thank for the pointer to the helper function. I have not memorized, the class interactions, so i am using what I can find to complete my job. Once I find something that works I do not go looking further.
Thank you for pointing me in the more correct direciton.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#5 Post by Jörg Riesmeier »

The stack stores the results of the search process. So, when the top of the stack contains the data element that was found during the last call and you invoke the search() function with "ESM_fromStackTop" that means "start from the last searched element" - That's all :-)

Btw, there is an example on how to access data elements like the patient's name in the documentation. The helper functions are much easier to use and to understand.

Post Reply

Who is online

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