GDCM 3.2.1

headsq2dcm.py
1
14
15"""
16 Usage:
17 python headsq2dcm.py -D /path/to/VTKData
18"""
19
20 import vtk
21 import vtkgdcm
22 from vtk.util.misc import vtkGetDataRoot
23VTK_DATA_ROOT = vtkGetDataRoot()
24
25reader = vtk.vtkVolume16Reader()
26reader.SetDataDimensions(64, 64)
27reader.SetDataByteOrderToLittleEndian()
28reader.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
29reader.SetImageRange(1, 93)
30reader.SetDataSpacing(3.2, 3.2, 1.5)
31
32cast = vtk.vtkImageCast()
33cast.SetInput( reader.GetOutput() )
34cast.SetOutputScalarTypeToUnsignedChar()
35
36# By default this is creating a Multiframe Grayscale Word Secondary Capture Image Storage
37writer = vtkgdcm.vtkGDCMImageWriter()
38writer.SetFileName( "headsq.dcm" )
39writer.SetInput( reader.GetOutput() )
40# cast -> Multiframe Grayscale Byte Secondary Capture Image Storage
41#writer.SetInput( cast.GetOutput() )
42writer.SetFileDimensionality( 3 )
43writer.Write()