dcm2json filtering

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
inorton
Posts: 1
Joined: Mon, 2018-12-03, 08:06

dcm2json filtering

#1 Post by inorton »

I would like to give users a tool to some DICOM information to JSON, but only preserve some specific (known safe) fields we need, alongside NIFTI research format output converted with dcm2niix. I know about the existing BIDS output from dcm2niix, but need some more specific and expansive fields which it won't cover, including the CSA header in some cases.

To support this use case, I was considering to make dcm2json support the +P command line option like dcmdump. Then users could filter output, by specifying either `dcm2json +P tag +P tag...` or more likely `dcm2json @filter.txt` (where filter.txt has a set of +P commands).

If this sounds ok: in terms of implementation, it looks like the simplest way to make this change would be to iterate over the DcmFile instance via the DcmSequenceOfItems methods, and remove all top-level DcmItem that do not match any tag specified on the command line. Then proceed to call `DcmDataset::writeJson` as usual in the existing code. I am only interested in "top level" tags, so I would not iterate into the tree.

Does this sound reasonable/acceptable for a patch?

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: dcm2json filtering

#2 Post by Jan Schlamelcher »

Good Idea! Maybe have a look at the class DcmAttributeFilter that might help for filtering items.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest