<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi all,<br><br>I have a vtk mesh that I would like to register with a nifti image.<br>I tried to convert it to an image using this page, by changing the c++ code to python : http://www.paraview.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData<br>It gave me a MetaImage (a .mhd file and .raw file) that doesn&#39;t help me for the registration...<br><br>How could I get a nifti image from this mesh ? (nifti or any other image format that I could register with a nifti)<br><br>Here is the Python vtk code to create the mesh (generates a long cylinder named &#39;stem&#39; and a smaller one named &#39;c1&#39;) :<br><br>&nbsp;&nbsp;import vtk<br><br>&nbsp;&nbsp;# create a rendering window and renderer<br>&nbsp;&nbsp;ren = vtk.vtkRenderer()<br>&nbsp;&nbsp;renWin = vtk.vtkRenderWindow()<br>&nbsp;&nbsp;renWin.AddRenderer(ren)<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;# create a renderwindowinteractor<br>&nbsp;&nbsp;iren = vtk.vtkRenderWindowInteractor()<br>&nbsp;&nbsp;iren.SetRenderWindow(renWin)<br><br><br>&nbsp;&nbsp;# create stem<br>&nbsp;&nbsp;stem = vtk.vtkCylinderSource()<br>&nbsp;&nbsp;stem.SetCenter(0,0.73875,0)<br>&nbsp;&nbsp;stem.SetRadius(0.0063)<br>&nbsp;&nbsp;stem.SetHeight(1.5225) # 2.25 + 150<br>&nbsp;&nbsp;stem.SetResolution(100) # number of facets to define cylinder<br><br>&nbsp;&nbsp;# create c1<br>&nbsp;&nbsp;c1 = vtk.vtkCylinderSource()<br>&nbsp;&nbsp;c1.SetCenter(0,0,0)<br>&nbsp;&nbsp;c1.SetRadius(0.00635)<br>&nbsp;&nbsp;c1.SetHeight(0.03)<br>&nbsp;&nbsp;c1.SetResolution(100)<br><br>&nbsp;&nbsp;# mappers<br>&nbsp;&nbsp;stemMapper = vtk.vtkPolyDataMapper()<br>&nbsp;&nbsp;stemMapper.SetInput(stem.GetOutput())<br><br>&nbsp;&nbsp;c1mapper = vtk.vtkPolyDataMapper()<br>&nbsp;&nbsp;c1mapper.SetInput(c1.GetOutput())<br><br>&nbsp;&nbsp;# actors<br>&nbsp;&nbsp;stemActor = vtk.vtkActor()<br>&nbsp;&nbsp;stemActor.SetMapper(stemMapper)<br><br>&nbsp;&nbsp;c1Actor = vtk.vtkActor()<br>&nbsp;&nbsp;c1Actor.SetMapper(c1mapper)<br>&nbsp;&nbsp;c1Actor.GetProperty().SetColor(1.0,0,0)<br><br>&nbsp;&nbsp;# assign actors to the renderer<br>&nbsp;&nbsp;ren.AddActor(stemActor)<br>&nbsp;&nbsp;ren.AddActor(c1Actor)<br><br>&nbsp;&nbsp;# display axes<br>&nbsp;&nbsp;axes = vtk.vtkAxesActor()<br>&nbsp;&nbsp;ren.AddActor(axes)<br><br>&nbsp;&nbsp;# enable user interface interactor<br>&nbsp;&nbsp;iren.Initialize()<br>&nbsp;&nbsp;renWin.Render()<br>&nbsp;&nbsp;iren.Start()<br><br><br>Thank you for your help. Regards,<br><br>Jude<br>                                               </div></body>
</html>