[vtkusers] vtkDICOMImageReader(): Anyway to change the metadata?

Sonam Wangyal sonam.wangyal at ryerson.ca
Thu Jul 13 13:19:26 EDT 2017


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 <mailto:sonam.wangyal at ryerson.ca>
C: 647.779.2560

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170713/af008099/attachment.html>


More information about the vtkusers mailing list