| Download | Install | Usage (1) (2) | How to | Problems | Limitations | Performances | ||||
| How to | ||||
Send me an email if you want me to add or create a new "How to" section that might be relevant for you or the other users. |
||||
| Understand output | ||||
| The default behavior of dicom2 is to process your files silently and display nothing but warnings and errors... Warnings (prefixed with [W]) are most of the time harmless and do not stop the conversion process, whereas errors (prefixed with [E]) do. It is possible to prevent these warnings from being displayed or even control many other output features by using the corresponding output options. | ||||
| Set default options | ||||
| Many default behaviours as well as default option-values
are used during the conversion process, but these might not fit your own
way to work. It is easy to redefine them, but you might getting tired of
always specifying the same destination directory (--to),
the same compression scheme (--compression),
the same control flags (--warn,
--rank), and so on. Put any
of your usual options in the DICOM2 environment variable, and
they will be used in every subsequent calls:
might be replaced by: No worry, you may still override these options by redefining them on the command-line (the first set of files will be written to c:\temp, the second to c:\temp2): The way you might set and save environment variables depends on your
operating system and your shell:
|
||||
| Convert to PNG, BMP, TARGA | ||||
| Fairly simple. dicom2 is a command-line driven program.Therefore,
it shall be called using a set of options and arguments specifying its
tasks. See Usage (1) and Usage
(2) pages for complete informations regarding these options.
Nevertheless, here are small examples: will convert the medical file knee.dcm to Windows's BMP format. The resulting file will be called knee.dcm.bmp. will convert all files with extension .dcm to TARGA and PNG formats. The .tga extension will be appended to the resulting TARGA files (respectively .png to the PNG files). |
||||
| Convert to raw (vtk) | ||||
| The Visualization
Toolkit (vtk for short) is a very powerful library that
"covers dozens of graphics and visualization techniques". It provides
functions to read 16 bits/pixel images (optionally preceeded by a header
of fixed length) and automatically swaps and masks 16 bits words if needed.
Unfortunately, the organization and the structure of the DICOM format is
far from that expected format: there is no fixed-length header, and pixel
data shall be "padded" (and optionally "cleaned") first to be usable. This
whole stuff may be carried out by the conversion to RAW (have a look
at the -r option for more explanations
and diagrams regarding the resulting pixel structure). Here is a simple
way to create these raw files using dicom2:
The --to=rawdir option is used to store the resulting files in the rawdir directory, although it might not be necessary as the .raw extension will be appended to each file. The --rank option might be useful if you plan to convert hundreds of files: it gives you a visual clue of the remaining files to process (in that situation you might use the --warn option too). |
||||
| Be aware that the vtk might be a bit demanding on
the syntax of the name of the raw files it uses... In the case where many
images should be read in the same time (and treated as a volume), these
names must be numbered (ex: ct-raw.1, ct-raw.2, ct-raw.3,
and so on). dicom2 may automagically append that kind of number,
or even build a much more sophisticated filename (including contents of
DICOM tags) by using a renaming pattern (see --rename).
will produce the files: test-1.raw test-2.raw test-3.raw |
||||
| You might also need some informations about the image,
especially if you are working on series. It is very easy, as you just have
to perform a TEXT conversion on the image or one of the element of the
series, and look for the corresponding field (see option -t
for more explanations, and the "How To: List
DICOM tags" section).
Slice Thickness (0018,0050) 1 DS [10.00] the value (within square brackets) is 10.0.
the pixel size is 0.859 mm in the horizontal dimension (columns), and the same along the vertical dimension (rows).
|
||||
| If you plan to use DICOM files to work on 3D reconstruction,
you will surely have to look at the vtkVolume16Reader
class. This class inherits the members of the more general vtkVolumeReader
class.
vtkVolume16Reader reader
|
||||
| List DICOM tags | ||||
| It might be interesting to list the contents of the data-set
stored in a DICOM file, in order to recover the most useful informations
in a human-readable form (the size of the image, the position of the patient,
the offset to the pixel data, and so on). Hence, you may use dicom2
to save a textual representation of this file (see option -t
for more explanations), where each element will be listed as [description,
tag, VM, VR, value]. But it might become a bit frustrating to create that
file, display it, and then remove it. Hopefully, this textual representation
might be redirected to the standard output:
..... Transfer Syntax UID (0002,0010) 1 UI [1.2.840.10008.1.2.1] Image Type (0008,0008) 1-n CS [ORIGINAL\PRIMARY] Study Date (0008,0020) 1 DA [1995.06.26] Image Date (0008,0023) 1 DA [1995.06.26] Study Time (0008,0030) 1 TM [11:20:00] Modality (0008,0060) 1 CS [MR] Manufacturer (0008,0070) 1 LO [Philips] Patient's Name (0010,0010) 1 PN [Doe John] Slice Thickness (0018,0050) 1 DS [10.00] Series Number (0020,0011) 1 IS [1] Image Number (0020,0013) 1 IS [103] Samples per Pixel (0028,0002) 1 US [1] Photometric Interpretation (0028,0004) 1 CS [MONOCHROME2] Number of Frames (0028,0008) 1 IS [16] Frame Increment Pointer (0028,0009) 1-n AT [(0018,1063)] Rows (0028,0010) 1 US [256] Columns (0028,0011) 1 US [256] Bits Allocated (0028,0100) 1 US [8] Bits Stored (0028,0101) 1 US [8] High Bit (0028,0102) 1 US [7] Pixel Representation (0028,0103) 1 US [0] Pixel Data (7FE0,0010) 1 OB [1048576 bytes at offset 1022 (0x3fe)] ..... You can make an alias (depending on your shell) to improve the overall
efficiency :)
You might extract a single element by using the grep filter
(which is a very common tool in the unix world, and is also available for
Windows when working on the command prompt). grep will search
for an expression in a file or in the data available on the standard input.
or,
or,
|
||||
| Generate subsets | ||||
| Dealing with hundred of files might become a very time
consuming task. Therefore, why not try to work with reduced data
before running the real job on full-sized images. Halving will achieve
this goal (see option --halve).
For example, one could build a 256x256 and a 64x64 set of DICOM files
from a 512x512 set of original DICOM files. As most options performs linearly,
it is obvious to see that dicom2 will carry out its tasks 4 (64)
times quicker on the 256x256 (respectively 64x64) set than on the 512x512
set.
|
||||
| Clean images (accumulate, mask, crop) | ||||
Typical images may exhibit more than the desired body-structures.
Artefacts, as well as parts of the bed may be hard to locate and tend to
produce undesirable effects (while using 3D reconstruction for example).
Moreover, the form and location of these artefacts might change within
a series of images, preventing the user from building a hypothetical mask
based on a single image of the series. A rudimentary but better approach
may be applied with some of the dicom2 functions.
![]() ![]() ![]() ![]() |
||||
AccumulateFirst of all, you shall compute which of the pixels are used along all images within the series (which is quite similar to an accumulation buffer representing the maximum occupancy of the structures). See option --acc for more explanations and diagrams.![]() ![]() The resulting DICOM file (which defaults to acc-max.dcm) shall
be converted to BMP, in order to be recognized by any painting program.
|
||||
MaskYou are now able to create a mask starting from this image, by attributing zero to the points that you want to save in each frame, and non-zero to these that you want to remove(set to 0). The mask will act like a kind of stencil: the zero-area being a "hole", the non-zero area covering the non-desired pixels. Have a look at the --mask option to get more coverage on the principles.![]() We are quite finished: let's build up the new masked images, which will be stored in the masked directory: ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||||
CropThe resulting images will exhibit more zeros than the original ones (as pixels from removed structures are set 0). Hence you might consider using the --crop option to save the relevant part of the image only, and speed-up further processes. The coordinates of the cropping-window might be computed from the mask, which explicitly shows which parts of the resulting image will remain, and which won't.The --crop and --mask options may be used in the same time (as --mask occurs first). Forget the previous call to dicom2 and speed up the process with: ![]() ![]() |
||||
Summary... create the mask using acc-max.bmp... |
||||
| Extract frames | ||||
| As the --frame
option has been enhanced since v1.5, it is now very easy to work on multiple-frame
files. Although dicom2 is able to read multi-frame files, you shall
not forget that its output is always made of single-frame files. Therefore,
you can not build multiple-frame files, but you can extract many
single-frame files from one multiple-frame file. See option --frame
to learn more about frame selection.
Let's have a look at some examples, using the file mframe, which stores 3 frames (you can use the -t1 option to find the number of frames):
|
||||
| Download | Install | Usage (1) (2) | How to | Problems | Limitations | Performances | ||||