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

sonamwangyal sonam.wangyal at ryerson.ca
Thu Jul 13 16:27:47 EDT 2017


Thanks I used pydicom to get the metadata and used what you suggested and it worked!

Thank you!

Sent from my iPhone

> On Jul 13, 2017, at 4:23 PM, David Gobbi [via VTK] <ml+s1045678n5743965h66 at n5.nabble.com> wrote:
> 
> 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 <[hidden email]> 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
>> 
> 
> _______________________________________________ 
> Powered by www.kitware.com 
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> 
> Follow this link to subscribe/unsubscribe: 
> http://public.kitware.com/mailman/listinfo/vtkusers
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://vtk.1045678.n5.nabble.com/vtkDICOMImageReader-Anyway-to-change-the-metadata-tp5743964p5743965.html
> To start a new topic under VTK - Users, email ml+s1045678n1224199h20 at n5.nabble.com 
> To unsubscribe from VTK - Users, click here.
> NAML




--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkDICOMImageReader-Anyway-to-change-the-metadata-tp5743964p5743966.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170713/d23937af/attachment.html>


More information about the vtkusers mailing list