<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
h1
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        page-break-after:avoid;
        font-size:16.0pt;
        font-family:Arial;}
h2
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        page-break-after:avoid;
        font-size:14.0pt;
        font-family:Arial;
        font-style:italic;}
h3
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        page-break-after:avoid;
        font-size:13.0pt;
        font-family:Arial;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.EPSRCHeading1, li.EPSRCHeading1, div.EPSRCHeading1
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        page-break-after:avoid;
        font-size:14.0pt;
        font-family:Calibri;
        font-weight:bold;}
p.EPSRCHeading2, li.EPSRCHeading2, div.EPSRCHeading2
        {margin-top:3.0pt;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:0cm;
        margin-bottom:.0001pt;
        page-break-after:avoid;
        font-size:12.0pt;
        font-family:Calibri;
        text-transform:uppercase;
        font-weight:bold;
        font-style:italic;}
p.EPSRCHeading3, li.EPSRCHeading3, div.EPSRCHeading3
        {margin-top:3.0pt;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:0cm;
        margin-bottom:.0001pt;
        page-break-after:avoid;
        font-size:11.0pt;
        font-family:Calibri;
        font-weight:bold;
        font-style:italic;}
p.EPSRCNormal, li.EPSRCNormal, div.EPSRCNormal
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        text-indent:17.0pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCBullets, li.EPSRCBullets, div.EPSRCBullets
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:19.85pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCBulletsCxSpFirst, li.EPSRCBulletsCxSpFirst, div.EPSRCBulletsCxSpFirst
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:19.85pt;
        margin-bottom:.0001pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCBulletsCxSpMiddle, li.EPSRCBulletsCxSpMiddle, div.EPSRCBulletsCxSpMiddle
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:19.85pt;
        margin-bottom:.0001pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCBulletsCxSpLast, li.EPSRCBulletsCxSpLast, div.EPSRCBulletsCxSpLast
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:19.85pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCNumbering, li.EPSRCNumbering, div.EPSRCNumbering
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:19.85pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCNumberingCxSpFirst, li.EPSRCNumberingCxSpFirst, div.EPSRCNumberingCxSpFirst
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:19.85pt;
        margin-bottom:.0001pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCNumberingCxSpMiddle, li.EPSRCNumberingCxSpMiddle, div.EPSRCNumberingCxSpMiddle
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:19.85pt;
        margin-bottom:.0001pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.EPSRCNumberingCxSpLast, li.EPSRCNumberingCxSpLast, div.EPSRCNumberingCxSpLast
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:19.85pt;
        text-indent:-11.35pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.StyleEPSRCNormalCentered, li.StyleEPSRCNormalCentered, div.StyleEPSRCNormalCentered
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        text-align:center;
        text-indent:17.0pt;
        line-height:12.0pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.CVList, li.CVList, div.CVList
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:36.0pt;
        text-align:justify;
        text-indent:-18.0pt;
        font-size:12.0pt;
        font-family:"Times New Roman";
        color:black;}
span.EmailStyle25
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:21.0cm 842.0pt;
        margin:70.9pt 70.9pt 70.9pt 70.9pt;}
div.Section1
        {page:Section1;}
/* List Definitions */
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hi there,</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>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. </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>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.</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I created the new level transform using the standard method
as described in the DeformableRegistration8 example or in the ITK migration
guide FAQ:</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><a
href="http://itk.org/migrationv4/index.php?sid=4480&lang=en&action=artikel&cat=3&id=82&artlang=en">http://itk.org/migrationv4/index.php?sid=4480&lang=en&action=artikel&cat=3&id=82&artlang=en</a></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Not sure if this is the best or recommended method but it worked
OK in my case</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hope this helps, Gareth</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
insight-users-bounces@itk.org [mailto:insight-users-bounces@itk.org] <b><span
style='font-weight:bold'>On Behalf Of </span></b>lien lee<br>
<b><span style='font-weight:bold'>Sent:</span></b> 09 August 2012 22:36<br>
<b><span style='font-weight:bold'>To:</span></b> insight-users@itk.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [Insight-users] Crash
when using multi-grid BSpline transform in the framework of multi-resolution
image registration</span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>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::</span></font></p>
<div id=":5q">
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>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!</span></font></p>
</div>
<p class=MsoNormal style='margin-right:0cm;margin-bottom:12.0pt;margin-left:
36.0pt'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'> </span></font></p>
</div>
</body>
</html>