[Insight-users] Crash when using multi-grid BSpline transform in the framework of multi-resolution image registration
Gareth Price
Gareth.Price at physics.cr.man.ac.uk
Fri Aug 10 03:36:26 EDT 2012
Hi there,
The way I went about doing this was to use a standard
ResampleImageFilter (templated over BSplineTransformType::ImageType to
BSplineTransformType::ImageType) on each of the B Spline's component
coefficient images (obtained via
initialBSplineTransformPointer->GetCoefficientImages()[k] where k is an
image component), setting the resampler output spacing etc to the new
transform's corresponding coefficient image values.
You can then decompose each resampled co-efficient image into B Spline
transform parameters using BSplineDecompositionImageFilter and place
these into the new transform's parameter vector using a standard
ImageRegionIterator templated over the BSplineTransformType::ImageType.
I created the new level transform using the standard method as described
in the DeformableRegistration8 example or in the ITK migration guide
FAQ:
http://itk.org/migrationv4/index.php?sid=4480&lang=en&action=artikel&cat
=3&id=82&artlang=en
Not sure if this is the best or recommended method but it worked OK in
my case
Hope this helps, Gareth
-----Original Message-----
From: insight-users-bounces at itk.org
[mailto:insight-users-bounces at itk.org] On Behalf Of lien lee
Sent: 09 August 2012 22:36
To: insight-users at itk.org
Subject: [Insight-users] Crash when using multi-grid BSpline transform
in the framework of multi-resolution image registration
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().GetNumberOfPix
els() ) ) );
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/20120810/3e06c6fe/attachment.htm>
More information about the Insight-users
mailing list