[Insight-users] Crash when using multi-grid BSpline transform in the framework of multi-resolution image registration
lien lee
lienlee at gmail.com
Thu Aug 9 17:35:45 EDT 2012
Hi all,
I am trying to do BSpline transform with multi-resolution image
registration, but I got some trouble on how to configure the itk::
BSplineDeformableTransform<double,3,3> object when moving from one
resolution level to the next. Through google-search, I can not find any
clear solution for this. ITK does have an example with multi-grid BSpline
transform, but it is not in the framework of multi-resolution image
registration.
I tried the stuff of GridScheduleComputer and
UpsampleBSplineParametersFilter found in ITK-journal based on ITK's
multi-resolution image registration example. Unfortunately, I got a crash
when proceeding from resolution level 0 to level 1. What I did is
something like this:
//===================================================================================
void
RegistrationInterfaceCommand::Execute(itk::Object * object,
const itk::EventObject & event)
{
....
if (Registration->GetCurrentLevel() != 0)
{
Optimizer->SetMaximumStepLength( Optimizer->GetMaximumStepLength()
/ 4.0 );
Optimizer->SetMinimumStepLength( Optimizer->GetMinimumStepLength()
/ 10.0 );
Optimizer->SetNumberOfIterations( 100 );
Optimizer->SetRelaxationFactor( 0.7 );
typedef
itk::UpsampleBSplineParametersFilter<TransformType::ParametersType,
TransformType::ImageType>
GridUpsamplerType;
GridUpsamplerType::Pointer Upsampler = GridUpsamplerType::New();
Upsampler->SetCurrentGridOrigin(Transform->GetGridOrigin());
Upsampler->SetCurrentGridSpacing(Transform->GetGridSpacing());
Upsampler->SetCurrentGridRegion(Transform->GetGridRegion());
TransformType::OriginType NewOrigin;
TransformType::SpacingType NewSpacing;
TransformType::RegionType NewRegion;
mGridScheduleComputer->GetBSplineGrid(vLevel, NewRegion,
NewSpacing, NewOrigin);
Upsampler->SetRequiredGridOrigin(NewOrigin);
Upsampler->SetRequiredGridSpacing(NewSpacing);
Upsampler->SetRequiredGridRegion(NewRegion);
TransformType::ParametersType Parameters =
Registration->GetLastTransformParameters();
TransformType::ParametersType NewParameters;
Upsampler->UpsampleParameters(Parameters, NewParameters);
Transform->SetGridOrigin(NewOrigin);
Transform->SetGridSpacing(NewSpacing);
Transform->SetGridRegion(NewRegion);
Transform->SetParameters(NewParameters);
{
std::cout << "Parameters: " <<
Transform->GetNumberOfParameters() << std::endl;
std::cout << "Full transform description ";
Transform->Print( std::cout );
}
Registration->SetInitialTransformParameters(Transform->GetParameters());
Registration->SetInitialTransformParametersOfNextLevel(NewParameters);
unsigned int NumberOfParameters =
Transform->GetNumberOfParameters();
const unsigned long NumberOfSamples =
static_cast<unsigned long>(
vcl_sqrt( static_cast<double>( NumberOfParameters ) *
static_cast<double>(
Registration->GetFixedImage()->GetLargestPossibleRegion().GetNumberOfPixels()
) ) );
Metric->SetNumberOfSpatialSamples( NumberOfSamples );
OptimizerType::ScalesType OptimizerScales =
OptimizerType::ScalesType( NumberOfParameters );
OptimizerScales.Fill( 1.0 );
Optimizer->SetScales( OptimizerScales );
}
....
}
//===================================================================================
I debugged into the code. I found that when proceeding from level 0 to
level 1, an exception was caught as:
"
ExceptionObject caught!
itk::ExceptionObject (000000000000B6D6A0)
location: "void __cdecl itkLLBSplineBaseTransform<double, 3,
3>::SetParameters(const calss itk::OptimizerParameters<double> &)"
File: d\projects\itk\insighttoolkit-4.1.0\modules\core\transform\include
itkBSplineBaseTransform.hxx
Line 92
Description: itk::ERROR: BSplineDeformableTransform (00000000004595520):
Mismatch between parameters size 3435973826 and expected number of
parameters 5070
"
Am I wrong somewhere? I am working with ITK4.1 in Visual Studio 2010. Or,
could you please point me any direction? Any comments will be appreciated
by the ITK newbie, me. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120809/a5aa02db/attachment.htm>
More information about the Insight-users
mailing list