[Insight-users] access to vnl_conjugate_gradient methods from Python

Luis Ibanez luis.ibanez at kitware.com
Tue May 25 11:42:04 EDT 2010


Hi Nestor,

We don't wrap the internal VNL optimizers.


What you want to do is to add a new method to the

            itkConjugateGradientOptimizer

to expose that functionality of the internal vnl optimizer.

The new method of the itkConjugateGradientOptimizer
will look like:


    void SetNumberOfEvaluations( unsigned int nevals )
      {
      this->m_VnlOptimizer->set_max_function_evals( nevals );
      }



Then,
you should rebuild the Wrapping.


If you find that patch useful, we could add it to the
API of ITK 3.20.


Please let us know,


    Thanks,


          Luis


======================================================
On Fri, May 14, 2010 at 11:24 AM, Parra, Nestor <NParra at med.miami.edu> wrote:
>
> Dear ITK geniuses:
>
> I am using the ITK library for image registration in Python.
>
> I am successfully creating the following optimizer object and its VNL implementation:
>
> optimizer = itk.ConjugateGradientOptimizer.New()
> vnlOptimizer = optimizer.GetOptimizer()
>
> and I need to call:
> vnlOptimizer.set_max_function_evals( Max_Iterations )
>
> but vnlOptimizer seems to be a (SWIG??) pointer represented as a string:
>
>>>> vnlOptimizer.__class__
> <type 'str'>
>>>> str(vnlOptimizer)
> '_584aa110_p_vnl_conjugate_gradient'
>>>> optimizer.__class__
> <class 'ITKOptimizers.itkConjugateGradientOptimizer_PointerPtr'>
>>>> str(optimizer)
> '<C itk::SmartPointer<(itk::ConjugateGradientOptimizer)> instance at _b8157206_p_itk__SmartPointerTitk__ConjugateGradientOptimizer_t>'
>
> My question is:
>
> How do I dereference the string representation to get back the vnl_conjugate_gradient object itself, so I can call its methods?
>
> Thank you so much,
> Andres
>
> Nestor Andres Parra
> Intermediate Programmer
> Department of Radiology
> Miller School of Medicine, University of Miami
> 1150 N.W. 14th St., Suite 713
> Miami, FL 33136
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list