Hi all,<br><br>I am trying to do BSpline transform with multi-resolution
image registration, but I got some trouble on how to configure the itk::<div id=":5q">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.<br>
<br>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:<br>
<br>//===================================================================================<br>void <br>RegistrationInterfaceCommand::Execute(itk::Object * object, <br> const itk::EventObject & event)<br>{<br>....<br>
<br> if (Registration->GetCurrentLevel() != 0)<br> {<br> Optimizer->SetMaximumStepLength( Optimizer->GetMaximumStepLength() / 4.0 );<br> Optimizer->SetMinimumStepLength( Optimizer->GetMinimumStepLength() / 10.0 );<br>
Optimizer->SetNumberOfIterations( 100 );<br> Optimizer->SetRelaxationFactor( 0.7 );<br> <br><br> typedef itk::UpsampleBSplineParametersFilter<TransformType::ParametersType, TransformType::ImageType><br>
GridUpsamplerType;<br> <br> GridUpsamplerType::Pointer Upsampler = GridUpsamplerType::New();<br> Upsampler->SetCurrentGridOrigin(Transform->GetGridOrigin());<br> Upsampler->SetCurrentGridSpacing(Transform->GetGridSpacing());<br>
Upsampler->SetCurrentGridRegion(Transform->GetGridRegion());<br><br> TransformType::OriginType NewOrigin;<br> TransformType::SpacingType NewSpacing;<br> TransformType::RegionType NewRegion;<br>
mGridScheduleComputer->GetBSplineGrid(vLevel, NewRegion, NewSpacing, NewOrigin);<br><br> Upsampler->SetRequiredGridOrigin(NewOrigin);<br> Upsampler->SetRequiredGridSpacing(NewSpacing);<br> Upsampler->SetRequiredGridRegion(NewRegion);<br>
<br> TransformType::ParametersType Parameters = Registration->GetLastTransformParameters();<br> TransformType::ParametersType NewParameters;<br> Upsampler->UpsampleParameters(Parameters, NewParameters);<br>
<br> Transform->SetGridOrigin(NewOrigin);<br> Transform->SetGridSpacing(NewSpacing);<br> Transform->SetGridRegion(NewRegion);<br> Transform->SetParameters(NewParameters);<br>
<br> {<br> std::cout << "Parameters: " << Transform->GetNumberOfParameters() << std::endl;<br> std::cout << "Full transform description ";<br> Transform->Print( std::cout ); <br>
}<br><br> Registration->SetInitialTransformParameters(Transform->GetParameters());<br> Registration->SetInitialTransformParametersOfNextLevel(NewParameters);<br>
unsigned int NumberOfParameters = Transform->GetNumberOfParameters();<br><br> const unsigned long NumberOfSamples =<br> static_cast<unsigned long>(<br> vcl_sqrt( static_cast<double>( NumberOfParameters ) *<br>
static_cast<double>( Registration->GetFixedImage()->GetLargestPossibleRegion().GetNumberOfPixels() ) ) );<br>
Metric->SetNumberOfSpatialSamples( NumberOfSamples );<br><br> OptimizerType::ScalesType OptimizerScales = OptimizerType::ScalesType( NumberOfParameters );<br>
OptimizerScales.Fill( 1.0 );<br> Optimizer->SetScales( OptimizerScales );<br> }<br>....<br>}<br>//===================================================================================<br>
<br>I debugged into the code. I found that when proceeding from level 0 to level 1, an exception was caught
as:<br><br><br>"<br>ExceptionObject caught!<br><br>itk::ExceptionObject (000000000000B6D6A0)<br>location: "void __cdecl itkLLBSplineBaseTransform<double, 3, 3>::SetParameters(const calss itk::OptimizerParameters<double> &)"<br>
File: d\projects\itk\insighttoolkit-4.1.0\modules\core\transform\include<br>itkBSplineBaseTransform.hxx<br>Line 92<br>Description: itk::ERROR: BSplineDeformableTransform (00000000004595520): Mismatch between parameters size 3435973826 and expected number of parameters 5070<br>
"<br><br>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!</div><br><br>