<div>Hi all,</div><div>I would like to apply a deformation field to a surface mesh. First of all, I compute the deformation field between two binary nii-datasets (fixed + moving) using DiffeomorphicDemonsRegistrationFilter. Then I extract the mesh of the moving dataset and transform it based on the deformation field to obtain the mesh of the fixed dataset. However, the resulting mesh always corresponds to the moving one - as if the deformation field has not been applied (I suppose the mesh is in the same space as the corresponding volume). The deformation field (also verified with ParaView) is correct as I can apply it to the moving volume using WarpImageFilter. In this case, the resulting volume corresponds to fixed volume. </div>
<div><br></div><div>Thanks for any input,</div><div>Michael B.</div><div><br></div><div><br></div><div><br></div><div>typedef itk::Image&lt; unsigned short, 3 &gt;<span class="Apple-tab-span" style="white-space:pre">                                                </span>                ImageType;</div>
<div>typedef itk::ImageFileReader&lt; imageType &gt;<span class="Apple-tab-span" style="white-space:pre">                                        </span>                        ReaderType;</div><div>typedef itk::Vector&lt; double, 3 &gt;<span class="Apple-tab-span" style="white-space:pre">                                                </span>                                VectorType;</div>
<div>typedef itk::Image&lt; VectorType, 3 &gt;<span class="Apple-tab-span" style="white-space:pre">                                                </span>                        DefFieldType;</div><div>typedef itk::ImageFileReader&lt; DefFieldType &gt;<span class="Apple-tab-span" style="white-space:pre">                                </span> <span class="Apple-tab-span" style="white-space:pre">        </span>                DefFieldReader;</div>
<div><br></div><div>typedef itk::DefaultDynamicMeshTraits&lt; double, 3, 2, double, double &gt;<span class="Apple-tab-span" style="white-space:pre">        </span> <span class="Apple-tab-span" style="white-space:pre">        </span>        MeshTraits;</div>
<div>typedef itk::Mesh&lt; double, 3, MeshTraits &gt;<span class="Apple-tab-span" style="white-space:pre">                                        </span>                        MeshType;</div><div>typedef itk::BinaryMask3DMeshSource&lt; ImageType, MeshType &gt; <span class="Apple-tab-span" style="white-space:pre">                        </span>MeshSourceType;</div>
<div>typedef itk::WarpMeshFilter&lt; MeshType, MeshType, DefFieldType &gt;<span class="Apple-tab-span" style="white-space:pre">                        </span>WarpMeshType;</div><div><br></div><div><br></div><div>// load binary volume of moving dataset in .nii format<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div>ReaderType::Pointer reader = ReaderType::New();</div><div>reader-&gt;SetFileName( argv[1] );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader-&gt;Update();</div><div>} catch ( itk::ExceptionObject&amp; exp ) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; exp &lt;&lt; std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return false;</div><div>}</div><div><br></div>
<div>// load deformation field (moving -&gt; fixed) in .mha format</div><div>DefFieldReader::Pointer defReader = DefFieldReader::New();</div><div>defReader-&gt;SetFileName( argv[2] );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>defReader-&gt;Update();</div>
<div>} catch ( itk::ExceptionObject&amp; exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; exp &lt;&lt; std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return false;</div>
<div>}</div><div><br></div><div>// extract mesh from volume</div><div>MeshSourceType::Pointer meshSource = MeshSourceType::New();</div><div>meshSource-&gt;SetInput( reader-&gt;GetOutput() );</div><div>meshSource-&gt;SetObjectValue( 1 );</div>
<div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>meshSource-&gt;Update();</div><div>} catch ( itk::ExceptionObject &amp;exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cerr &lt;&lt; &quot;Exception caught!&quot; &lt;&lt; exp &lt;&lt; std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>return false;</div><div>}</div><div><br></div><div>// apply deformation field to mesh</div><div>WarpMeshType::Pointer meshWarper = WarpMeshType::New();</div>
<div>meshWarper-&gt;SetInput( meshSource-&gt;GetOutput() );</div><div>meshWarper-&gt;SetDeformationField( defReader-&gt;GetOutput() );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>meshWarper-&gt;Update();</div>
<div>} catch ( itk::ExceptionObject&amp; exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; exp &lt;&lt; std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return false;</div>
<div>}</div>