itkwidgets icon indicating copy to clipboard operation
itkwidgets copied to clipboard

itk orientation vs vtk orientation display

Open stephahn0916 opened this issue 2 years ago • 1 comments

Hi,

I have a segmented image using itk pipeline. For the display in itkwidgets, I used itk-vtkglue lib and used a marching cubes to display only the segmented surface. But when I display both itk image and segmented surface, they are not in the same orientation.

import itk
import vtk
from itkwidgets import view

itk_image = itk.imread(PATH_TO_SEGMENTATION)
vtk_image = itk.vtk_image_from_image(itk_image,)

marching_cubes_filter = vtk.vtkDiscreteMarchingCubes()
marching_cubes_filter.SetInputData(vtk_image)
marching_cubes_filter.SetNumberOfContours(1)
marching_cubes_filter.SetComputeNormals(1)
marching_cubes_filter.GenerateValues(1,1,1)
marching_cubes_filter.Update()

view(vtk_image, geometries={"vessel":marching_cubes_filter.GetOutput()}) # Alignement between image and polydata is ok
view(itk_image, geometries={"vessel":marching_cubes_filter.GetOutput()}) # 90° orientation missmatch

I have tried to use the OrientImageFilter to check if the images were not in RAS (change from LPS to RAS) but it is not the case.

Not sure also if the problem is with itkwidgets? or with itk-vtkglue? or (more probably) with my understanding of image orientation? For example, when I code myself the transformation from itk to vtk, it seems that providing the direction cosine produce a wrong alignment also. To reproduce the result of itk-vtkglue, I have to use only extent, spacing and origin.

stephahn0916 avatar Jan 10 '22 16:01 stephahn0916

Indeed in _transform_types.py at line 256: to_itk_image from vtk, the direction is not passed. However, it seems that direction is now supported by vtk.

stephahn0916 avatar Jan 11 '22 13:01 stephahn0916