This notebook is intended to demonstrate how registration methods of ITKTubeTK operate.

There are many other (more effective) registration methods available in other pages (e.g., NiftiReg, ANTS). However, the method in ITKTubeTK is often sufficient and is easy to control. So, if it works for your problem...


In [1]:
import itk
from itk import TubeTK as ttk

from itkwidgets import view

import numpy as np

In [2]:
ImageType = itk.Image[itk.F, 3]

ReaderType = itk.ImageFileReader[ImageType]

reader1 = ReaderType.New(FileName="data/mra.mha")
reader1.Update()
im1 = reader1.GetOutput()

reader2 = ReaderType.New(FileName="data/mri_t1_sag.mha")
reader2.Update()
im2 = reader2.GetOutput()

In [3]:
RegisterImagesType = ttk.RegisterImages[ImageType]

reg2To1 = RegisterImagesType.New(FixedImage=im1, MovingImage=im2)
reg2To1.SetReportProgress(True)
reg2To1.SetExpectedOffsetMagnitude(5)
reg2To1.SetExpectedRotationMagnitude(0.005)
reg2To1.SetRegistration("PIPELINE_AFFINE")
reg2To1.SetMetric("MATTES_MI_METRIC")
reg2To1.Update()
im2Reg = reg2To1.ResampleImage()

In [4]:
CheckerboardImagesType = itk.CheckerBoardImageFilter[ImageType]
cb12 = CheckerboardImagesType.New(Input1=im1, Input2=im2Reg)
cb12.Update()
im12 = ImageType.New()
im12 = cb12.GetOutput()
view(im12)



In [ ]: