Hi all, this is my first question here, I hope I understood the rules.
I have been using itk (C++ version) for many years now, so I am quite familiar with it. Recently I have been exploring the possibility to use it also in Python. So far with not a lot of luck. Here is an specific question but any link to itk or simple itk resources only will be most appreciated (so far I have found quite a few tutorials but after reading those I feel I do not yet understand the way itk works in Python).
I want to port the code from this example:
to Python. As you will see, I am using both itk and simpleitk (I am not sure that is a good idea actually).
So far I have tried this:
import SimpleITK as sitk import itk def computeMetrics(nameFixed,nameMoving): pixelType = sitk.sitkFloat32 fixedImage = sitk.ReadImage(nameFixed, pixelType) movingImage = sitk.ReadImage(nameMoving, pixelType) metric=itk.MeanSquaresImageToImageMetric() interpolator=itk.LinearInterpolateImageFunction() transform=itk.TranslationTransform() interpolator.SetInputImage( fixedImage ) metric.SetFixedImage( fixedImage ) metric.SetMovingImage( movingImage ) metric.SetFixedImageRegion( fixedImage.GetLargestPossibleRegion() ) metric.SetTransform( transform ) metric.SetInterpolator( interpolator )
However, whenever I try to set the input images for the metric (both fixed and moving) I get the following error:
Traceback (most recent call last):
File “./computeImageMetric.py”, line 67, in
File “./computeImageMetric.py”, line 26, in computeMetrics
interpolator.SetInputImage( fixedImage )
TypeError: in method ‘itkImageFunctionISS2DD_SetInputImage’, argument 2 of type ‘itkImageSS2 const *’
I do not understand the error and am also having a hard time finding documentation (in python) for the classes involved. Any help will be most appreciated.