DICOM: Difference between revisions
No edit summary |
|||
| Line 37: | Line 37: | ||
All of these can be launched non-interactively with <tt>matlabLauncher.py</tt>. | All of these can be launched non-interactively with <tt>matlabLauncher.py</tt>. | ||
== Matlab == | == Handling DICOMs == | ||
=== Matlab === | |||
Matlab has [http://www.mathworks.com/company/newsletters/digest/nov02/dicom.html extensive built-in support] for DICOM header and image data I/O with the [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicominfo.html <code>dicominfo</code>], [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicomread.html <code>dicomread</code>], and [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicomwrite.html <code>dicomwrite</code>] functions. This is nice for quickly creating DICOM processing scripts to be run manually, but Matlab is relatively slow and difficult to call from non-interactive scripts. Therefore it's encouraged to port Matlab code into another language (preferably C++ or Python) for inclusion in the [[diffusion processing pipeline]]. | Matlab has [http://www.mathworks.com/company/newsletters/digest/nov02/dicom.html extensive built-in support] for DICOM header and image data I/O with the [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicominfo.html <code>dicominfo</code>], [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicomread.html <code>dicomread</code>], and [http://www.mathworks.com/access/helpdesk/help/toolbox/images/dicomwrite.html <code>dicomwrite</code>] functions. This is nice for quickly creating DICOM processing scripts to be run manually, but Matlab is relatively slow and difficult to call from non-interactive scripts. Therefore it's encouraged to port Matlab code into another language (preferably C++ or Python) for inclusion in the [[diffusion processing pipeline]]. | ||
=== Python === | |||
A few Python libraries for handling DICOMs exist; these might be worth looking into: | |||
* [http://code.google.com/p/pydicom/ pydicom] --- a pure Python DICOM library | |||
* [http://dicomlib.swri.ca/pydicomlib.html pydicomlib] --- a Python wrapper around dicomlib, below | |||
=== C/C++ === | |||
* [http://gdcm.sourceforge.net/ GDCM] --- "Grassroots DICOM" library | |||
* [http://dicom.offis.de/dcmtk DCMTK] --- the DICOM toolkit library | |||
* [http://dicomlib.swri.ca/dicomlib.html dicomlib] --- Yet another DICOM library, written at Sunnybrook Health Sciences Centre, Toronto | |||
=== Java === | |||
* [http://santec.tudor.lu/project/optimage/dicom/start Tudor DICOM Tools] | |||
* [http://sourceforge.net/projects/dcm4che dcm4che] | |||
* [http://rsb.info.nih.gov/ij ImageJ] | |||
=== Tools === | |||
* [http://xmedcon.sourceforge.net medcon] --- Command-line tool for converting among tons of different medical image formats | |||
* [http://www.dclunie.com/dicom3tools.html DICOM3tools] --- Command-line tool for reading DICOM headers, written by a member of the DICOM standards committee | |||
== Useful Links == | == Useful Links == | ||
* [http://medical.nema.org The DICOM standards committee] | |||
* [http://medical.nema.org | |||
[[Category:Diffusion MRI]][[Category:File Formats]] | [[Category:Diffusion MRI]][[Category:File Formats]] | ||
Revision as of 02:38, 2 July 2009
Files ending in .ima or .dcm are in the DICOM medical image format. It is a widely used format that enjoyed great popularity but, in the diffusion MRI community at least, has been mostly superseded by NIfTI.
You can confirm that you're dealing with DICOM data by running the following two commands:
strings <SUSPECTED_DICOM_FILE> | grep -i "dicom" strings <SUSPECTED_DICOM_FILE> | grep -i "dcim"
If you get output, that means that the DICOM magic string shows up somewhere in the file. Another good indication that you're dealing with some sort of DICOM data is that your collaborator told you so.
Volumes as DICOMs
A single DICOM file stores only one 2-D image, and so various strategies exist for storing and transferring volumes and collections of volumes as DICOM images. Most commonly, you'll just get a directory full of dozens (if not hundreds or thousands) of .ima or .dcm files, each one storing a single slice. Some other strategies crop up from time to time, though, to represent a whole volume or a collection of volumes as a single file. If you have reason to believe that your data should be in DICOM format but they seem a little funky, they might be stored as a tarball or in "mosaic" format. Here are a couple clues that indicate you should consider these possibilities:
- Matlab or Medcon claims that your file is not a DICOM
- the file size is much larger than you'd expect for a single slice (which should be on the order of 100kB)
- the number of files is much lower than you'd expect for a collection of slices (hundreds or maybe even thousands)
- the DICOM header reports an unusually large slice resolution (> 256x256)
Tar
Sometimes many DICOM files (or even a whole directory structure of different files) are concatenated together into a single file using the Unix tar utility. If your presumed DICOM file seems a little funky, it might actually be a "tarball" (as the result of a tar concatenation is called) of DICOMs. Here's how to check:
tar -tf <SUSPECTED_DICOM_FILE>
If you get non-error output, especially a list of *.dcm or *.ima filenames, then you're dealing with a tarball of DICOMs. Extract the original images as follows:
tar -xf <SUSPECTED_DICOM_FILE>
The tarball may also have been compressed after concatenation; in which case you would need the -z option in the above commands:
tar -tzf <SUSPECTED_DICOM_FILE> tar -xzf <SUSPECTED_DICOM_FILE>
Mosaic
An unusual storage strategy for DICOM-formatted medical images is the so-called "mosaic" scheme, in which a three-dimensional voxel volume is represented as a two-dimensional flat image. The volume is divided up into X-Y slices which are then arranged in 2D like a tile floor, with Z increasing left to right, top to bottom. You can spot one of these by visual inspection or if the header shows an image size much larger than a single slice---a single slice is usually 128x128 or 256x256 voxels, while a mosaic file may be much larger than that, depending on the Z resolution of the volume.
Code
The following scripts to handle DICOM mosaic files can be found in /map/gfx0/common0/diffusion/Interface/bin/data/:
- processMosaics.m --- split all mosaic files matching a given pattern into DICOM and MRIimage files
- splitMosaic.m --- split a single mosaic file into a Matlab data array
- writeMosaicSlices.m --- write a collection of Matlab data volumes to DICOM and MRIimage files
All of these can be launched non-interactively with matlabLauncher.py.
Handling DICOMs
Matlab
Matlab has extensive built-in support for DICOM header and image data I/O with the dicominfo, dicomread, and dicomwrite functions. This is nice for quickly creating DICOM processing scripts to be run manually, but Matlab is relatively slow and difficult to call from non-interactive scripts. Therefore it's encouraged to port Matlab code into another language (preferably C++ or Python) for inclusion in the diffusion processing pipeline.
Python
A few Python libraries for handling DICOMs exist; these might be worth looking into:
- pydicom --- a pure Python DICOM library
- pydicomlib --- a Python wrapper around dicomlib, below
C/C++
- GDCM --- "Grassroots DICOM" library
- DCMTK --- the DICOM toolkit library
- dicomlib --- Yet another DICOM library, written at Sunnybrook Health Sciences Centre, Toronto
Java
Tools
- medcon --- Command-line tool for converting among tons of different medical image formats
- DICOM3tools --- Command-line tool for reading DICOM headers, written by a member of the DICOM standards committee