hammer_faq > An example of using HAMMER in ITK
Nov 11, 2011  03:11 PM | Guorong Wu
An example of using HAMMER in ITK
Here we demonstrate how to use HAMMER registration filter in ITK for deformable registration of the two T1 MR brains. The source code can be found in source code package (/src/test/HammerRegistrationTest.cxx).

First of all, we need to initialize the HAMMER registration filter instance as follows:
typedef itk::HammerDeformableRegistrationImageFilter RegistrationFilterType;
RegistrationFilterType::Pointer hammer = RegistrationFilterType::New();

Then, the fixed and the moving images should be specified:
hammer->SetFixedImage( fImg0 );
hammer->SetMovingImage( mImg0 );

Next, we need to specify the parameters used in HAMMER:
hammer->SetIterations( iterations[0], iterations[1], iterations[2] );
hammer->SetDeformRate(0.05);
hammer->SetPointMatchingThreshold(0.8);
hammer->SetSubvolumeSimilarityThreshold(0.6);
hammer->SetSearchRadius(12);

Finally, by calling hammer->Update(), it will return a dense deformation field that points from the fixed image to the moving image. The following lines of code are used to warp the subject image with itk::WarpImageFilter:
typedef itk::WarpImageFilter  WarperType;
typedef itk::NearestNeighborInterpolateImageFunction  InterpolatorType;
WarperType::Pointer warper = WarperType::New();
InterpolatorType::Pointer interpolator = InterpolatorType::New();
warper->SetInput( mImg0 );
warper->SetInterpolator( interpolator );
warper->SetOutputDirection( fImg0->GetDirection() );
warper->SetOutputSpacing( fImg0->GetSpacing() );
warper->SetOutputOrigin( fImg0->GetOrigin() );
warper->SetDeformationField(hammer->GetOutput());
WriterType::Pointer writer =  WriterType::New();
writer->SetFileName( resampledFilename.c_str() );
writer->SetInput( warper->GetOutput() );
writer->Update();

Threaded View

TitleAuthorDate
An example of using HAMMER in ITK
Guorong Wu Nov 11, 2011
Guorong Wu Nov 16, 2011