Category Archives: Tools

Favorite DICOM tools: dcmtk

Background

I just wanted to do a quick post about one of my favourite open-source DICOM toolkits, dcmtk.

From the dcmtk website: “It includes software…

  • for examining, constructing and converting DICOM image files
  • handling storage media
  • sending and receiving images over a network connection
  • as well as demonstrative image storage and worklist servers”

So, basically it does a lot of the things you need to do to deal with DICOM network traffic as well as DICOM files themselves. I’ve incorporated it into pretty much every Radiology software project that I’ve written, as its tools can easily be called inside of common scripting languages to do almost whatever you need to do in terms of interfacing with PACS systems and handling/manipulating DICOM files.

Some of my favorite dcmtk utilities:

    • dcmdump – used to dump out the header elements of DICOM files
    • findscu – utility to perform C-FIND operations on PACS; I use this to create worklists in web-based apps or allow users to query PACS interactively
    • movescu – retrieve DICOM object(s)/files from PACS; useful for moving around files
    • dsrdump and dsr2html – dump out the data from DICOM SR objects (dsr2html dumps it to HTML format); super-helpful in understanding how the various vendors’ SR formats & content work

I’ve used it before in Mac OS, Windows, and Linux environments, and it works flawlessly in all of them.  This project is a real asset to the imaging community.

Example – movescu & dsrdump

Here’s an example of some PHP code how you’d use movescu to retrieve a DICOM object from  PACS:

$command = "movescu -aet $myaetitle -aec $pacsaetitle -aem $myaetitle -S -k 0008,0052=\"IMAGE\" -k 0020,000d=\"$studyuid\" -k 0020,000e=\"$seriesuid\" -k 0008,0018=\"$objectuid\" $pacsipaddress $pacstcpport 2>&1";
$movescu = shell_exec($command);

The variables used above are:

  • $myaetitle – the DICOM AE Title of the web server/workstation doing the retrieval
  • $pacsaetitle – the DICOM AE Title of the PACS server
  • $studyuid – the Study UID of the study that the SR object belongs to
  • $seriesuid – the Series UID of the series that the SR object belongs to
  • $objectuid – the Object UID of the SR object
  • $pacsipaddress – the IP address of the PACS server
  • $pacstcpport – the TCP Port that the PACS Server’s DICOM interface is listening on

And let’s say we just retrieved a DICOM SR object; next we can use dsr2html to dump out the SR object into a variable:

$dump_command = "dsr2html -Ee -Er -Ec +Rd +Sr report.css " . $infile;
$sr_html = shell_exec($dump_command);

The options I’m using here for dsr2html are:

  • -Ee – ‘ignore item errors’ – useful as SR objects can sometimes have errors in them
  • -Er – ‘accept unknown/missing relationship type’ – again, to not fail if the object has errors
  • +Rd – ‘render full data of content items’ – to render the entire content of the SR
  • +Sr – ‘add reference to specified CSS to document’ – to have the HTML output reference the CSS file that you’re including to style the output
  • report.css – the CSS file to use to style the HTML output

We could then just render the HTML output with print $sr_html;

That’s it – hope you find it as helpful as I have over the years.