I discovered few weeks back, that you cannot just change input mesh for deform filter, that is<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 14px; border-collapse: collapse; "><i><span lang="nl-nl"><font size="1" face="Courier New">m_DeformFilter->SetInput(m_SimplexMesh);</font></span></i></span></div>
<div>this line is a problem. The workaround I used was to create unnamed block and create a new deform filter from scratch (instantiate filter and set a bunch of parameters) instead of just setting setting input mesh and calling update.</div>
<div><br></div><div>Regards,</div><div>Dženan</div><div><br><div class="gmail_quote">On Wed, Jul 21, 2010 at 11:37, <span dir="ltr"><<a href="mailto:J.Menssen@cukz.umcn.nl">J.Menssen@cukz.umcn.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">Dear All</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">We are working on a segmentation algorithm using deformable models with a refine mesh. The deformation and refinement is done in a for loop. Our application is based on the DeformableModel application as given in the InsightApplications example DeformableModelSimplexMesh.</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">We modified the for loop in de DeformMesh method</font></span><span lang="nl"></span><span lang="en-us"><font face="Calibri"> (DeformableModelApplication.cxx)</font></span><span lang="nl"></span><span lang="en-us"><font face="Calibri"> with a refinement of the mesh, but this crashes. Below a part of (pseudo) code is given.. </font></span></p>
<ul dir="LTR">
<p dir="LTR"><span lang="nl"></span><span lang="en-us"></span></p>
</ul>
<p dir="LTR"><span lang="nl"><i></i></span><i><span lang="en-us"><font face="Calibri"> for i=</font></span></i><span lang="nl"><i></i></span><i><span lang="en-us"><font face="Calibri">1</font></span></i><span lang="nl"><i></i></span><i><span lang="en-us"><font face="Calibri">:i<nr_iterations;i++</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> {</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_simplexMesh->DisconnectPipeline()</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_deformFilter-SetInput(m_simplexMesh);</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_deformFilter->Update(0;</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> simplexMesh2 = m_deformFilter->GetOutput();</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> </font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_refineMesh->SetInput(simplexMesh2);</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_refineMesh->Update();</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> m_simplexMesh=m_refineMesh->GetOutput();</font></span></i></p>
<p dir="LTR"><i><span lang="en-us"><font face="Calibri"> }</font></span></i></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">m_deformFilter is a</font></span><span lang="nl"></span><span lang="nl-nl"> <font face="Calibri">DeformableSimplexMesh3DGradientConstraintForceFilter,</font></span><span lang="nl"></span><span lang="nl-nl"> </span></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl-nl"><font face="Calibri">m_RefineMesh is a itkSimplexMeshAdaptTopologyFilter</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"> </span><span lang="nl"><i></i></span><i><span lang="en-us"> </span></i></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">To isolate the bug, we started with a little modification of the DeformMesh method in DeformableModelApplication.cxx. The modifications are given below (line 522 in original file, InsightApplciations 3.16). Running this code results also in a crash</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">*----------------------------------------------------------------------------------------------------------------------------------------</font></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New">SimplexMeshType::Pointer simplexMesh2 = m_SimplexMesh;</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font color="#0000FF" size="1" face="Courier New">const</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"></font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#0000FF" size="1" face="Courier New">unsigned</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"></font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#0000FF" size="1" face="Courier New">int</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"> numberOfIterationsToGo = atoi(m_IterationsValueInput->value()); </font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font color="#0000FF" size="1" face="Courier New">for</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New">(</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#0000FF" size="1" face="Courier New">unsigned</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"></font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#0000FF" size="1" face="Courier New">int</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"> i=0; i<numberOfIterationsToGo; i++ )</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New">{</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> std::cout <<</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#A31515" size="1" face="Courier New">" Iteration "</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"> << i << std::endl;</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> </font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font color="#008000" size="1" face="Courier New">//* -------------- start modified code -------------------------------------------</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> </span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#008000" size="1" face="Courier New">// THIS IS MODIFIED CODE THAT (WE THINK) DOESN'T VIOLATE THE ITK RULES BUT THIS</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"></font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#008000" size="1" face="Courier New">// CODE CRASHES</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font size="1" face="Courier New">m_SimplexMesh->DisconnectPipeline();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">m_DeformFilter->SetInput(m_SimplexMesh);</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">m_DeformFilter->SetIterations(1);</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">m_DeformFilter->Update();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">simplexMesh2 = m_DeformFilter->GetOutput();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">SimplexMesh2->DisconnectPipeline(0</font></span></i></p>
<ul dir="LTR"><ul dir="LTR"><ul dir="LTR">
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New">m_DeformFilter->SetInput(simplexMesh2);</font></span></i></p>
</ul></ul></ul>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font size="1" face="Courier New">m_DeformFilter->SetIterations(1);</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">m_DeformFilter->Update();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="1" face="Courier New">m_SimplexMesh = m_DeformFilter->GetOutput();</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font color="#008000" size="1" face="Courier New">// --------------------- end modified code -------------------------------------- */</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"> m_SimplexMeshToShow = m_SimplexMesh;</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> </font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#0000FF" size="1" face="Courier New">this</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New">->RefreshMeshVisualization();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> </font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> </font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font color="#008000" size="1" face="Courier New">// force a redraw</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="1" face="Courier New"> axialView->redraw();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> coronalView->redraw();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> sagittalView->redraw();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> surfaceView->redraw();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="1" face="Courier New"> Fl::check(); </font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="2" face="Courier New"> }</font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"></span></i></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl"></span><span lang="en-us"><font face="Times New Roman">*-------------------------------------------------------------------------------------------------------------------------------------------</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">Error message</font></span><span lang="nl"></span><span lang="en-us"><font face="Calibri"> (using Visual Studio 2005 and/or 2008)</font></span><span lang="nl"></span><span lang="en-us"><font face="Calibri"> of the crash</font></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">Debug Assertion Failed !</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"> <font face="Calibri">Expression map/set iterator not dereferencable </font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">Do we something wrong? Using a for loop in a pipeline is dangerous but in bug 0001080, we read it’s possible to use a for loop. Also at the Old Nabble forum I read a message that is must be possible to use a for loop. (</font></span><span lang="nl"></span><a href="http://old.nabble.com/Using-image-iterators-combined-with-filters-in-a-loop-td28684443.html" target="_blank"><span lang="nl"><u></u></span><u><span lang="en-us"><font color="#0000FF" face="Calibri">http://old.nabble.com/Using-image-iterators-combined-with-filters-in-a-loop-td28684443.html</font></span></u><span lang="nl"></span></a><span lang="nl"></span><span lang="en-us"><font face="Calibri">)</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">Even if we changed the code in the original example DeformableModelApplication according to the above referenced Old Nabble article the application crashes</font></span><span lang="nl"></span><span lang="en-us"><font face="Calibri"> (see below)</font></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"><font size="2" face="Courier New"> </font></span></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"><font size="2" face="Courier New">m_DeformFilter->SetInput( m_SimplexMesh );</font></span></i></p>
<p dir="LTR"><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="2" face="Courier New"> </font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font size="2" face="Courier New">m_DeformFilter->SetIterations(1); </font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="2" face="Courier New"> m_DeformFilter->Update();</font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"><font size="2" face="Courier New"> </font></span></i><span lang="nl"><i></i></span><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"> <font size="2" face="Courier New">m_SimplexMesh = m_DeformFilter->GetOutput(); </font></span></i></p>
<p dir="LTR"><i><span lang="nl-nl"> <font size="2" face="Courier New">m_SimplexMesh->DisconnectPipeline();</font></span></i></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">So is there a bug in the original ITK sources? As far as we now, ITK doesn’t allow to change the input of a filter and we think this is what happened in the original DeformableSimplexMesh application.</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">Can someone help us with our problem ?</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri">We tested with ITK 2.8, ITK 3.16 and 3.18 and all crashes</font></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="en-us"><font face="Calibri"></font></span><span lang="nl"><b></b></span><span lang="nl"><b></b></span><b><span lang="nl-nl"></span></b><b><span lang="nl-nl"> <font color="#215868" size="2" face="Univers">Jan Menssen</font></span></b><span lang="nl"><b></b></span><span lang="nl"><b></b></span><b><span lang="nl-nl"><br>
</span></b><span lang="nl"><i></i></span><span lang="nl"><i></i></span><i><span lang="nl-nl"></span></i><i><span lang="nl-nl"><font color="#444444" size="2" face="Univers">Research assistant</font></span></i></p>
<p dir="LTR"><span lang="nl"><b></b></span><span lang="nl"><b></b></span><b><span lang="nl-nl"></span></b><b><span lang="nl-nl"><font color="#215868" size="1" face="Univers">Radboud University Nijmegen Medical Centre</font></span></b><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"><br>
</span><span lang="nl"><b></b></span><span lang="nl"><b></b></span><b><span lang="nl-nl"></span></b><b><span lang="nl-nl"><font color="#444444" size="1" face="Univers">C</font><font color="#444444" size="1" face="Univers">linical Physics Lab -</font></span></b><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"></span><span lang="nl-nl"> <font color="#444444" size="1" face="Univers">Peadiatrics</font></span><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"><br>
</span><span lang="nl-nl"><font color="#444444" size="1" face="Univers">Huispost 833, route 833<br>
P.O box 9101<br>
6500 HB Nijmegen<br>
Telefoon: +31 24 36 19063<br>
E-mail</font></span><span lang="nl"> </span><a href="mailto:J.Menssen@cukz.umcn.nl" target="_blank"><span lang="nl"></span><span lang="nl"><u></u></span><u><span lang="nl-nl"></span></u><u><span lang="nl-nl"><font color="#0000FF" size="1" face="Univers">J.Menssen@cukz.umcn.nl</font></span></u><span lang="nl"></span></a><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"></span><span lang="nl-nl"><font color="#444444" size="1" face="Univers"> </font></span></p>
<p dir="LTR"><span lang="nl"></span><a href="http://www.umcn.nl/" target="_blank"><span lang="nl"></span><span lang="nl"><u></u></span><u><span lang="nl-nl"></span></u><u><span lang="nl-nl"><font color="#0000FF" size="1" face="Univers">http://www.umcn.nl</font></span></u><span lang="nl"></span></a><span lang="nl"></span><span lang="nl"></span><span lang="nl-nl"></span></p>
<p dir="LTR"><span lang="nl"></span><span lang="nl-nl"></span></p>
<p dir="LTR"><span lang="nl"></span></p>
<br clear="all">
        <div>
        <p style="font-size:13px;font-family:arial">
        
        Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.<br> The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.<br>
        </p>
        </div>
</div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>