[Insight-users] Use of PointSet and VectorContainer in python

Matt McCormick matt at mmmccormick.com
Thu May 26 12:34:54 EDT 2011



Hi Roel,

> 
> 
> Hi!
> 
> I've just started using Python(x,y), the scientific Python platform that 
includes ITK 3.16. I'm interested in using PointSets and VectorContainers, 
ultimately to use Meshes. I am trying to work through chapter 4 of the ITK 
Software Guide, but I'm having a hard time translating the examples to Python, 
and I cannot find any python examples online. 

I am not sure, but Python(x,y) probably uses WrapITK.  There is some 
documentation here, e.g.,
http://mima2.jouy.inra.fr/darcs/contrib-itk/WrapITK/WrapITK_-
_Enhanced_languages_support_for_the_Insight_Toolkit.pdf


> 
> This works ok, but the ITK Software Guide says it's better to use containers. 
And if I am to work with Meshes, it will be even more important to use 
containers, or am I mistaken?

Using containers is for efficiency.  If you are worried about efficiency, then 
it is probably a bigger hit to use Python instead of C++.  Maybe play around in 
Python and see if it is good enough, then make improvements as needed.


> 
> 
> vectorcontainertype = itk.VectorContainer[itk.UL, pointtype]
> 
> python raises the error:
> 
> 
> raise KeyError, 'itkTemplate : No template %s for the %s class' % 
(str(parameters), self.__name__)
> 
> KeyError: "itkTemplate : No template (<itkCType unsigned long>, <class 
'itkPoint.itkPointD3'>) for the itk::VectorContainer class"
> 

> I've tried a lot of different combinations, but always the same sort of 
result. Does anybody know the correct syntax? And more generally, are there 
examples somewhere that show the use of meshes in python?
> 

Notice you are trying to use UL (unsigned long) here instead of D (double) in 
your previous example that is working.   When they built the Python binding, the 
Python(x,y) had to decide what pixels types are supported at build time.  Maybe 
they did not build support for an unsigned long VectorContainer.

The easiest way to figure out what is support may be to fire up an IPython shell 
and use the tab completion.

In [2]: itk.VectorContainer.<TAB>

Matt



More information about the Insight-users mailing list