4 \page dcm2xml Convert DICOM file and data set to XML
6 \page dcm2xml dcm2xml: Convert DICOM file and data set to XML
9 \section synopsis SYNOPSIS
12 dcm2xml [options] dcmfile-in [xmlfile-out]
15 \section description DESCRIPTION
17 The \b dcm2xml utility converts the contents of a DICOM file (file format or
18 raw data set) to XML (Extensible Markup Language). The DTD (Document Type
19 Definition) is described in the file <em>dcm2xml.dtd</em>.
21 If \b dcm2xml reads a raw data set (DICOM data without a file format
22 meta-header) it will attempt to guess the transfer syntax by examining the
23 first few bytes of the file. It is not always possible to correctly guess the
24 transfer syntax and it is better to convert a data set to a file format
25 whenever possible (using the \b dcmconv utility). It is also possible to use
26 the \e -f and <em>-t[ieb]</em> options to force \b dcm2xml to read a data set
27 with a particular transfer syntax.
29 \section parameters PARAMETERS
32 dcmfile-in DICOM input filename to be converted
34 xmlfile-out XML output filename (default: stdout)
37 \section options OPTIONS
39 \subsection general_options general options
42 print this help text and exit
45 print version information and exit
48 print expanded command line arguments
51 quiet mode, print no warnings and errors
54 verbose mode, print processing details
57 debug mode, print debug information
59 -ll --log-level [l]evel: string constant
60 (fatal, error, warn, info, debug, trace)
61 use level l for the logger
63 -lc --log-config [f]ilename: string
64 use config file f for the logger
67 \subsection input_options input options
72 read file format or data set (default)
78 read data set without file meta information
80 input transfer syntax:
83 use TS recognition (default)
85 -td --read-xfer-detect
86 ignore TS specified in the file meta header
88 -te --read-xfer-little
89 read with explicit VR little endian TS
92 read with explicit VR big endian TS
94 -ti --read-xfer-implicit
95 read with implicit VR little endian TS
100 load very long tag values (e.g. pixel data)
103 do not load very long values (default)
105 +R --max-read-length [k]bytes: integer (4..4194302, default: 4)
106 set threshold for long values to k kbytes
109 \subsection processing_options processing options
113 +Cr --charset-require
114 require declaration of extended charset (default)
116 +Ca --charset-assume [c]harset: string constant
117 (latin-1 to -5, cyrillic, arabic, greek, hebrew)
118 assume charset c if no extended charset declared
120 +Cc --charset-check-all
121 check all data elements with string values
122 (default: only PN, LO, LT, SH, ST and UT)
125 \subsection output_options output options
129 +Xd --add-dtd-reference
130 add reference to document type definition (DTD)
132 +Xe --embed-dtd-content
133 embed document type definition into XML document
135 +Xf --use-dtd-file [f]ilename: string
136 use specified DTD file (only with +Xe)
137 (default: /usr/local/share/dcmtk/dcm2xml.dtd)
139 +Xn --use-xml-namespace
140 add XML namespace declaration to root element
144 +Wn --write-element-name
145 write name of the DICOM data elements (default)
147 -Wn --no-element-name
148 do not write name of the DICOM data elements
150 +Wb --write-binary-data
151 write binary data of OB and OW elements
152 (default: off, be careful with --load-all)
155 encode binary data as hex numbers (default)
158 encode binary data as Base64 (RFC 2045, MIME)
163 The basic structure of the XML output created from a DICOM image file looks
167 <?xml version="1.0" encoding="ISO-8859-1"?>
168 <!DOCTYPE file-format SYSTEM "dcm2xml.dtd">
169 <file-format xmlns="http://dicom.offis.de/dcmtk">
170 <meta-header xfer="1.2.840.10008.1.2.1" name="LittleEndianExplicit">
171 <element tag="0002,0000" vr="UL" vm="1" len="4"
172 name="MetaElementGroupLength">
176 <element tag="0002,0013" vr="SH" vm="1" len="16"
177 name="ImplementationVersionName">
181 <data-set xfer="1.2.840.10008.1.2" name="LittleEndianImplicit">
182 <element tag="0008,0005" vr="CS" vm="1" len="10"
183 name="SpecificCharacterSet">
187 <sequence tag="0028,3010" vr="SQ" card="2" name="VOILUTSequence">
189 <element tag="0028,3002" vr="xs" vm="3" len="6"
190 name="LUTDescriptor">
198 <element tag="7fe0,0010" vr="OW" vm="1" len="262144"
199 name="PixelData" loaded="no" binary="hidden">
205 The "file-format" and "meta-header" tags are absent for DICOM data sets.
207 \subsection character_encoding Character Encoding
209 The XML encoding is determined automatically from the DICOM attribute
210 (0008,0005) "Specific Character Set" (if present) using the following
214 ASCII "ISO_IR 6" => "UTF-8"
215 UTF-8 "ISO_IR 192" => "UTF-8"
216 ISO Latin 1 "ISO_IR 100" => "ISO-8859-1"
217 ISO Latin 2 "ISO_IR 101" => "ISO-8859-2"
218 ISO Latin 3 "ISO_IR 109" => "ISO-8859-3"
219 ISO Latin 4 "ISO_IR 110" => "ISO-8859-4"
220 ISO Latin 5 "ISO_IR 148" => "ISO-8859-9"
221 Cyrillic "ISO_IR 144" => "ISO-8859-5"
222 Arabic "ISO_IR 127" => "ISO-8859-6"
223 Greek "ISO_IR 126" => "ISO-8859-7"
224 Hebrew "ISO_IR 138" => "ISO-8859-8"
227 Multiple character sets are not supported (only the first attribute value is
228 mapped in case of value multiplicity).
230 \subsection xml_encoding XML Encoding
232 Attributes with very large value fields (e.g. pixel data) are not loaded by
233 default. They can be identified by the additional attribute "loaded" with a
234 value of "no" (see example above). The command line option \e --load-all
235 forces to load all value fields including the very long ones.
237 Furthermore, binary information of OB and OW attributes are not written to the
238 XML output file by default. These elements can be identified by the
239 additional attribute "binary" with a value of "hidden" (default is "no"). The
240 command line option \e --write-binary-data causes also binary value fields to
241 be printed (attribute value is "yes" or "base64"). But, be careful when using
242 this option together with \e --load-all because of the large amounts of pixel
243 data that might be printed to the output.
245 Multiple values (i.e. where the DICOM value multiplicity is greater than 1)
246 are separated by a backslash "\" (except for Base64 encoded data). The "len"
247 attribute indicates the number of bytes for the particular value field as
248 stored in the DICOM data set, i.e. it might deviate from the XML encoded value
249 length e.g. because of non-significant padding that has been removed. If this
250 attribute is missing in "sequence" or "item" start tags, the corresponding
251 DICOM element has been stored with undefined length.
253 \section logging LOGGING
255 The level of logging output of the various command line tools and underlying
256 libraries can be specified by the user. By default, only errors and warnings
257 are written to the standard error stream. Using option \e --verbose also
258 informational messages like processing details are reported. Option
259 \e --debug can be used to get more details on the internal activity, e.g. for
260 debugging purposes. Other logging levels can be selected using option
261 \e --log-level. In \e --quiet mode only fatal errors are reported. In such
262 very severe error events, the application will usually terminate. For more
263 details on the different logging levels, see documentation of module "oflog".
265 In case the logging output should be written to file (optionally with logfile
266 rotation), to syslog (Unix) or the event log (Windows) option \e --log-config
267 can be used. This configuration file also allows for directing only certain
268 messages to a particular output stream and for filtering certain messages
269 based on the module or application where they are generated. An example
270 configuration file is provided in <em><etcdir>/logger.cfg</em>).
272 \section command_line COMMAND LINE
274 All command line tools use the following notation for parameters: square
275 brackets enclose optional values (0-1), three trailing dots indicate that
276 multiple values are allowed (1-n), a combination of both means 0 to n values.
278 Command line options are distinguished from parameters by a leading '+' or '-'
279 sign, respectively. Usually, order and position of command line options are
280 arbitrary (i.e. they can appear anywhere). However, if options are mutually
281 exclusive the rightmost appearance is used. This behaviour conforms to the
282 standard evaluation rules of common Unix shells.
284 In addition, one or more command files can be specified using an '@' sign as a
285 prefix to the filename (e.g. <em>\@command.txt</em>). Such a command argument
286 is replaced by the content of the corresponding text file (multiple
287 whitespaces are treated as a single separator unless they appear between two
288 quotation marks) prior to any further evaluation. Please note that a command
289 file cannot contain another command file. This simple but effective approach
290 allows to summarize common combinations of options/parameters and avoids
291 longish and confusing command lines (an example is provided in file
292 <em><datadir>/dumppat.txt</em>).
294 \section environment ENVIRONMENT
296 The \b dcm2xml utility will attempt to load DICOM data dictionaries specified
297 in the \e DCMDICTPATH environment variable. By default, i.e. if the
298 \e DCMDICTPATH environment variable is not set, the file
299 <em><datadir>/dicom.dic</em> will be loaded unless the dictionary is built
300 into the application (default for Windows).
302 The default behaviour should be preferred and the \e DCMDICTPATH environment
303 variable only used when alternative data dictionaries are required. The
304 \e DCMDICTPATH environment variable has the same format as the Unix shell
305 \e PATH variable in that a colon (":") separates entries. On Windows systems,
306 a semicolon (";") is used as a separator. The data dictionary code will
307 attempt to load each file specified in the \e DCMDICTPATH environment variable.
308 It is an error if no data dictionary can be loaded.
312 <em><datadir>/dcm2xml.dtd</em> - Document Type Definition (DTD) file
314 \section see_also SEE ALSO
316 <b>xml2dcm</b>(1), <b>dcmconv</b>(1)
318 \section copyright COPYRIGHT
320 Copyright (C) 2002-2010 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.