My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
GettingStarted  
Brief overview of pydicom and how to install.
Phase-Deploy, Featured
Updated Mar 12, 2012 by darcymason@gmail.com

Introduction

pydicom is a pure python package for parsing DICOM files (generally medical image files but also non-image files such as radiotherapy information). It is not meant as an image viewer (there are many of those) but is targeted to getting the DICOM data elements as python variables and altering them if desired, and being able to do so in your own code.

pydicom has a license based on the MIT license.

Installing

To use pydicom 0.9.7, python 2.4 through 2.7 is required -- work is being done to move towards python 3.0, but it will appear in the pydicom 1.0 release.

Note: in addition to the instructions below, pydicom can also be installed through the Python(x,y) distribution, which can install python and a number of packages (including pydicom) at once. Other packages you might be interested in include IPython (an indispensable interactive shell with auto-completion, history etc), Numpy (optionally used by pydicom for pixel data), and ITK/VTK or PIL (image processing and visualization).

Installing using Windows binary release:

Installing using easy_install (all platforms):

  • if you have setuptools installed, just use easy_install at the command line (you may need sudo on linux):
easy_install pydicom
  • depending on your python version, there may be some warning messages, but the install should still be ok.

Installing from source (all platforms):

  • download the source code from the Downloads tab or checkout the mercurial repository source
  • at a command line, change to the directory with the setup.py file
  • with admin privileges, run python setup.py install
    • could also use python setup.py develop to keep the installation in the download location
    • with some linux variants, for example, use sudo python setup.py install
    • with other linux variants you may have to su before running the command.
  • for python < 2.6, you may get a syntax error message when the python files are "built" -- this is due to some python 2.6 specific code in one unit test file. The installation seems to still be ok.

Installing on Mac

  • Mac users can always use easy_install (or pip) or install from source as noted above
  • MacPorts portfiles (e.g. py26-pydicom) are available. This is maintained by other users and may not immediately be up to the latest release.

Using pydicom

Once installed, the package can be imported at a python command line or used in your own python program with import dicom (note the package name is dicom, not pydicom when used in code. See the examples directory for both kinds of uses. Also see the PydicomUserGuide for more details of how to use the package.

Documentation

Documentation for pydicom can be found at:

  • the wiki at http://code.google.com/p/pydicom/w/list
  • doc strings in the code. View these directly in the source files, or use python's help function at the command line. For example:
  • >>> import dicom
    >>> ds = dicom.read_file("CT_small.dcm")
    >>> help(ds)
    Help on Dataset in module dicom.dataset object:
    
    class Dataset(__builtin__.dict)
     |  A Dataset is a collection (dictionary) of Dicom DataElement instances.
     |  
     |  Example of two ways to retrieve or set values:
     |  (1) dataset[0x10, 0x10].value --> patient's name
     |  (2) dataset.PatientName --> patient's name
     |  
    ...
  • in-line comments in the code.
  • example programs in the examples directory

Support

Please join the pydicom discussion group to ask questions, give feedback, post example code for others -- in other words for any discussion about the pydicom code. New versions, major bug fixes, etc. will also be announced through the group.

Next Step

To start learning how to use pydicom, see the PydicomUserGuide.

Comment by proporti...@gmail.com, Oct 10, 2008

Easy to install, easy to use !!

Most of other python packages for DICOM file reading are merely wrappers of C++ code, you should first install. But this one allows you in 30 min read a DICOM file from scratch.

A medical physicist's dream come true. Kudos to Darcy Mason!!!

Comment by Michael....@gmail.com, Nov 10, 2008

This looks extremely useful. install went without problems on Ubuntu Hardy

Seems like this is exactly what I was looking for - just as proportional said.

Thank you very much!

Comment by ebori...@gmail.com, Jan 23, 2009

I've added a portfile (py25-pydicom) for MacPorts? users: http://trac.macports.org/changeset/45855/trunk/dports

Comment by tri...@gmail.com, Mar 4, 2009

Very impressed. At last I can consider giving up Matlab, The DICOM utilities where one of the few (possibly the only) advantages it had over Python.

Comment by tak.r...@gmail.com, Jan 13, 2010

any news on compatibility for python 3.0?

Comment by project member darcymason@gmail.com, Jan 13, 2010

> Comment by tak.rliu, > any news on compatibility for python 3.0?

I'd like to start looking at this at some point after the next release. It's on the issues list (#13). Any comments/advice/contributions are welcome to be added to that issue.

Comment by anaho...@gmail.com, May 30, 2011

Hi, does anybody knows if I can convert video (AVI, MPEG2 or similar) to DICOM files with this library??


Sign in to add a comment
Powered by Google Project Hosting