Discussion:
[vtkusers] how to read dicom file using python?
RimAY
2009-02-17 10:30:10 UTC
Permalink
Hi all,
I'm trying to read a Dicom file using python. I have successfully built
VTK_5.2.1 in python 2.4, but I failed to use vtkDICOMImageReader(). I got
many errors .

Please, can someone give me the right method to use in order to read a Dicom
file using vtk and python.
Thanks a lot
Best Regards
--
View this message in context: http://www.nabble.com/how-to-read-dicom-file-using-python--tp22054451p22054451.html
Sent from the VTK - Users mailing list archive at Nabble.com.
Mathieu Malaterre
2009-02-17 10:43:50 UTC
Permalink
Post by RimAY
Hi all,
I'm trying to read a Dicom file using python. I have successfully built
VTK_5.2.1 in python 2.4, but I failed to use vtkDICOMImageReader(). I got
many errors .
Do you really expect anyone to help you out without:
1. Sending the actual error
2. Sending the actual code you were using
--
Mathieu
RimAY
2009-02-17 11:23:14 UTC
Permalink
I'm sorry,
Thanks for your reply,

Here is my code:

import vtk

reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName('the root of my dicom files')
win = 400000
lev = 400000

viewer = vtk.vtkImageViewer()
viewer.SetInputConnection( reader.GetOutputPort() )
viewer.SetColorWindow(win)
viewer.SetColorLevel(lev)
viewer.Render()

viewer2 = vtk.vtkImageViewer2()
viewer2.SetInputConnection( reader.GetOutputPort() )
viewer2.SetColorWindow(win)
viewer2.SetColorLevel(lev)
viewer2.Render()

iren = vtk.vtkRenderWindowInteractor()
viewer2.SetupInteractor(iren)
iren.Initialize()

and I got the following error:: vtkDICOMImageReader[015579F0]: Couldn't get
stored files.

Please could someone help me to resolve it
Thanks a lot
Post by Mathieu Malaterre
Post by RimAY
Hi all,
I'm trying to read a Dicom file using python. I have successfully built
VTK_5.2.1 in python 2.4, but I failed to use vtkDICOMImageReader(). I got
many errors .
1. Sending the actual error
2. Sending the actual code you were using
--
Mathieu
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
http://www.vtk.org/mailman/listinfo/vtkusers
--
View this message in context: http://www.nabble.com/how-to-read-dicom-file-using-python--tp22054451p22055230.html
Sent from the VTK - Users mailing list archive at Nabble.com.
Mathieu Malaterre
2009-02-17 13:35:20 UTC
Permalink
Post by RimAY
I'm sorry,
Thanks for your reply,
import vtk
reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName('the root of my dicom files')
Works for me.
Post by RimAY
and I got the following error:: vtkDICOMImageReader[015579F0]: Couldn't get
stored files.
http://en.wikipedia.org/wiki/Dyslexia :)

Did you mean 'sorted' ?
Post by RimAY
Please could someone help me to resolve it
Implicitely vtkDICOMImageReader will only works with MR Image Storage
or CT Image Storage, as it requires Image Orientation (Patient) and
Image Position (Patient) attribute to order slices.

You could use vtkGDCMImageReader as it does not have such restriction.

http://gdcm.sourceforge.net/html/classvtkGDCMImageReader.html

2cts
--
Mathieu
Loading...