Local tools
dicom3tools - toolkit from David Clunie
CTN - software package from RSNA/Mallinckrodt Institute
| dcm_convert | Convert DICOM image files into other formats |
| dcm_unconvert | Recreate DICOM image files |
| dcm_move, dcm_movegui | Rename and move DICOM files |
| send_dicom† | Send DICOM images to DICOM server |
| dcmls† | List DICOM files with selected header info |
| dcminfo† | Show selected DICOM header inof for one or more files |
Note: This program was written to handle images from a Philips ACS/NT scanner. Many features are aimed at those images. It may also work for GE Signa and Siemens images but more testing is required. It is not for use with MR or CT Enhanced DICOM images.dcm_convert -h
If the optional -f switch (see below) is not used on the command line, the DICOM images must be in the current directory, or in a subdirectory of the current directory named MR or named any number 1 through 99. MR is the default name used by simple_storage when images are not redirected or when they are redirected using "#-#". Numbered directories are generated by simple_storage when images are redirected using "#a#" or "#s#" or when dcm_move is used to rename dicom files.
A series menu will be presented showing all dicom series found in the current, the MR and the numbered directories below the current working directory. Each line in the menu is numbered in the left column. You are prompted to enter the number of one series to be converted. After conversion, the menu is shown again and you can select another series. Any series you convert will appear in subsequent menus with an asterisk (*) below the selection number (like #1 in the example below). Enter just return when you are done to exit dcm_convert.
Example menu
Studies found:
--------------------------------------------------------------------------------
# |Physician |Identity |Name |Date |Time |Cols|Rows|Slic|Dyn |
|Description |
--------------------------------------------------------------------------------
1| |1232 |Hartford,J|04/26/2000|09:45:31.800| 256| 256| 12| 2|
*|MOSER se no filter TRA SE 504 25 90 |
--------------------------------------------------------------------------------
2| |1232 |Hartford,J|04/26/2000|09:31:39.790| 256| 256| 12| 2|
|Stability T1W/SE/no TRA SE 504 25 90 |
--------------------------------------------------------------------------------
3| |1232 |Hartford,J|04/26/2000|09:38:52.580| 256| 256| 12| 2|
|Stability T1W/SE/yes TRA SE 504 25 90 |
--------------------------------------------------------------------------------
Number (1-3) [done] ->
This method is faster than the above since all images in the directory do not have to be read to determine their series and image numbers. But most UIDs do not contain the needed information anymore - old Philips ACS/NT UID's did when this was written. This method can be used for images renamed using dcm_move.
A single series of DICOM images can be selected for conversion on the command line. The names must fit a pattern that can be defined using a C programming language "sprintf" format. You can see more about sprintf formats in the sprintf manpage (use "man sprintf" in a terminal window).
This format contains the parts of the image names that are constant for all slices and all dynamics and a conversion specifier where the changing numbers appear that represent the slice and dynamic numbers. The usual conversion specifier is %d which converts an integer into it's decimal representation without leading blanks or zeroes. The format specifier is used in dcm_convert with two integer arguments: i and j where i is a slice number and j is a dynamic number to step through all your DICOM images.
The format can include a path as well if the DICOM files are not in the current directory.
example (using Philips ACS/NT UID named images):
-f 1.3.46.670589.11.5406.9.955073100000002870201.%d.1.1.%d.0.41image names that match:
| slice 1 dyn 1: | 1.3.46.670589.11.5406.9.955073100000002870201.1.1.1.1.0.41 |
| slice 1 dyn 2: | 1.3.46.670589.11.5406.9.955073100000002870201.1.1.1.2.0.41 |
| slice 2 dyn 1: | 1.3.46.670589.11.5406.9.955073100000002870201.2.1.1.1.0.41 |
| slice 12 dyn 145: | 1.3.46.670589.11.5406.9.955073100000002870201.12.1.1.145.0.41 |
example (using images renamed by dcm_move -f) note: the conversion specifier %03d means 3 digit long decimal integer padded with leading zeroes:
-f 01284.003.%03d.%03dimage names that match (this was exam id 1284, series 3):
slice 1 dyn 1,2,3: 01284.003.001.001 01284.003.001.002 01284.003.001.003
slice 2 dyn 1,2,3: 01284.003.002.001 01284.003.002.002 01284.003.002.003
| -d | delete DICOM input files after conversion |
| -dyn | override number of dynamics specified in dicom header. This is used only with the -f option. |
| -f | C sprintf format specifier for the input file name (see above). |
A Mayo Clinic Analyze compatible header file is made describing the data. It has a .hdr file extension. Info from the DICOM header is put into all appropriate fields of the Analyze header (specifications).
Additionally a file is created with file extension .dcm containing all image DICOM headers concatenated together (specifications). This file along with the .img and .hdr files permits the original DICOM images files to be recreated using the dcm_unconvert program. This allows users to safely delete the original DICOM files. You can also feed this file to dcm_dump_file or dcm_dump_element to display DICOM header elements from the first (slice 1, dynamic 1) header.
A single Mayo Clinic Analyze compatible header file is made describing the data named with extension .001.hdr. Links are made to this file for all other time points with names .002.hdr, .003.hdr, etc. This header file therefore consumes only the space of the single original file but has multiple names.
The concatenated DICOM header file (.dcm) is also created. The -n switch cannot be combined with -a.
A Mayo Clinic Analyze compatible header file (.hdr) and concatenated DICOM header file (.dcm) are also made. These would be needed if the original DICOM images were to be recreated using dcm_unconvert. The -a switch cannot be combined with -n.
| -o |
The argument following -o specifies the output filename root.
This
name is prepended to the filename extensions of all output files
created
by dcm_convert. This root can include pathname elements to store the
output
files outside to current directory. The destination directory must
already
exist.
Using the series menus you will be prompted for an output file root, if you don't specify one on the command line or the one specified already exists . You will always be prompted for series selected beyond the first one. Using the -f switch, if you don't specify a output file root on the command line, the name "output" will be used. If a file specified or the default already exists, an error message will be displayed. |
| -a | AFNI format output. |
| -n | 3D Analyze format for FIDAP. |
Binary: Solaris2
This program will recreate all the individual DICOM images files in a series using the 4D or 3D image data file (.img, .<nnn>.img or .BRIK), the concatenated DICOM header file (.dcm) and optionally the Analyze header file (.hdr) made by dcm_convert. The switches -a and -n indicate that the input image data is in 3D Analyze (-n) or AFNI (-a) format. If neither switch is present, 4D Analyze is assumed.dcm_unconvert -h
The Analyze .hdr file is needed only to determine the dimensions of the image data. If the dimensions are specified on the command line using the -d switch, unconversion can proceed without the .hdr file.
| -a | AFNI format input. |
| -n | 3D Analyze format input. |
| -d | Image dimensions x (columns), y (rows), z (slices), t (time points) separated by colons. |
Binary: included with dcm_convert
dcm_move [-s <source-dir>] [-R] [-m modality] -u [<destdir>]
dcm_movegui
dcm_move will read DICOM imagesthen rename and move them based on the stored study number, acquisition number, slice number and possibly dynamic, echo or phase number. There are command line switches to control the source and destination of the image files, and the format of renaming. dcm_movegui has the same features as dcm_move but they are accessed through the graphic user interface shown to the right. There is a direct correspondence between the fields of the GUI and the command-line switches.
Command-line switches:
| Input Switches | |
| -s <sourcedir> | dicom source directory, default: present working directory |
| -R | recurse into all sub-directories of source-dir, default: source dir only |
| -a | process all source files found, default: prompt for each study |
| -m <modality> | check only the named DICOM modality sub-dir, default is all (MR CT US USMF CR NM SC) |
| Output Switches | |
| -c | copy files leaving originals, default: move to another dir |
| -r | rename in place (implies flat names -f), default: move to another dir |
| <destdir> | is the writable & searchable destination directory, default is present working directory |
| -i | no info file created |
| -l | ignore location in header, default: move to location in header if found |
| -f | flat names mode, default: hierarchical |
| -u | unmove - use SOP Instance UID for names |
| -d | add .dcm to output filenames, useful for some Windows apps |
| -n | no echo/phase/dynamic breakdown |
Images are renamed according to the study, series and slice number found in the dicom header. If images are Philips dynamic images, they are renamed according to the study, series, slice and dynamic number. If images are GE cardiac multiphase images, they are renamed according to study, series, slice and phase number. If a file has an invalid dicom header it is moved to a directory named "bad". The program dcm_dump_file from the CTN package is used to read Dicom header information.
Without the flat switch images are stored in a hierarchy of directories and files, named from top, using a directory with the study number, then directory with series number, then a file with the slice number. If the study has multiple dynamics (echoes or phases) the slice number and dynamic (echo or phase) number will be used in the file name.
When -n is specified, series with multiple dynamics or phases (time points) are treated like anatomic series. The images are numbered using the image number provided in the Dicom header. It increments through time points for each slice (i.e. first all time points for slice 1, then all time points for slice 2, etc.). The highest image number is number of slices * number of time points.
hierarchical (no -f ) for an anatomic series (i.e. no dynamics/multiphase):
flat (-f) for anatomic series:images are stored in the destination directory in a directory named using the exam number in a directory named using the 3 digit series number in a file using <3 digit slice>.<4 digit dynamic number> example: /g1/smith/subj1/17543/002/001.0124
If the Patient History field in the header contains #-#<directory> and <directory> exists and is writable and searchable the images will be moved to that <directory> rather than the one named on the command line (or the default). Use -l on the command line to ignore this stored tag.
Without -i, a file named "info" is created in each series directory containing some identifying information about the study, patient and series. Use the -i command line switch to suppress creation of this file. PHI/HIPAA Warning: the info file may contain the patient's name or other private information.
| -d | Max delay, default is 0.5 second. |
| -a | Local host's AE title, default is godzilla2. |
| -c | Remote host name or IP address of destination, default MR1. |
| -p | Remote dicom port, default 3010. |
| -r | Remote host's dicom AE title, default MR1. |
| <dicom file> | One or more DICOM images to send |
This script will send the specified DICOM images to a DICOM server. The local AE Title is usedin the DICOM association. The remote system's AE Title, port and host name or IP address must be specified.
If multiple images are beiing sent a delay is used between each send to try to prevent transfer errors.. The delay starts at 0 and increases by 0.1 sec each time an error occurs up to the max-delay. Failed transfers will be retired 3 times. At the end of all transfers the script will list how many images were successful and failed.
Links to this script with the names of our local scanners allow transfer to these systems without supplying the AE Titles, destination port and name or address.
The script will use either CTN send_image for standard DICOM files or DCMtk storescu for enhanced DICOM images. Do not mix standard and enhanced files in one command since this detection is done only once.
Binaries: Solaris2 NT gzipped
test image zipped
test image
dcmls acts much like the Unix "ls -lR" command, listing files recursively in long format with permissions, owner, group, size, access date and name. If the file is DICOM format, it also lists a selection of DICOM header fields: SeriesDate, SeriesTime, StudyDescription, SeriesDescription, PatientName, PatientID, ProtocolName, SeriesNumber and PerformedProceduresStepDescription.
dcminfo -l [-k] dicom-file
dcminfo -a dicom-file
First form will list selected dicom tags for one or more dicom files. If multiple files are specified, the tags with the same value for all files are listed first, then tags which are different in one or more files are listed in a table.
Additional tags can be added to the pre-defined list (see below). The selected files can optionally be renamed using their series number.
| -r | rename scanned dicom files using series number |
| -t | additional tags to display - use colon separated names from dcminfo -l |
| -w | maximum width of displayed data table - default 200 |
| -f |
full dicom read - without this switch only the first 20k bytes of the dicom file is read. Most parameters of interest are in this part and the time to read is greatly decreased. |
Second form lists all dicom fields names for one file sorted by the numeric tag. Adding -k will sort by the key name. Either the key name or numeric tag can be used with -t in first form. For numeric tags specify tow four digit number separated by comma (e.g. 0008,0031).
| -l | list all dicom tags in the dicom-file |
| -k | sort by key name rather than by numeric tag |
Third form will list all fields from one file in a cleaner format than provided by dcmdump. Field name is first, indented 2 spaces for each sequence or item key. Private field name are preceeded by dot . to make it clear they are vendor private fields. The field nasme is followed by 2 colons to make parsing easy, followed by the value in the original format used by dcmdump. Strings are surrounded by square barckets [], sequence and item delimiters are surrounded by braces (), integer and floats are bare, array elements are separated by backslash \. For long items like Pixel Data, the first few elements are shown with ... at then end to indicate the value is truncated.
| -a | list all dicom elements for one file |
Pre-defined tags for the first form are:
You can create a ~/.dcminforc file with a set of preferred tags that will override the default pre-defined tags listed above. You can also override the default table width. File format:
Tags <tag1> <tag2> <tag3> ... MaxWidth <number>
| ancp | Copy ACR-NEMA file |
| ancreate | Create dicom file |
| andiff | |
| andump | Describe ACR-NEMA file content |
| antodc | Convert ACR-NEMA to DICOM |
| binpatch | |
| bmpdump | |
| dcacqmap | Create visual map of acquisition pattern |
| dcarith | Arithmetic on DICOM pixels |
| dcbriggs | Create DICOM Briggs pattern |
| dcburn | |
| dccomb | |
| dccp | Copy DICOM file |
| dcdecmpr | |
| dcdict | Extract dictionary elements |
| dcdirdmp | Describe DICOMDIR content |
| dcdirmk | Create DICOMDIR |
| dcdisp | Display file on X window |
| dcdtchg | Change UIDs consistently |
| dcdump | Describe DICOM file content |
| dcencap | Encapsulate compressed stream in a DICOM file |
| dcfile | Describe DICOM file content |
| dchist | DICOM image statistics |
| dcintro | Introduction and options |
| dciodvfy | Describe DICOM objects |
| dckey | Extract attribute values |
| dclutburn | |
| dclutdmp | dump LUT contents |
| dclutmix | |
| dcmerge | Merge DICOM files |
| dcmkpres | Create DICOM presentation state |
| dcmulti | Make multiframe image from single frames |
| dcortho | |
| dcostosr | |
| dcpatmpl | Apply patient and study template |
| dcposn | DICOM locate position |
| dcpost | |
| dcproj | |
| dcrmmeta | Remove meta information header |
| dcsmpte | Create DICOM SMPTE pattern |
| dcsort | Make sorted list of images |
| dcsqextr | Extract Papyrus images |
| dcsrdump | |
| dcsrmrg | |
| dcstats | DICOM image statistics |
| dcsub | |
| dctable | Make tables of attribute values |
| dctopdf | Extract DICOM encapsulated PDF |
| dctopgm8 | |
| dctopgx | DICOM image to PGX file |
| dctopnm | DICOM image to PNM file |
| dctoraw | DICOM image to raw file |
| dcuidchg | Change UIDs consistently |
| dcuncat | Split multiframe image into concatenation |
| dcunmeta | Remove DICOM Metaheader |
| dumptiff | |
| dumpwhat | |
| gawdump | GE Advantage Windows to DICOM |
| gawtodc | GE Advantage Windows to DICOM |
| ge98id | GE 9800 dump identifiers |
| ge98topgm | GE 9800 image to PGM file |
| gendump | Genesis dump contents |
| gentodc | Genesis to DICOM |
| gentopgm | Genesis ximg file to PGM file |
| himrdump | himr dump contents |
| himrtodc | himr to DICOM |
| himrunid | |
| imtndump | Imatron dump contents |
| imtntodc | Imatron to DICOM |
| jpegdump | |
| jpegsplit | |
| pacedump | GE PACE dump contents |
| pacetodc | GE PACE to DICOM |
| pacetopgm | GE Pace image to PGM file |
| paceunid | paceunid (1) - PACE remove identification |
| pbmswbit | |
| pbmtoovl | Create DICOM Overlay from PBM file |
| pdftodc | Encapsulate PDF in DICOM |
| pgmtobmp | |
| pgxtodc | Create DICOM from PGX file |
| pnmpred | |
| pnmtodc | Create DICOM from PNM file |
| pnmtoraw | |
| pqdump | pq dump contents |
| pqsplit | |
| pqtodc | pq to DICOM |
| rawarith | |
| rawdiff | |
| rawftodc | Create DICOM from raw float file |
| rawmask | |
| rawnjl | |
| rawnjl2 | JPEG-LS compress/decompress from raw file |
| rawtodc | Create DICOM from raw file |
| sgndump | Signa dump contents |
| sgntodc | Signa to DICOM |
| shimdump | Imatron dump contents |
| shimtodc | Imatron to DICOM |
| sompdump | somp dump contents |
| somptodc | somp to DICOM |
| syttopgm | GE Sytec image to PGM file |
| toshtodc | Convert separate Toshiba ACR-NEMA header and raw pixel data files to DICOM |
| vsntopgm | Vision image to PGM file |
| dcm2pnm | Convert DICOM images to PPM/PGM, PNG, TIFF or BMP |
| dcm2xml | Convert DICOM file and data set to XML |
| dcmcjpeg | Encode DICOM file to JPEG transfer syntax |
| dcmconv | Convert DICOM file encoding |
| dcmcrle | Encode DICOM file to RLE transfer syntax |
| dcmdjpeg | Decode JPEG-compressed DICOM file |
| dcmdrle | Decode RLE-compressed DICOM file |
| dcmdspfn | Export standard display curves to a text file |
| dcmdump | Dump DICOM file and data set |
| private.dic | Private DICOM dictionary locally with added Philips fields |
| dcmftest | Test if file uses DICOM part 10 format |
| dcmgpdir | Create a general purpose DICOMDIR |
| dcmj2pnm | Convert DICOM images to PGM, PPM, BMP, TIFF or JPEG |
| dcmmkcrv | Add 2D curve data to image |
| dcmmkdir | Create a DICOMDIR file |
| dcmmklut | Create DICOM look-up tables |
| dcmodify | Modify DICOM files |
| dcmp2pgm | Read DICOM image and presentation state and render bitmap |
| dcmprscp | DICOM basic grayscale print management SCP |
| dcmprscu | Print spooler for presentation state viewer |
| dcmpschk | Checking tool for presentation states |
| dcmpsmk | Create DICOM grayscale softcopy presentation state |
| dcmpsprt | Read DICOM images and presentation states and render print job |
| dcmpsrcv | Network receive for presentation state viewer |
| dcmpssnd | Network send for presentation state viewer |
| dcmqridx | Register a DICOM image file in an image database index file |
| dcmqrscp | DICOM image archive (central test node) |
| dcmqrti | The Terminal Initiator Telnet Client Program |
| dcmquant | Convert DICOM color images to palette color |
| dcmscale | Scale DICOM images |
| dcmsign | Sign and Verify DICOM Files |
| dcod2lum | Convert hardcopy characteristic curve file to softcopy format |
| dconvlum | Convert VeriLUM files to DCMTK display files |
| dsr2html | Render DICOM SR file and data set to HTML |
| dsr2xml | Convert DICOM SR file and data set to XML |
| dsrdump | Dump DICOM SR file and data set |
| dump2dcm | Convert ASCII dump to DICOM file |
| echoscu | DICOM verification (C-ECHO) SCU |
| findscu | DICOM query (C-FIND) SCU |
| movescu | DICOM retrieve (C-MOVE) SCU |
| pdf2dcm | Convert PDF file to DICOM |
| storescp | DICOM storage (C-STORE) SCP |
| storescu | DICOM storage (C-STORE) SCU |
| termscu | DICOM termination SCU |
| wlmscpfs | DICOM Basic Worklist Management SCP (based on data files) |
| xml2dcm | Convert XML document to DICOM file or data set |
| xml2dsr | Convert DICOM SR file and data set to XML |
| dcm_dump_file | Display contents of DICOM image header |
| dcm_dump_element | Display a DICOM image header element |
| dcm_x_disp/dcm_w_disp | Quick display of DICOM image |
| dcm_move | Rename and move DICOM image files |
| dcm_count | Count number of images in DICOM directory by series |
| dcm_combine | Combine multi NEX series into single series |
| dcm_study | Show study number of DICOM image |
| send_image | Send an image to a DICOM server |
| simple_storage | DICOM server daemon |
| runDicom | Daemon to keep simple_storage running |
| Full Downloads | All programs in gzipped tar file or zip file |
| -b | Input files are stored in big-endian byte order |
| -e | Exit on file open error. Do not process other files |
| -g | Remove group length elements |
| -l | Use (retired) length-to-end attribute for object length |
| -t | Part 10 file |
| -v | Place DCM facility in verbose mode |
| -z | Perform format conversion (verification) on data in files |
|
file |
One or more information objects to be dumped |
| -b | Read file assuming big endian transfer syntax |
| -t | Read file assuming DICOM Part 10 format |
| -v | Place DCM facility in verbose mode |
|
group element |
The tag of the element to be dumped |
| filein fileout | Input and output files |
| -b | Read file assuming big endian transfer syntax |
| -t | Read file assuming DICOM Part 10 format |
Binaries: (dcm_x_disp) Solaris2
(dcm_w_disp) NT
| -a | Abort Association after receiving one image (debugging tool) |
| -c | Set the AE title of this server |
| -d | Place one facility (DCM, DUL, SRV) in verbose mode |
| -f | Fork a new process for each connection |
| -i | Ignore some incorrect parameters in Association request |
| -j | Use thread model. Spawn a new thread for each connection |
| -k | Kill (delete) files immediately after they are received |
| -l | Log stdout and stderr to named log file (JHU addition) |
| -m | Set the maximum received PDU in the Association RP to maxPDU |
| -n | <naming> contains naming convention for files stored |
| -p | Dump the Association RQ parameters |
| -s | Silent mode. Don't dump attributes of received images |
| -t | Execute the main loop trips times (debugging tool) |
| -u | Run as this alternate uid when not running as root (JHU addition) |
| -v | Place DUL and SRV facilities in verbose mode |
| -w | Wait flag. Wait for 1 second in callback routines (debugging) |
| -x | Set base directory for image creation. Default is current directory |
| -z | Wait for sec seconds before releasing association |
| port | The TCP/IP port number to use |
If command line switches are provided, they are used when starting simple_storage, unless the first switch is one of the following:
| -help | prints this message |
| -kill | kills runDicom and simple_storage |
| -restart | kills runDicom and simple_storage, then restarts both |
If no command line switches for simple_storage are given on the command line, runDicom looks for the file /usr/local/sbin/runDicom.<hostname>, where <hostname> is the name returned by the gethostname system call. That file must contain valid switches and switch parameters for simple_storage, one switch or parameter to a line. For example:
-lIf that file does not exist, the following switches are used for starting simple_storage:
/tmp/simple_storage.log
-s
-c
DICOM_STORAGE
-u
600
-f
-x
/g1/dicom
3010
-l /tmp/simple_storage.log -s -f -c DICOM_STORAGE -u 0 3010runDicom logs starts and shutdowns of simple_storage in the file /tmp/simple_storage.log. This same file can be used for simple_storage
Source & Binary: Solaris2
Solaris 2.x binaries and shell scripts in a gzipped tar file
Windows
NT binaries in a zip file
libctn.so CTN dynamic library