[Insight-users] Two WrapITK Questions

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Jan 24 16:25:11 EST 2007


Hi Brian,

I think that the typemap for the itk::Array objects is broken.
Please fill a bug report, so we don't forget it before the next release.
In the mean time, you can use a python sequence instead of an itkArrayD:

   registration.SetInitialTransformParameters([1,2])

I hope you'll be able to make it work like that for now !
Please let me know if you find other problems.

Thanks,

Gaetan


Le Tue, 16 Jan 2007 19:28:32 +0100, Brian Chapman <chapmanbe at upmc.edu> a  
écrit:

> Gaetan,
>
> I've been in Hawaii for a break, so I'm just now getting back to things.
> I've attached the code that I am using as well as to test png files I am
> using.
>
> Again the output error looks like this.
>
> initializeRegistration
> transformImage
> Debug: In
> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Common/itkObject.cxx,
> line 312
> TranslationTransform (0xab84510): Registered, ReferenceCount = 3
>
> Starting registration
> failed in main():
> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Algorithms/itkMultiResolu
> tionImageRegistrationMethod.txx:156:
> itk::ERROR: MultiResolutionImageRegistrationMethod(0xfac9390): Size  
> mismatch
> between initial parameter and transform
> Debug: In
> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Common/itkObject.cxx,
> line 328
> TranslationTransform (0xab84510): UnRegistered, ReferenceCount = 2
>
> Debug: In
> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Common/itkObject.cxx,
> line 328
> TranslationTransform (0xab84510): UnRegistered, ReferenceCount = 1
>
> I appreciate your help on this.
>
> Brian
>
>
>
> On 1/6/07 1:14 PM, "Gaëtan Lehmann" <gaetan.lehmann at jouy.inra.fr> wrote:
>
>> Le Thu, 28 Dec 2006 18:31:20 +0100, Brian Chapman <chapmanbe at upmc.edu> a
>> écrit:
>>
>>> I have two WrapITK questions.
>>>
>>> 1) Has anyone successfully used the
>>> itk.MultiResolutionImageRegistrationMethod? I am trying to translate  
>>> the
>>> example code in MultiResImageRegistration1.cxx to Python. When I start
>>> the
>>> registration, I get the following error:
>>>
>>> Starting registration
>>> failed in main():
>>> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Algorithms/itkMultiResolu
>>> tionImageRegistrationMethod.txx:156:
>>> itk::ERROR: MultiResolutionImageRegistrationMethod(0x10cf9e10): Size
>>> mismatch between initial parameter and transform
>>>
>>> I initialize the transform parameters with the array initialParameters:
>>>
>>> In [62]: WrapITKUtils.print_itkArray(initialParameters)
>>> <class 'itkArray.itkArrayDPtr'>
>>> 0 0.0   1 0.0
>>>
>>> In [63]: registration.SetInitialTransformParameters(initialParameters)
>>>
>>> However, if I now look at the value stored in the registration's  
>>> initial
>>> transform parameters, its an empty array:
>>>
>>> In [64]:
>>> WrapITKUtils.print_itkArray(registration.GetInitialTransformParameters())
>>> <class 'itkArray.itkArrayDPtr'>
>>>
>>> It seems as if the Set method is not working. Any thoughts?
>>
>> Can you post your code, or the part of your code which fails, so I can
>> test it and try to see what is going wrong ?
>>
>>>
>>> 2) I can't figure out the template syntax for objects like the
>>> interpolator
>>> that I would define using object attributes in the interpreter as
>>> follows:
>>>
>>> interpolator = itk.LinearInterpolateImageFunction.IF2D.New()
>>>
>>> How would I create this using template arguments instead?
>>
>> you can found in the name what the template parameters are:
>>
>>    IF2 is for Image< float, 2 >
>>    D is for double
>>
>> but it can be sometime difficult.
>> A somtime better way to go is the keys() method of the iykTemplate  
>> object
>> (itk.LinearInterpolateImageFunction is an itkTemplate object) to get all
>> the instantiation available:
>>
>>    3> itk.LinearInterpolateImageFunction.keys()
>>    3>
>>    [(<class 'itkImage.itkImageF2'>, <itkCType double>),
>>     (<class 'itkImage.itkImageUC2'>, <itkCType double>),
>>     (<class 'itkImage.itkImageUS2'>, <itkCType double>),
>>     (<class 'itkImage.itkImageF3'>, <itkCType double>),
>>     (<class 'itkImage.itkImageUC3'>, <itkCType double>),
>>     (<class 'itkImage.itkImageUS3'>, <itkCType double>)]
>>
>> or the itk.template() method to get the parameters of a given
>> instantiation:
>>
>>    4> itk.template(itk.LinearInterpolateImageFunction.IF2D)
>>    4>
>>    (<itkTemplate itk::LinearInterpolateImageFunction>,
>>      (<class 'itkImage.itkImageF2'>, <itkCType double>))
>>
>> So you can create it like that:
>>
>>    itk.LinearInterpolateImageFunction[ itk.Image[ itk.F, 2], itk.D  
>> ].New()
>>
>> hope that helps,
>>
>> Gaetan
>>
>>
>>
>



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr


More information about the Insight-users mailing list