File: dcmodify.man

package info (click to toggle)
dcmtk 3.6.9-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 95,648 kB
  • sloc: ansic: 426,874; cpp: 318,177; makefile: 6,401; sh: 4,341; yacc: 1,026; xml: 482; lex: 321; perl: 277
file content (594 lines) | stat: -rw-r--r-- 23,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
/*!

\if MANPAGES
\page dcmodify Modify DICOM files
\else
\page dcmodify dcmodify: Modify DICOM files
\endif

\section dcmodify_synopsis SYNOPSIS

\verbatim
dcmodify [options] dcmfile-in...
\endverbatim

\section dcmodify_description DESCRIPTION

\b dcmodify is a tool that allows one to modify, insert and delete tags and
items in DICOM files.  Sequences and tags with a value multiplicity > 1 are
also supported.  Metaheader information and the tag's VR can not be modified
directly by \b dcmodify at this time.  In addition to tag modifications,
\b dcmodify makes available some input options - forcing \b dcmodify to
handle its input files as the user specifies - and output options to control
the output format of the resulting files.

In case multiple modifications have to be performed, \b dcmodify does the
modifications in the same order as they appear on the command line.  Please
note that \b dcmodify does not check whether a given value matches its value
representation (VR).  Usually, an error message is printed but generally the
user should take care of the right VR usage.

If \b dcmodify doesn't know the tag it should insert, then the tag's VR is set
to UN and the value provided on command line is interpreted as being a series
of hexadecimal numbers (like they are provided for VR=OB).  Please insert these
tags into the dictionary to avoid this behavior.  Also, specifying the \e -iun
option, it is possible to force \b dcmodify to leave UN values untouched.
Using option \e -u lets \b dcmodify saving all VR=UN attributes as OB.

\b dcmodify is able to work with so-called tag paths to access tags in
sequences.  The (pseudo-formalized) syntax is

\verbatim
{sequence[item-no].}*element
\endverbatim

where 'sequence' is a sequence tag like (0008,1111) or a dictionary name for a
tag.  'item-no' describes the item number to be accessed (counting from zero).
'element' defines the target tag to work on.  A tag can either be specified
directly as (0010,0010) or through the corresponding dictionary name
"PatientName".  The '*' denotes that you can repeat sequence statements to
access deeper levels in DICOM files (see EXAMPLES section).  For 'item-no',
also a wildcard character '*' can be used selecting all items in surrounding
sequence (see section WILDCARDS below).

When inserting tag paths consisting of multiple nodes (i.e. not a single
element) using the \e -i option, any missing path elements (items, sequences,
leaf elements) are inserted automatically when missing.  That does not work
for item wildcards: When no single item exists in the surrounding sequence
\b dcmodify of course can't decide, how many items should be generated.
However, if specifying an item number like '5', all 6 items (counted from zero)
can be (and are) automatically generated in insert mode.  If already 2 items
would exist, the rest (4) would be inserted.

\b dcmodify does not work on directories, i.e. the parameter \e dcmfile-in...
must not include directory names.

Please note that there are some issues concerning the modification of private
tags (see PRIVATE TAGS section) and for changing UIDs (CHANGING UIDs section).

\section dcmodify_parameters PARAMETERS

\verbatim
dcmfile-in  DICOM input filename(s) to be modified ("-" for stdin/stdout)
\endverbatim

\section dcmodify_options OPTIONS

\subsection dcmodify_general_options general options
\verbatim
  -h    --help
          print this help text and exit

        --version
          print version information and exit

        --arguments
          print expanded command line arguments

  -q    --quiet
          quiet mode, print no warnings and errors

  -v    --verbose
          verbose mode, print processing details

  -d    --debug
          debug mode, print debug information

  -ll   --log-level  [l]evel: string constant
          (fatal, error, warn, info, debug, trace)
          use level l for the logger

  -lc   --log-config  [f]ilename: string
          use config file f for the logger
\endverbatim

\subsection dcmodify_input_options input options
\verbatim
input file format:

  +f    --read-file
          read file format or data set (default)

  +fo   --read-file-only
          read file format only

  -f    --read-dataset
          read data set without file meta information

  +fc   --create-file
          create file format if file does not exist

input transfer syntax:

  -t=   --read-xfer-auto
          use TS recognition (default)

  -td   --read-xfer-detect
          ignore TS specified in the file meta header

  -te   --read-xfer-little
          read with explicit VR little endian TS

  -tb   --read-xfer-big
          read with explicit VR big endian TS

  -ti   --read-xfer-implicit
          read with implicit VR little endian TS

parsing of odd-length attributes:

  +ao   --accept-odd-length
          accept odd length attributes (default)

  +ae   --assume-even-length
          assume real length is one byte larger

automatic data correction:

  +dc   --enable-correction
          enable automatic data correction (default)

  -dc   --disable-correction
          disable automatic data correction

bitstream format of deflated input:

  +bd   --bitstream-deflated
          expect deflated bitstream (default)

  +bz   --bitstream-zlib
          expect deflated zlib bitstream
\endverbatim

\subsection dcmodify_processing_options processing options
\verbatim
backup input files:

        --backup
          backup files before modifying (default)

  -nb   --no-backup
          don't backup files (DANGEROUS)

insert mode:

  -i    --insert  "[t]ag-path=[v]alue"
          insert (or overwrite) path at position t with value v

  -if   --insert-from-file  "[t]ag-path=[f]ilename"
          insert (or overwrite) path at position t with value from file f

  -nrc  --no-reserv-check
          do not check private reservations

modify mode:

  -m    --modify  "[t]ag-path=[v]alue"
          modify tag at position t to value v

  -mf   --modify-from-file  "[t]ag-path=[f]ilename"
          modify tag at position t to value from file f

  -ma   --modify-all  "[t]ag=[v]alue"
          modify ALL matching tags t in file to value v

erase mode:

  -e    --erase  "[t]ag-path"
          erase tag/item at position t

  -ea   --erase-all  "[t]ag"
          erase ALL matching tags t in file

  -ep   --erase-private
          erase ALL private data from file

unique identifier:

  -gst  --gen-stud-uid
          generate new Study Instance UID

  -gse  --gen-ser-uid
          generate new Series Instance UID

  -gin  --gen-inst-uid
          generate new SOP Instance UID

  -nmu  --no-meta-uid
          do not update metaheader UIDs if related
          UIDs in the dataset are modified

error handling:

  -ie   --ignore-errors
          continue with file, if modify error occurs

  -imt  --ignore-missing-tags
          treat 'tag not found' as success
          when modifying or erasing in files

  -iun  --ignore-un-values
          do not try writing any values to elements
          having a VR of UN
\endverbatim

\subsection dcmodify_output_options output options
\verbatim
output file format:

  +F    --write-file
          write file format (default)

  -F    --write-dataset
          write data set without file meta information

output transfer syntax:

  +t=   --write-xfer-same
          write with same TS as input (default)

  +te   --write-xfer-little
          write with explicit VR little endian TS

  +tb   --write-xfer-big
          write with explicit VR big endian TS

  +ti   --write-xfer-implicit
          write with implicit VR little endian TS

post-1993 value representations:

  +u    --enable-new-vr
          enable support for new VRs (UN/UT) (default)

  -u    --disable-new-vr
          disable support for new VRs, convert to OB

group length encoding:

  +g=   --group-length-recalc
          recalculate group lengths if present (default)

  +g    --group-length-create
          always write with group length elements

  -g    --group-length-remove
          always write without group length elements

length encoding in sequences and items:

  +le   --length-explicit
          write with explicit lengths (default)

  -le   --length-undefined
          write with undefined lengths

data set trailing padding (not with --write-dataset):

  -p=   --padding-retain
          do not change padding (default if not --write-dataset)

  -p    --padding-off
          no padding (implicit if --write-dataset)

  +p    --padding-create  [f]ile-pad [i]tem-pad: integer
          align file on multiple of f bytes and items on
          multiple of i bytes
\endverbatim

\section dcmodify_private_tags PRIVATE TAGS

There are some issues you have to consider when working with private tags.
However, the insertion or modification of a reservation tag (gggg,00xx) should
always work.

\subsection dcmodify_private_insertions Insertions

If you wish to insert a private tag (not a reservation with gggg,00xx), be
sure, that you've listed it in your dictionary (see
<em>\<docdir\>/datadict.txt</em> for details).  If it's not listed, \b dcmodify
will insert it with VR=UN. Also, for some cases insertion may even fail for
some values.

If you've got your private tag in the dictionary, \b dcmodify acts as follows:
When it finds a reservation in the tag's enclosing dataset, whose private
creator matches, insertion is done with the VR found in the dictionary and the
value given on command line.  But if the private creator doesn't match or none
is set, \b dcmodify will return with an error.  If a private tag should be
inserted regardless whether a reservation does not exist, the option \e -nrc
can be used, forcing an insertion.  However, the VR is set to UN then, because
the tag then cannot be found in the dictionary.

See description above how inserting values into elements with unknown VR
are handled.

\subsection dcmodify_private_modifications Modifications

If you modify a private tags value, \b dcmodify won't check its VR against the
dictionary.  So please be careful to enter only values that match the tag's VR.

If you wish to change a private tags value \e and VR, because you just added
this tag to your dictionary, you can delete it with \b dcmodify and re-insert
it.  Then \b dcmodify uses your dictionary entry to determine the right VR
(also see subsection insertions).

Also, see description above how inserting values into elements with unknown VR
are handled.

\subsection dcmodify_private_deletions Deletions

When you use \b dcmodify to delete a private reservation tag, please note that
\b dcmodify won't touch the private tags that are under this reservation.  The
user is forced to handle the consistency between reservations and their
associated private tags.

For the deletion of private non-reservation tags there are no special issues.

\section dcmodify_changing_uids CHANGING UIDS

\b dcmodify will automatically correct 'Media Storage SOP Class UID' and
'Media Storage SOP Instance UID' in the metaheader, if you make changes to the
related tags in the dataset ('SOP Class UID' and 'SOP Instance UID') via
insert or modify mode options.  You can disable this behavior by using the
\e -nmu option.

If you generate new UID's with \e -gst, \e -gse or \e -gin, this will only
affect the UID you chose to generate.  So if you use \e -gst to generate a
new 'Study Instance UID', then 'Series Instance UID' and 'SOP Instance UID'
will not be affected!  This gives you the possibility to generate each value
separately.  Normally, you would also modify the 'underlying' UIDs.  As a
disadvantage of this flexibility, the user has to assure, that when creating
'new' DICOM files with new UIDs with \b dcmodify, other UIDs have to be updated
by the user as necessary.

When choosing the \e -gin option, the related metaheader tag ('Media Storage
SOP Instance UID') is updated automatically.  This behavior cannot be
disabled.

When working on multiple input files, \b dcmodify processes each file
in isolated fashion, i.e. it will generate UIDs for each single file.  For
example, when using the \e -gst option, \b dcmodify will insert a different
Study Instance UID into each file instead of generating a single one and
writing it to each file that is being processed.

\section dcmodify_creating_new_files CREATING NEW FILES

Option \e --create-file lets \b dcmodify create a file if it does not already
exist on disk. This can be used in order to create files from scratch by
performing consecutive insertions with options like \e --insert. This might
especially become handy when creating query files for tools like \b findscu or
\b movescu. In case no specific output transfer syntax is defined, \b dcmodify
chooses Little Endian Explicit Uncompressed for output. Files that are newly
created are always written as DICOM file format, i.e. option \e --write-dataset
is not permitted together with \e --create. This way, at least the metaheader
is written and no file with zero byte length is created in a case where no
insertions are performed in the \b dcmodify call.

\section dcmodify_element_values_from_file ELEMENT VALUES FROM FILE

In order to read the element value from a file instead of specifying it on the
command line, option \e -mf and \e -if can be used.  Please note that for OW
elements, the data is expected to be little endian ordered and will be swapped
if necessary.  The file size should always be an even number of bytes, i.e. no
automatic padding is performed.

\section dcmodify_wildcards WILDCARDS

\b dcmodify also permits the usage of a wildcard character "*" for item numbers
in path expressions, e.g. "ContentSequence[*].CodeValue" selects all "Code
Value" attributes in all items of the ContentSequence.  Using a wildcard is
possible for all basic operations, i.e. modifying \e -m, inserting \e -i and
\e -e options which makes it, together with the automatic creation of
intermediate path nodes a powerful tool for construction and processing complex
datasets.

The options \e -ma and \e -ea for modifying or deleting all occurrences of a
DICOM element based on its tag do not accept any wildcards but only work on
single elements (i.e. a single dictionary name or tag key).

\section dcmodify_examples EXAMPLES

\verbatim
-i   --insert:
       dcmodify -i "(0010,0010)=A Name" file.dcm
       Inserts the PatientName tag into 'file.dcm' at 1st level.
       If tag already exists, -i will overwrite it!  If you want to
       insert an element with value multiplicity > 1 (e.g. 4) you
       can do this with: dcmodify -i "(0018,1310)=1\\2\\3\\4"

       dcmodify -i "(0008,1111)[0].PatientName=Another Name" *.dcm
       Inserts PatientName tag into the first item of sequence
       (0008,1111).  Note that the use of wildcards for files is
       possible.  You can specify longer tag paths, too (e.g.
       "(0008,1111)[0].(0008,1111)[1].(0010,0010)=A Third One").
       If any part of the path, e.g. the sequence or the item "0"
       does not exist, it is automatically inserted by dcmodify.

       dcmodify -i "(0008,1111)[*].PatientName=Another Name" *.dcm
       Inserts PatientName tag into _every_ item of sequence
       (0008,1111).  Note that the use of wildcards for files is
       possible.  You can specify longer tag paths, too (e.g.
       "(0008,1111)[*].(0008,1111)[*].(0010,0010)=A Third One").

-if  --insert-from-file:
       dcmodify -if "PixelData=pixel.raw" file.dcm
       Inserts the content of file 'pixel.raw' into the PixelData element
       of 'file.dcm'.  The contents of the file will be read as is.
       OW data is expected to be little endian ordered and will be
       swapped if necessary.  No checks will be made to ensure that the
       amount of data is reasonable in terms of other attributes such as
       Rows or Columns.

-m   --modify:
       dcmodify -m "(0010,0010)=A Name" file.dcm
       Changes tag (0010,0010) on 1st level to "A Name".

       This option also permits longer tag paths as demonstrated above
       for -i. If the leaf element or any intermediate part of the path
       does not exist, it is not inserted as it would be if using the
       '-i' option.

       dcmodify -m "(0010,0010)=A Name" -imt file.dcm
       Changes tag (0010,0010) on 1st level to "A Name". Due to the given
       option '-imt', success is returned instead of "tag not found", if
       the element/item (or any intermediate node in a longer path) does
       not exist.

       Note that for the '-m' option the last node in the path must be a
       leaf element, i.e. not a sequence or an item.

-mf  --modify-from-file:
       dcmodify -mf "PixelData=pixel.raw" file.dcm
       Does the same as -if in case there was already a PixelData element
       in 'file.dcm'.  Otherwise nothing is changed.

-ma  --modify-all:
       dcmodify -ma "(0010,0010)=New Name" file.dcm
       Does the same as -m but works on all matching tags found in
       'file.dcm'.  Therefore, it searches the whole dataset including
       sequences for tag (0010,0010) and changes them to "New Name"

-e   --erase:
       dcmodify -e "(0010,0010)" *.dcm
       Erases tag (0010,0010) in all *.dcm files at 1st level.

       This option also allows longer tag paths as demonstrated
       above for -i.

       dcmodify -e "(0010,0010)" -imt *.dcm
       Erases tag (0010,0010) in all *.dcm files at 1st level. Due to the
       given option '-imt', success is returned instead of "tag not
       found", if the element/item (or any intermediate node in a longer
       path) does not exist.

-ea  --erase-all:
       dcmodify -ea "(0010,0010)" *.dcm
       Same as -e, but also searches in sequences and items.

-ep  --erase-private:
       dcmodify -ep *.dcm
       Deletes all private tags (i.e. tags having an odd group number)
       from all files matching *.dcm in the current directory.

-gst --gen-stud-uid:
       dcmodify -gst file.dcm
       This generates a new value for the StudyInstanceUID (0020,000d).
       Other UIDs are not modified!

-gse --gen-ser-uid:
       dcmodify -gse file.dcm
       This generates a new value for the SeriesInstanceUID (0020,000e).
       Other UIDs are not modified!

-gin --gen-inst-uid:
       dcmodify -gin file.dcm
       This command generates a new value for the SOPInstanceUID
       (0008,0018).  The corresponding MediaStorageSOPInstanceUID
       (0002,0003) is adjusted to the new value automatically.
       Please note that it's not possible to avoid this metaheader
       update via the -nmu option.

-nmu --no-meta-uid:
       dcmodify -m "SOPInstanceUID=[UID]" -nmu *.dcm
       This will modify the SOPInstanceUID to the given [UID], but -nmu
       avoids, that dcmodify adjusts the MediaStorageSOPInstanceUID in
       the metaheader, too.
\endverbatim

\section dcmodify_error_handling ERROR HANDLING

\b dcmodify tries executing each modify operation given on command line: If
one returns an error, the others are being performed anyway.  However in case
of any error, the modified file is not saved, unless the \e --ignore-errors
option is specified.  If that option is selected, \b dcmodify also
continues modifying further files specified on command line; otherwise
\b dcmodify exits after the first file that had modification errors.

If the \e --ignore-missing-tags option is enabled, any modify or erase
operations (i.e. not \e --insert) that fails because of a non-existing tag is
treated as being successful.  That does make sense if someone wants to be sure
that specific tags are not present in the file or that - if they exist - that
they are set to a specific value.

\section dcmodify_logging LOGGING

The level of logging output of the various command line tools and underlying
libraries can be specified by the user.  By default, only errors and warnings
are written to the standard error stream.  Using option \e --verbose also
informational messages like processing details are reported.  Option
\e --debug can be used to get more details on the internal activity, e.g. for
debugging purposes.  Other logging levels can be selected using option
\e --log-level.  In \e --quiet mode only fatal errors are reported.  In such
very severe error events, the application will usually terminate.  For more
details on the different logging levels, see documentation of module "oflog".

In case the logging output should be written to file (optionally with logfile
rotation), to syslog (Unix) or the event log (Windows) option \e --log-config
can be used.  This configuration file also allows for directing only certain
messages to a particular output stream and for filtering certain messages
based on the module or application where they are generated.  An example
configuration file is provided in <em>\<etcdir\>/logger.cfg</em>.

\section dcmodify_command_line COMMAND LINE

All command line tools use the following notation for parameters: square
brackets enclose optional values (0-1), three trailing dots indicate that
multiple values are allowed (1-n), a combination of both means 0 to n values.

Command line options are distinguished from parameters by a leading '+' or '-'
sign, respectively.  Usually, order and position of command line options are
arbitrary (i.e. they can appear anywhere).  However, if options are mutually
exclusive the rightmost appearance is used.  This behavior conforms to the
standard evaluation rules of common Unix shells.

In addition, one or more command files can be specified using an '@' sign as a
prefix to the filename (e.g. <em>\@command.txt</em>).  Such a command argument
is replaced by the content of the corresponding text file (multiple
whitespaces are treated as a single separator unless they appear between two
quotation marks) prior to any further evaluation.  Please note that a command
file cannot contain another command file.  This simple but effective approach
allows one to summarize common combinations of options/parameters and avoids
longish and confusing command lines (an example is provided in file
<em>\<datadir\>/dumppat.txt</em>).

\section dcmodify_environment ENVIRONMENT

The \b dcmodify utility will attempt to load DICOM data dictionaries specified
in the \e DCMDICTPATH environment variable.  By default, i.e. if the
\e DCMDICTPATH environment variable is not set, the file
<em>\<datadir\>/dicom.dic</em> will be loaded unless the dictionary is built
into the application (default for Windows).

The default behavior should be preferred and the \e DCMDICTPATH environment
variable only used when alternative data dictionaries are required.  The
\e DCMDICTPATH environment variable has the same format as the Unix shell
\e PATH variable in that a colon (":") separates entries.  On Windows systems,
a semicolon (";") is used as a separator.  The data dictionary code will
attempt to load each file specified in the \e DCMDICTPATH environment variable.
It is an error if no data dictionary can be loaded.

\section dcmodify_copyright COPYRIGHT

Copyright (C) 2003-2024 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.

*/