[vtkusers] GDCM2 + VTK: wrong slice order?
Paul Melis
paul at science.uva.nl
Mon Dec 8 07:18:39 EST 2008
Hello,
I'm using VTK 5.2 together with GDCM 2.0.10 to read in a set of MR
slices in DICOM format. I was under the impression that the
vtkGDCMImageReader would sort the files given to it (through
SetFileNames()) at least by looking at the "Image Position (Patient)"
tag. However, it seems that when I shuffle list of filenames in a random
order before giving them to the reader the output of the reader changes
and I can see the slices appear in the wrong order. I.e., something like
this
#!/usr/bin/env python
import os, sys, random
import vtk
import vtkgdcm
files = sys.argv[1:]
random.shuffle(files)
sa = vtk.vtkStringArray()
for f in files:
sa.InsertNextValue(f)
dr = vtkgdcm.vtkGDCMImageReader()
dr.SetFileNames(sa)
dr.Update()
dw = vtk.vtkDataSetWriter()
dw.SetFileName('out.vtk')
dw.SetInputConnection(dr.GetOutputPort())
dw.Write()
produces radically different output across different runs (observed by
loading them in paraview and browsing the slices).
So this would suggest that my set of DICOM images does not contain
enough information for them to be correctly sorted by GDCM. However,
when I check the "Image Position (Patient) (0020,0032)" tag of the files
these seem to make sense. So what else could be going on here? Any
strategies to debug why these slices aren't getting ordered correctly?
Thanks,
Paul
More information about the vtkusers
mailing list