LEADTOOLS Support
Medical
Medical SDK FAQ
How do I workaround invalid elements in my DICOM file when copying my DataSet?
#1
Posted
:
Sunday, March 18, 2012 5:15:11 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
If a DICOM dataset contains invalid elements, the LDicomDS.CopyDS method returns error 5 (DICOM_ERROR_WRITE).
You can work around this if you use the overload of CopyDS that has a callback. In the callback, return FALSE when you get to the invalid element. This way, CopyDS will copy everything but the invalid element.
Here is sample code that shows how to do this:
Code:L_BOOL EXT_CALLBACK pfnCopyDSCallBack(pDICOMELEMENT pElement, L_UINT16 nFlags, L_VOID *pUserData)
{
UNREFERENCED_PARAMETER(nFlags);
UNREFERENCED_PARAMETER(pUserData);
//The condition in the following if statement depends on the dataset.
//This is just an example for one dataset that had invalid Other Patient IDs Sequence item.
if (pElement->nTag == TAG_OTHER_PATIENT_IDS_SEQUENCE)
return FALSE;
return TRUE;
}
void CDicomDlg::OnCopyDataset()
{
L_UINT32 nClass;
L_UINT16 uFlags;
L_TCHAR buf[180];
LDicomDS lDS(NULL);
LDicomDS lDSTmp(NULL);
lDS.LoadDS(TEXT("D:\\X.dcm"), 0);
int nRet = lDSTmp.CopyDS(NULL, &lDS, NULL, pfnCopyDSCallBack, NULL);
if (nRet == 0)
{
lDSTmp.GetInfoDS(&nClass, &uFlags);
wsprintf(buf, TEXT("Data Set #2\nClass = %d\nFlags = %d"), nClass, uFlags);
::MessageBox(NULL, buf, TEXT("Test"), MB_OK);
}
}
Edited by moderator Wednesday, March 21, 2018 10:14:05 AM(UTC)
| Reason: Formatted code
LEADTOOLS Support
Medical
Medical SDK FAQ
How do I workaround invalid elements in my DICOM file when copying my DataSet?
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.