[vtkusers] Re: help on vtkDicomImage Reader and python

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Sep 12 10:34:32 EDT 2007


On 9/12/07, raffaele ponzini <raffaele.ponzini at gmail.com> wrote:
> Dear Mr. Malaterre,
>
> can you please give me some good avise concerning books, papers and
> documentation (possibly with examples) on the usage of the
> vtkDicomImageReader with python?
> Thank you in advance for you consideration,

Hi Raffaele,

  [CC'ing VTKusers]

  Yup, you are right, I should write a book on the vtkDICOMImageReader
subject :)
  Anyway, usage is pretty straightforward as long as you know that VTK
is demand driven.

  API is here:

http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html

for instance you could do something like this:

testSingleFile.py:
  import vtk
  reader = vtk.vtkDICOMImageReader()
  reader.SetFileName('image.dcm')
  reader.Update() # important
  print reader.GetOutput()
  print reader.GetOutput().GetScalarRange()


This example will read all DICOM files from directory:
/full/path/to/my/dicom/images/

testDirectory.py:
  import vtk
  reader = vtk.vtkDICOMImageReader()
  reader.SetDirectoryName('/full/path/to/my/dicom/images/')
  reader.Update()
  print reader.GetOutput() # You should see that 3rd dimension is > 1 now
  print reader.GetOutput().GetScalarRange()

HTH,
-- 
Mathieu



More information about the vtkusers mailing list