[Insight-users] warpmeshfilter

steffen schumann medmlb at gmail.com
Tue Apr 5 08:06:27 EDT 2011


Hi all,
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.

Thanks for any input,
Michael B.



typedef itk::Image< unsigned short, 3 >                 ImageType;
typedef itk::ImageFileReader< imageType >
 ReaderType;
typedef itk::Vector< double, 3 >                                 VectorType;
typedef itk::Image< VectorType, 3 >                         DefFieldType;
typedef itk::ImageFileReader< DefFieldType >
 DefFieldReader;

typedef itk::DefaultDynamicMeshTraits< double, 3, 2, double, double >
   MeshTraits;
typedef itk::Mesh< double, 3, MeshTraits >                         MeshType;
typedef itk::BinaryMask3DMeshSource< ImageType, MeshType > MeshSourceType;
typedef itk::WarpMeshFilter< MeshType, MeshType, DefFieldType >
WarpMeshType;


// load binary volume of moving dataset in .nii format
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
try {
reader->Update();
} catch ( itk::ExceptionObject& exp ) {
std::cout << exp << std::endl;
return false;
}

// load deformation field (moving -> fixed) in .mha format
DefFieldReader::Pointer defReader = DefFieldReader::New();
defReader->SetFileName( argv[2] );
try {
defReader->Update();
} catch ( itk::ExceptionObject& exp ) {
std::cout << exp << std::endl;
return false;
}

// extract mesh from volume
MeshSourceType::Pointer meshSource = MeshSourceType::New();
meshSource->SetInput( reader->GetOutput() );
meshSource->SetObjectValue( 1 );
try {
meshSource->Update();
} catch ( itk::ExceptionObject &exp ) {
std::cerr << "Exception caught!" << exp << std::endl;
return false;
}

// apply deformation field to mesh
WarpMeshType::Pointer meshWarper = WarpMeshType::New();
meshWarper->SetInput( meshSource->GetOutput() );
meshWarper->SetDeformationField( defReader->GetOutput() );
try {
meshWarper->Update();
} catch ( itk::ExceptionObject& exp ) {
std::cout << exp << std::endl;
return false;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110405/c00d6d79/attachment.htm>


More information about the Insight-users mailing list