<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'>&nbsp;</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&#8217;s component coefficient images (obtained via initialBSplineTransformPointer-&gt;GetCoefficientImages()[k]
where k is an image component), setting the resampler output spacing etc to the
new transform&#8217;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'>&nbsp;</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&#8217;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'>&nbsp;</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&amp;lang=en&amp;action=artikel&amp;cat=3&amp;id=82&amp;artlang=en">http://itk.org/migrationv4/index.php?sid=4480&amp;lang=en&amp;action=artikel&amp;cat=3&amp;id=82&amp;artlang=en</a></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</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'>&nbsp;</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'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</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'>&nbsp;</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&lt;double,3,3&gt;
object when moving from one resolution level to the next.&nbsp; 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.&nbsp; Unfortunately, I got a crash when proceeding from resolution
level 0 to level 1.&nbsp; What I did is something like this:<br>
<br>
//===================================================================================<br>
void <br>
RegistrationInterfaceCommand::Execute(itk::Object * object, <br>
&nbsp;&nbsp;&nbsp; const itk::EventObject &amp; event)<br>
{<br>
....<br>
<br>
&nbsp;&nbsp;&nbsp; if (Registration-&gt;GetCurrentLevel() != 0)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Optimizer-&gt;SetMaximumStepLength(
Optimizer-&gt;GetMaximumStepLength() / 4.0 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Optimizer-&gt;SetMinimumStepLength(
Optimizer-&gt;GetMinimumStepLength() / 10.0 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Optimizer-&gt;SetNumberOfIterations( 100
);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Optimizer-&gt;SetRelaxationFactor( 0.7 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef
itk::UpsampleBSplineParametersFilter&lt;TransformType::ParametersType,
TransformType::ImageType&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; GridUpsamplerType;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GridUpsamplerType::Pointer Upsampler =
GridUpsamplerType::New();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Upsampler-&gt;SetCurrentGridOrigin(Transform-&gt;GetGridOrigin());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Upsampler-&gt;SetCurrentGridSpacing(Transform-&gt;GetGridSpacing());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Upsampler-&gt;SetCurrentGridRegion(Transform-&gt;GetGridRegion());<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TransformType::OriginType&nbsp;&nbsp;
&nbsp;NewOrigin;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TransformType::SpacingType&nbsp;&nbsp;
&nbsp;NewSpacing;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TransformType::RegionType&nbsp;&nbsp;
&nbsp;NewRegion;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
mGridScheduleComputer-&gt;GetBSplineGrid(vLevel, NewRegion, NewSpacing,
NewOrigin);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Upsampler-&gt;SetRequiredGridOrigin(NewOrigin);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Upsampler-&gt;SetRequiredGridSpacing(NewSpacing);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Upsampler-&gt;SetRequiredGridRegion(NewRegion);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TransformType::ParametersType Parameters
= Registration-&gt;GetLastTransformParameters();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TransformType::ParametersType
NewParameters;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Upsampler-&gt;UpsampleParameters(Parameters,
NewParameters);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transform-&gt;SetGridOrigin(NewOrigin);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transform-&gt;SetGridSpacing(NewSpacing);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transform-&gt;SetGridRegion(NewRegion);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Transform-&gt;SetParameters(NewParameters);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout
&lt;&lt; &quot;Parameters: &quot; &lt;&lt;
Transform-&gt;GetNumberOfParameters() &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt;
&quot;Full transform description &quot;;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Transform-&gt;Print(
std::cout );&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Registration-&gt;SetInitialTransformParameters(Transform-&gt;GetParameters());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Registration-&gt;SetInitialTransformParametersOfNextLevel(NewParameters);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned int NumberOfParameters =
Transform-&gt;GetNumberOfParameters();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; const unsigned long NumberOfSamples =<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; static_cast&lt;unsigned
long&gt;(<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; vcl_sqrt(
static_cast&lt;double&gt;( NumberOfParameters ) *<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
static_cast&lt;double&gt;(
Registration-&gt;GetFixedImage()-&gt;GetLargestPossibleRegion().GetNumberOfPixels()
) ) );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Metric-&gt;SetNumberOfSpatialSamples(
NumberOfSamples );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OptimizerType::ScalesType OptimizerScales
= OptimizerType::ScalesType( NumberOfParameters );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OptimizerScales.Fill( 1.0 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Optimizer-&gt;SetScales( OptimizerScales
);<br>
&nbsp;&nbsp;&nbsp; }<br>
....<br>
}<br>
//===================================================================================<br>
<br>
I debugged into the code.&nbsp; I found that when proceeding from level 0 to
level 1, an exception was caught as:<br>
<br>
<br>
&quot;<br>
ExceptionObject caught!<br>
<br>
itk::ExceptionObject (000000000000B6D6A0)<br>
location: &quot;void __cdecl itkLLBSplineBaseTransform&lt;double, 3,
3&gt;::SetParameters(const calss itk::OptimizerParameters&lt;double&gt;
&amp;)&quot;<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>
&quot;<br>
<br>
Am I wrong somewhere? I am working with ITK4.1 in Visual Studio 2010.&nbsp; Or,
could you please point me any direction?&nbsp; 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'>&nbsp;</span></font></p>

</div>

</body>

</html>