also see the dicom2 converter page for freeware.

How to prepare a DICOM volume for use in Vtk by using dicom2



1. Put all of the data files into an empty directory.
At a terminal, run these commands:

> mkdir data
> mv filename data/*
2. Reformat file names.
Since dicom2 can only process DICOM files with a specific type of file name that indicates slice ordering, it is necessary to run a script that modifies the file names to fit this structure. This structure consists of <filePrefix><filePattern>, where filePrefix is anything before the number and filePattern is the portion of the file name after the filePrefix and number (Ex: %s%d.raw). For example, in the file name "mummy-5.raw", the filePrefix would be "mummy-" and the filePattern would be ".raw".

Compile and run the script numberfiles.c in the directory where the DICOM slice files are located. You'll probably have to fiddle with the script to get it to produce files of the proper format.

Your slices should be numbered consecutively beginning with startSlice (lowest file number) and ending with endSlice (highest file number).
3. Make a new directory for the .raw data files to go to.
> mkdir rawdata
4. Convert the data files into .raw data files.
You can use special flags to instruct dicom2 to convert your DICOM data to .raw data for use in Vtk. Raw data may be written using Little (-r0) or Big (-r1) endian syntax. If you don't know the difference, use -r0. In the directory above your data directory, run this command:

> dicom2 --to=rawdata -r0 data/*

You should see output that looks like this:

[W] [16:12:26]
bool convert_file( const sbcFileName&, constsbcCmdLineParser& )
Pixel Representation 1 <> 0 ! You might consider --changepr if any problems.
5. Get the Pixel Spacing info from an original data file.
Run this command:

> dicom2 -t1 data/file-1 | grep -i "pixel spacing"

You should see output that looks like this:

Pixel Spacing (0028,0030) 2 DS [7.421875e-01\7.421875e-01]
                                                        pixelSizeX     pixelSizeY
6. Get the Slice Thickness/Zspacing info from an original data file.
Run this command:

> dicom2 -t1 data/file-1 | grep -i "slice thick"

You should see output that looks like this:

Slice Thickness (0018,0050) 1 DS [3.0]
                                                  Zspacing
7. Get the row (volume x-demension) info from an original data file.
< Run this command:

> dicom2 -t1 data/file-1 | grep -i "row"

You should see output that looks like this:

Rows (0028,0010) 1 US [512]
                                         rows
8. Get the column (volume y-demension) info from an original data file.
Run this command:

> dicom2 -t1 data/file-1 | grep -i "column"

You should see output that looks like this:

Columns (0028,0011) 1 US [512]
                                            columns
9. Pick a dataValue for displaying the volume.
Pixels with a value ranging from 0 to max will be visualized. If you don't know the pixel values of your data, use 100 (this is a good value for most CT scans).


SAMPLE XML-VOLUME (using the values above)

For an example of how this should look in XML format, see the rawVolume element in sceneTags.txt (a text file containing sample XML). Search for "rawVolume".


Last modified: Tue Jan 6 15:13:29 MST 2004