[Insight-users] a problem in itk registration fuction

Luis Ibanez luis.ibanez@kitware.com
Mon May 10 00:27:21 EDT 2004


Hi Carrie,


Thanks for your detailed report.


A couple of questions:


1) Did you verified that the variables
    imagefixed and imagemoving actually
    contain the images you expected ?

    your use of itkFixedImage.GetOutput()
    and itkMovingImage.GetOutput() could
    be failing to produce valid images...

2) Did the registration run for a certain
    number of iterations ?

    You connected an observer to the Optimizer,
    but you didn't mention if you got values
    at each iteration.



At first sight, it may seem that your registration
process is not even performing a first iteration...


Please let us know.



    Thanks



       Luis


---------------
Carrie wrote:
> Hi all,
> 
>    I wrote some sentences to do the registration function with python. 
> But after using “StartRegistration()”, the result array from 
> registration.GetLastTransformParameters() always is 0.  How can I solve 
> this problem? Some codes as followed:
> 
>            
> 
> imagefixed=itkFixedImage.GetOutput()
> 
>        imagemoving=itkMovingImage.GetOutput()
> 
>           
> 
>         registration = itk.itkImageRegistrationMethodF3F3_New()
> 
>         imageMetric  = itk.itkMutualInformationImageToImageMetricF3F3_New()
> 
>         transform     = itk.itkQuaternionRigidTransform_New()
> 
>         optimizer    = itk.itkGradientDescentOptimizer_New()
> 
>         interpolator = itk.itkLinearInterpolateImageFunctionF3D_New()
> 
>  
> 
>          imageMetric.SetFixedImageStandardDeviation(0.4)
> 
>         imageMetric.SetMovingImageStandardDeviation(0.4)
> 
>         imageMetric.SetNumberOfSpatialSamples(50)
> 
>  
> 
>         imagefixed.Update()
> 
> imagemoving.Update()
> 
>  
> 
>         registration.SetOptimizer(optimizer.GetPointer())
> 
>         registration.SetTransform(transform.GetPointer())
> 
>         registration.SetInterpolator(interpolator.GetPointer())
> 
>         registration.SetMetric(imageMetric.GetPointer())
> 
>         registration.SetFixedImage(imagefixed)
> 
>         registration.SetMovingImage(imagemoving)
> 
>  
> 
>         registration.SetFixedImageRegion(imagefixed.GetBufferedRegion())
> 
>         
> 
>         transform.SetIdentity()
> 
>         initialParameters=transform.GetParameters()
> 
>         i=0
> 
>         for i in range(transform.GetNumberOfParameters()):
> 
>             initialParameters.SetElement(i,0.0)
> 
>         registration.SetInitialTransformParameters(initialParameters )
> 
>      
> 
>         def iterationUpdate():
> 
>             currentParameter = transform.GetParameters()
> 
>         iterationCommand = itk.itkPyCommand_New()
> 
>         iterationCommand.SetCommandCallable(iterationUpdate)
> 
>  
> 
>         optimizer.AddObserver(itk.itkIterationEvent(), 
> iterationCommand.GetPointer() )
> 
>         optimizer.SetNumberOfIterations(100)
> 
>             optimizer.SetLearningRate(20.0)
> 
>         optimizer.MaximizeOn()
> 
>         registration.SetMovingImage(imagemoving)
> 
>         registration.StartRegistration()
> 
>         solution = registration.GetLastTransformParameters()
> 
>   
> 
> The 7 elements in solution array(in the last sentence) are 0. why did 
> that happen?
> 
> Thx
> 
> Regards,
> 
>   
> 
> Carrie
> 






More information about the Insight-users mailing list