[vtkusers] vtkDICOMImageReader(): Anyway to change the metadata?
David Gobbi
david.gobbi at gmail.com
Thu Jul 13 16:23:20 EDT 2017
Hi Sonam,
The filter vtkImageChangeInformation can modify the spacing of the data:
ici = vtk.vtkImageChangeInformation()
ici.SetInputConnection(reader.GetOutputPort())
ici.SetOutputSpacing(0.859375, 0.859375, 5.0)
- David
On Thu, Jul 13, 2017 at 11:19 AM, Sonam Wangyal <sonam.wangyal at ryerson.ca>
wrote:
> Hello!
>
> This is my first post in this community and just as a heads up I am a
> complete newbie. I am currently working on a project to segment ventricles
> from MRI scans of the brain (in MATLAB). I wanted to then extract the
> surface using vtkDiscreteMarchingCubes() and write it into an STL file
> using vtkSTLWriter().
>
> My problem is with the PixelSpacing, the documentation says if there are
> multiple DICOM images then the 'z' value is the Spacing Between the Slices.
> But I am receiving (0.859375, 0.859375, 0.0). I don't know why it is giving
> me a 0.0, it should be a 5. I have tried with an single DICOM and it works
> properly it gave me a Slice Thickness which coincidentally is the same
> value as the Spacing Between the Slices.
>
> SO MY QUESTION IS: is there anyway to manually change the value? My code
> is down below, THANKS FOR YOUR HELP!
>
> import vtk
>
> PathDicom = "./DICOMs/"
> reader = vtk.vtkDICOMImageReader()
> reader.SetDirectoryName(PathDicom)
> reader.Update()
>
> print(reader.GetPixelSpacing())
>
> dmc = vtk.vtkDiscreteMarchingCubes()
> dmc.SetInputConnection(reader.GetOutputPort())
> dmc.GenerateValues(1, 1, 1)
> dmc.Update()
>
> writer = vtk.vtkSTLWriter()
> writer.SetInputConnection(dmc.GetOutputPort())
> writer.SetFileTypeToBinary()
> writer.SetFileName("ventricle.stl")
> writer.Write()
>
> Cheers,
> *Sonam Wangyal*
> Electrical Engineering | BEng Candidate
> The Faculty of Engineering and Architectural Science
> E: sonam.wangyal at ryerson.ca
> C: 647.779.2560 <(647)%20779-2560>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170713/48ca3f2b/attachment.html>
More information about the vtkusers
mailing list