[vtkusers] VTK shifts CT data

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri May 1 04:26:44 EDT 2009


Peter,

On Thu, Apr 30, 2009 at 10:59 PM, Peter Halverson <halverson at byu.edu> wrote:
> VTK users,
>
> I am struggling with the two issues.  The first issue is that when I
> read in my CT data the image is shifted left. Meaning that the patients
> left hand appears disembodied and floating on his right side.  I believe
> the shift is ~50 pixels.  (It did this in MatLab too, but not when using
> Dicomworks or pydicom).  Is there a way to shift the data back or reset
> the origin?
>
> My input code is
>
> import vtk
> from vtk.util.misc import vtkGetDataRoot
> from vtk.util.colors import *
> VTK_DATA_ROOT = vtkGetDataRoot()
> import dicom
> filename="./SE1/IM50"
> info=dicom.ReadFile(filename)
>
> aRenderer = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(aRenderer)
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> v16 = vtk.vtkVolume16Reader()
> v16.SetDataDimensions(info.Rows, info.Columns)
> v16.SetDataByteOrderToLittleEndian()
> v16.SetFilePrefix("./SE1/IM")
> #v16.SetFilePrefix("Z:/COM and COR/PA3/ST1/SE1/IM")
> v16.SetFilePattern('%s%d')
> v16.SetImageRange(3, 60)
> v16.SetDataSpacing(info.PixelSpacing[0], info.PixelSpacing[1],
> info.SliceThickness)
>

Why are you using vtkVolume16Reader to read in a DICOM file ?

http://www.vtk.org/Wiki/VTK_FAQ#How_can_I_read_DICOM_files_.3F

If the DICOM file has a Data Set Trailing Padding attribute (well
anything after the Pixel Data element so to say), then
vtkVolume16Reader will simply not work.

HTH
-- 
Mathieu



More information about the vtkusers mailing list