[Insight-users] WrapITK and KappaStatisticImageToImageMetric

Brian Chapman chapmanbe at upmc.edu
Thu Mar 22 10:45:18 EST 2007


I am trying to use the KappaStatisticImageToImageMetric to drive an image
registration problem based on aligning two binary masks. I am currently
using the Python wrappers from WrapITK. I define a registration technique
and the metric as follows:

In [2]: import itk

In [3]: imageMetric = itk.KappaStatisticImageToImageMetric.IUC2IUC2.New()

In [4]: registration = itk.ImageRegistrationMethod.IUC2IUC2.New()

When I go to assign the metric to the registration, I get a type error:

In [5]: registration.SetMetric(imageMetric.GetPointer())
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/Users/brian/Code/Python/Liver/<ipython console> in <module>()

/usr/local/lib/InsightToolkit/WrapITK/lib/itkImageRegistrationMethod.py in
SetMetric(*args)
    506     def SetInitialTransformParameters(*args): return
_itkImageRegistrationMethod.itkImageRegistrationMethodIUC2IUC2_Pointer_SetIn
itialTransformParameters(*args)
    507     def SetInterpolator(*args): return
_itkImageRegistrationMethod.itkImageRegistrationMethodIUC2IUC2_Pointer_SetIn
terpolator(*args)
--> 508     def SetMetric(*args): return
_itkImageRegistrationMethod.itkImageRegistrationMethodIUC2IUC2_Pointer_SetMe
tric(*args)
    509     def SetMovingImage(*args): return
_itkImageRegistrationMethod.itkImageRegistrationMethodIUC2IUC2_Pointer_SetMo
vingImage(*args)
    510     def SetOptimizer(*args): return
_itkImageRegistrationMethod.itkImageRegistrationMethodIUC2IUC2_Pointer_SetOp
timizer(*args)

<type 'exceptions.TypeError'>: Type error. Got
_p_itk__KappaStatisticImageToImageMetricTitk__ImageTunsigned_char_2_t_itk__I
mageTunsigned_char_2_t_t, expected
_p_itk__SmartPointerTitk__ImageToImageMetricTitk__ImageTunsigned_char_2_t_it
k__ImageTunsigned_char_2_t_t_t



 However, if I use a different metric, I have no problems, as illustrated
below:

In [6]: imageMetric2  = itk.MeanSquaresImageToImageMetric.IUC2IUC2.New()

In [7]: registration.SetMetric(imageMetric2.GetPointer())

In [8]: imageMetric2.GetPointer()
Out[8]: <C itk::MeanSquaresImageToImageMetric<(itk::Image<(unsigned
char,2)>,itk::Image<(unsigned char,2)>)> instance at
_a0ce4d03_p_itk__MeanSquaresImageToImageMetricTitk__ImageTunsigned_char_2_t_
itk__ImageTunsigned_char_2_t_t>


No type error.

Any ideas as to what is happening? Any suggested fixes would be appreciated.

Brian


 cannot get the 



More information about the Insight-users mailing list