<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< unsigned short, 3 ><span class="Apple-tab-span" style="white-space:pre">                                                </span> ImageType;</div>
<div>typedef itk::ImageFileReader< imageType ><span class="Apple-tab-span" style="white-space:pre">                                        </span> ReaderType;</div><div>typedef itk::Vector< double, 3 ><span class="Apple-tab-span" style="white-space:pre">                                                </span> VectorType;</div>
<div>typedef itk::Image< VectorType, 3 ><span class="Apple-tab-span" style="white-space:pre">                                                </span> DefFieldType;</div><div>typedef itk::ImageFileReader< DefFieldType ><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< double, 3, 2, double, double ><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< double, 3, MeshTraits ><span class="Apple-tab-span" style="white-space:pre">                                        </span> MeshType;</div><div>typedef itk::BinaryMask3DMeshSource< ImageType, MeshType > <span class="Apple-tab-span" style="white-space:pre">                        </span>MeshSourceType;</div>
<div>typedef itk::WarpMeshFilter< MeshType, MeshType, DefFieldType ><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->SetFileName( argv[1] );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader->Update();</div><div>} catch ( itk::ExceptionObject& exp ) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << exp << 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 -> fixed) in .mha format</div><div>DefFieldReader::Pointer defReader = DefFieldReader::New();</div><div>defReader->SetFileName( argv[2] );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>defReader->Update();</div>
<div>} catch ( itk::ExceptionObject& exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << exp << 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->SetInput( reader->GetOutput() );</div><div>meshSource->SetObjectValue( 1 );</div>
<div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>meshSource->Update();</div><div>} catch ( itk::ExceptionObject &exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cerr << "Exception caught!" << exp << 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->SetInput( meshSource->GetOutput() );</div><div>meshWarper->SetDeformationField( defReader->GetOutput() );</div><div>try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>meshWarper->Update();</div>
<div>} catch ( itk::ExceptionObject& exp ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << exp << std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return false;</div>
<div>}</div>