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
Code: Select all
OFGlobal<OFBool> dcmAcceptFileMetaUnknownTransferSyntax(OFTrue); // added
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)
...
Regards, Yves