0

I want to do multi-modality image registration(mri/ct) but I do not have completely aligned images, results obtained with simpleITK are very bad. Even if I try to align them, results are still ridiculously bad. What can I do to fix this? My registration code is as follow:

import SimpleITK as sitk
def fusion(ct, mr):
    fixed = sitk.GetImageFromArray(ct, isVector=True)       
    moving = sitk.GetImageFromArray(mr, isVector=True) 


    numberOfBins = 24
    samplingPercentage = 0.10

    R = sitk.ImageRegistrationMethod()
    R.SetMetricAsMattesMutualInformation(numberOfBins)
    R.SetMetricSamplingPercentage(samplingPercentage,sitk.sitkWallClock)
    R.SetMetricSamplingStrategy(R.RANDOM)
    R.SetOptimizerAsRegularStepGradientDescent(1.0,.001,200)
    R.SetInitialTransform(sitk.TranslationTransform(fixed.GetDimension()))
    R.SetInterpolator(sitk.sitkLinear)

    #R.AddCommand( sitk.sitkIterationEvent, lambda: command_iteration(R) )

    outTx = R.Execute(fixed, moving)

    def get_result():                                                            
        resampler = sitk.ResampleImageFilter()                                                       
        resampler.SetReferenceImage(fixed);                                                          
        resampler.SetInterpolator(sitk.sitkLinear)    
        resampler.SetDefaultPixelValue(100)
        resampler.SetTransform(outTx)                                                                
        out = resampler.Execute(moving)                                                              
        simg1 = sitk.Cast(sitk.RescaleIntensity(fixed), sitk.sitkUInt8)                              
        simg2 = sitk.Cast(sitk.RescaleIntensity(out), sitk.sitkUInt8)                                
        cimg = sitk.Compose(simg1, simg2, simg1//2.+simg2//2.)  
        cimg = sitk.Compose(simg1, simg2, simg1//2.+simg2//2.)                                       
        return sitk.GetArrayFromImage(cimg)
        #sitk.Show( cimg, "ImageRegi

    return get_result()
blowekamp
  • 1,401
  • 7
  • 7
Willy Sun
  • 21
  • 5

1 Answers1

0

I think you forgot to make an initial alignment of your images at the beginning.

trans = sitk.CenteredTransformInitializer(fixed ,moving, sitk.Euler3DTransform(), sitk.CenteredTransformInitializerFilter.GEOMETRY)

fati
  • 125
  • 5