read and render transformed DICOM image from 3D slicer

I have the 2 DICOM images (MRI and CT)
And I performed rigid registration between MRI and CT (the CT was transformed) in “3D Slicer”

Then I would like to do volume rendering use transformed CT image
However, the transformation did not work properly

This is my code,

image_t = itk.Image[itk.F, 3]
reader = itk.ImageSeriesReader[image_t].New()
dicomIO = itk.GDCMImageIO.New()
dicomFN = itk.GDCMSeriesFileNames.New()
reader.SetImageIO(dicomIO)

dicomFN.SetUseSeriesDetails(True)
dicomFN.SetDirectory(filename)

uids = dicomFN.GetSeriesUIDs()
frames = dicomFN.GetFileNames(uids[0])

reader.SetFileNames(frames)
reader.Update()
image = reader.GetOutput()

orienter = itk.OrientImageFilter[image_t, image_t].New()
orienter.UseImageDirectionOn()
orienter.SetInput(image)
orienter.Update()

itk_vtk_converter = itk.ImageToVTKImageFilter[image_t].New()
itk_vtk_converter.SetInput(orienter.GetOutput())
itk_vtk_converter.Update()

vtk_image = vtk.vtkImageData()
vtk_image.DeepCopy(itk_vtk_converter.GetOutput())
1 Like

Perhaps you need to choose “harden transform” in Slicer before you save your transformed CT image?

transformation did not work properly

Can you be more specific? Transform was not applied? Transform is wrong?

1 Like

If I don’t use the “orientaer.UseImageDirectionOn” the transformation was not applied.
then if I use the “orientaer.UseImageDirectionOn” the transformation is wrong.

VTK does not currently support oriented images, but support has been added for the next release of VTK as discussed here.

1 Like

Maybe you will find this and this example useful.

1 Like

I solved this problem using dzenanz’s example

Thanks a lot !

1 Like