Private transfer syntax and DcmFileFormat::loadFile

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Yves Neumann
Posts: 30
Joined: Fri, 2005-12-02, 17:06
Location: Germany

Private transfer syntax and DcmFileFormat::loadFile

#1 Post by Yves Neumann »

Hello OFFIS-Team,

I have some kind of feature request related to DcmFileFormat and reading files using private transfer syntaxes. Actually I would like to have a flag (similar to 'dcmIgnoreParsingErrors' and alike) to avoid DcmFileFormat to load files containing any private/unknown transfer syntax.

About the background: from time to time we come across files that use private transfer syntaxes, e.g. some Philips machines use the transfer syntax '1.2.752.24.3.7.7', or are missing that info at all in the meta information, that we can not handle correctly for visualization. The logic of DcmFileFormat::loadFile will load the meta header info and, due to the unknown UID within the meta header tag (0002,0010), will determine EXS_Unknown which is then passed into DcmDataset::read pipe. The transfer syntax detection in DcmDataset is not able to detect the TS correctly (obviously) and claims the dataset to be e.g. "Explicit Little Endian". This strategy is ok in order to read the dataset and access information like patient names but fails in regards to access the pixel data.
In our case we have to make an addititional test before using DcmFileFormat to detect such case and avoid that those data are read-in.

Proposed solution that worked for us (missing GIT here to make a patch - hence added code only):

in 'dcobject.h' (around line 174):

Code: Select all


/** This flag allows to accept (or refuse) datasets being loaded into DcmFileFormat
 *  that use a private transfer syntax UID in (0002,0010) or if the info is absent.
 */
extern OFGlobal<OFBool> dcmAcceptFileMetaUnknownTransferSyntax; /* default OFTrue */  // added
in 'dcobject.cc' (around line 62):

Code: Select all


OFGlobal<OFBool> dcmAcceptFileMetaUnknownTransferSyntax(OFTrue); // added
in 'dcfilefo.cc' (around line 646):

Code: Select all

...
           // determine xfer from tag (0002,0010) in the meta header
           newxfer = lookForXfer(metaInfo);
           if ((FileReadMode == ERM_fileOnly) || (FileReadMode == ERM_metaOnly))
           {
                // reject file if no meta header present
                if (errorFlag.good() && (newxfer == EXS_Unknown))
                    errorFlag = EC_FileMetaInfoHeaderMissing;
           }

           /// added ///////////////////////////////////////////////////
           if (!dcmAcceptFileMetaUnknownTransferSyntax.get() && (newxfer == EXS_Unknown))
           {
                DCMDATA_ERROR("DcmFileFormat::read() Unknown transfer syntax in file meta information");
                errorFlag = EC_UnsupportedEncoding;
           }  
           /// added (end) ////////////////////////////////////////////

           if (errorFlag.good() && (!metaInfo || metaInfo->transferState() == ERW_ready))
            {
                dataset = getDataset();
                if (dataset == NULL && getTransferState() == ERW_init)
...
The proposed code would not break any existing code. I used the condition 'EC_UnsupportedEncoding' here as error. A newly introduced condition would probably more meaningful :).

Regards, Yves

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

#2 Post by J. Riesmeier »

Thank you for the feature request. I've just added it to our to-do list.

However, there is already a solution for this: See approach 3 at http://support.dcmtk.org/wiki/dcmtk/how ... metaheader .

Yves Neumann
Posts: 30
Joined: Fri, 2005-12-02, 17:06
Location: Germany

#3 Post by Yves Neumann »

Thanks, I didn't see that wiki before. I think it is very useful for people that are less experienced with the dcmtk in order to understand it a bit more. Actually, before modifying the dcmtk my approach was similar to 'approach 2'.

But I find my approach through the global flag in DcmFileFormat, as proposed in my inital post, somewhat more elegant than to have to write an additional test each time I read in a dataset.

Post Reply

Who is online

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