Hi!<div><br></div><div>I&#39;ve just started using Python(x,y), the scientific Python platform that includes ITK 3.16. I&#39;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&#39;m having a hard time translating the examples to Python, and I cannot find any python examples online. </div>
<div><br></div><div><div>So far I&#39;ve been able to do the following:</div><div><br></div><div>======================</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div>import itk</div><div><br></div><div>pixeltype = itk.D</div><div>dim = 3</div><div>traitstype = itk.DefaultStaticMeshTraits[pixeltype, dim, dim, pixeltype]</div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
pointsettype = itk.PointSet[pixeltype, dim, traitstype]</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">pointset = pointsettype.New()</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
<br></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">pointset.SetPoint(0, [1,0,0])</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
pointset.SetPoint(1, [0,1,0])</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">pointset.SetPoint(2, [0,0,1])</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
<br></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">print pointset.GetNumberOfPoints()</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
<br></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">pointtype = itk.Point[itk.D,3]</p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">pp = pointtype()</p><p></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">print pointset.GetPoint(1, pp)</p><p></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">print pp.GetElement(0), pp.GetElement(1), pp.GetElement(2)</p><p></p></div></blockquote><div><p></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
==========================</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
This works ok, but the ITK Software Guide says it&#39;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?</p><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">The problem is that I can&#39;t get the container to work: if I try:</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><div><br></div><p></p></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><div>import itk</div><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><div><br></div><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><div>pixeltype = itk.D</div><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><div>dim = 3</div><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><div>pointtype = itk.Point[pixeltype, dim]</div><p></p></div></div><div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><div>vectorcontainertype = itk.VectorContainer[itk.UL, pointtype]</div>
<p></p></div></div></blockquote><div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><p></p><p></p></div></blockquote><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
<br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">python raises the error:</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
<br></p><p></p></div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">raise KeyError, &#39;itkTemplate : No template %s for the %s class&#39; % (str(parameters), self.__name__)</p><p></p>
<p></p></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">
</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">KeyError: &quot;itkTemplate : No template (&lt;itkCType unsigned long&gt;, &lt;class &#39;itkPoint.itkPointD3&#39;&gt;) for the itk::VectorContainer class&quot;</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></p><p></p><p></p></div></blockquote>I&#39;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?<div>
<br></div><div>Hopefully someone can help!</div></div><div><br></div><div>Regards, </div><div>Roel Zinkstok</div><div><br></div><div><br></div><div><br></div><div><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">
</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">
<br></p><p></p></div>