dcm2json

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
nolden
Posts: 2
Joined: Fri, 2017-05-12, 14:37

dcm2json

#1 Post by nolden »

Hi,

I'm playing around with the new dcm2json utility of the latest snapshot, thanks for that, it's pretty useful I think. One issue I have with it is the export of bulk binary data. It seems to always dump these, no matter which options I pass. Looking at the source code, I think this hasn't been implemented yet,

Code: Select all

DcmJsonFormat::asBulkDataURI
always returns

Code: Select all

false
. Am I correct?

Is there some workaround using dcmodify to achieve the same? I won't need the OB data, I just want to remove them from the json.

Marco

Sebastian Grallert
Posts: 1
Joined: Tue, 2015-12-08, 15:49

Re: dcm2json

#2 Post by Sebastian Grallert »

Hello Marco,

the documentation is currently misleading (copy and paste error from dcm2xml), this will be fixed.
We will add a command line option to dcm2json for hiding binary data based on the VR.
At this stage dcm2json requires implementing a custom JSON formatter as in the example given in the documentation.

(In the example is a litte Error, here corrected)

Code: Select all

struct BulkDataURIJsonFormat : DcmJsonFormatPretty
{
  BulkDataURIJsonFormat(const OFBool printMetaheaderInformation = OFTrue,
                   ... bulkDataURIDatabase)
  : DcmJsonFormatPretty(printMetaheaderInformation)
  , TheDatabase(bulkDataURIDatabase)
  {
  }
  virtual OFBool asBulkDataURI(const DcmTagKey& tag, OFString& uri)
  {
    ... result = TheDatabase.findBulkDataFor(tag);
    if (result.found())
    {
      uri = result.uri();
      return OFTrue;
    }
    return OFFalse;
  }
  ... TheDatabase;
}
An example to hide all OW and OB information would be:

Code: Select all

virtual OFBool asBulkDataURI(const DcmTagKey& tag, OFString& uri)
{
  if (DcmTag(tag).getEVR() == EVR_OB || DcmTag(tag).getEVR() == EVR_OW || DcmTag(tag).getEVR() == EVR_ox)
  {
      uri = "<<BINARY_DATA_OMITTED>>";
      return OFTrue;
  }
  return OFFalse;
}

nolden
Posts: 2
Joined: Fri, 2017-05-12, 14:37

Re: dcm2json

#3 Post by nolden »

Thanks for the quick solution!

ormaa
Posts: 1
Joined: Mon, 2017-12-11, 12:58

Re: dcm2json

#4 Post by ormaa »

Hello,

do you have an idea of when this update will be available ?

I tried to read the different source, in order to make the fix myself, but I didn't find where to implement your solution.

thanks
Olivier

Post Reply

Who is online

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