[Insight-users] RE: VersorRigid3DTransform & Optimization

Radhika Sivaramakrishna radhika.sivaramakrishna at synarc.com
Wed, 14 Jan 2004 08:00:11 -0800


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C3DAB7.682685B2
Content-Type: text/plain

Hi Luis,
Thanks for the detailed explanation. As usual, thank you for helping to
solve the problem.

Radhika

-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
Sent: Tuesday, January 13, 2004 11:55 AM
To: Radhika Sivaramakrishna
Cc: 'insight-users at itk.org'
Subject: Re: [Insight-users] RE: VersorRigid3DTransform & Optimization


Hi Radhika,

Thanks for sending your code and the images you
were trying to register.

The real problem is that your images have set a
fictitious pixel spacing, specified just as

            1.0  x  1.0 x 1.0

while in reality the pixel size is probably
something like

            1.0  x  1.0 x 1.5

Having volumes of 256 x 256 x 164 pixels with
the fictitious spacing result in a physical
extent of

            256mm X 256mm X 164mm

which you can imagine as a slab of ratio

              1 :  1  : 0.6

When the VersorRigid3D optimizer is exploring
the overlap of two such volumes it attempts the
combination of small rotations around the X and
Y axis. In this combination the overlap between
the two slabs decreases dramatically.

The reason why the optimizer goes up-hill is that
the derivatives of the metric are computed with a
local measure based on the image gradient and the
transform's Jacobian. However when it comes to
compute the actual value of the metric, the  mean
squares are computed only over the number of pixels
in the overlapping regions. The result of  this
discrepancy is that the optimizer trusts the
direction of the local derivative, increases the
rotation out of the slab plane and then it is
surprised by a higher metric value due to the
reduction of the overlapping region.

All this unfortunate situation is avoided if you
set the correct spacing on the images.  By setting
the spacing to ( 1.0 x 1.0 x 1.5 ) and using
Initial step lengths of 0.1, the optimizer is able
to walk monotonically until registering the two images.

Here are the results of running the registration
with your code (once the image spacing was corrected).

--------------------------------------------
time ../bin/register 1000 0.10 0.0001 1000

TranslationScale = 1000
MaxStepLength    = 0.10
MinStepLength    = 0.0001
MaxIterations    = 100


  Finished writing fixed image
  Finished writing moving image
  Transform center before Initializer 0  0  0
  Transform center after Initializer 125.472  134.406  131.728
Intial Parameters =
[0, 0, 0, -1.15535, -0.252458, 0.0787966]
  Translationscale   = 1000

Starting Registration
0   389.774   [0.000498096, 0.0041635, 0.0187648, -1.08007, -0.203521, 
0.057368]
1   317.877   [-0.000193999, 0.00613385, 0.0335852, -1.09129, -0.239463, 
0.043748]
2   263.486   [-0.000382412, 0.00324637, 0.0471126, -1.09723, -0.280672, 
0.0436419]
3   209.872   [-0.000527169, 0.0029608, 0.0578632, -1.09992, -0.324779, 
0.0345101]
4   158.294   [-0.000379524, 0.00171905, 0.0670141, -1.10084, -0.370727, 
0.0277727]
5   111.143   [-0.000320991, 0.00114254, 0.0744852, -1.10084, -0.417742, 
0.019784]
6   68.8284   [-0.000143426, 0.000574566, 0.0808036, -1.09816, 
-0.465485, 0.0126217]
7   29.7093   [-0.000108126, 0.00016429, 0.0857882, -1.08819, -0.512831, 
0.00498878]
8   2.50794   [0.000514461, -0.000202424, 0.088728, -1.06125, -0.554066, 
-0.00109605]
9   3.38161   [-0.00236829, -6.93559e-05, 0.0862178, -1.07729, 
-0.537006, -0.00531419]
10   8.29858   [0.00100524, 0.000568953, 0.0866277, -1.07575, -0.531196, 
0.00318725]
11   2.39999   [-0.000579384, -0.000590192, 0.0867204, -1.07504, 
-0.534585, -0.000222387]
12   1.42702   [0.000199617, 0.000551113, 0.0869217, -1.07564, 
-0.534075, 0.000936169]
13   0.762661   [4.30728e-05, -5.54646e-05, 0.0869382, -1.07477, 
-0.534418, 0.000935771]
14   0.336736   [-0.000125978, 0.000172539, 0.0870684, -1.07465, 
-0.535641, 0.00020024]
15   0.340423   [1.00012e-05, 9.79281e-06, 0.0870758, -1.07425, 
-0.535421, 0.000669515]
16   0.273778   [-2.07788e-05, -3.31489e-06, 0.0870919, -1.07405, 
-0.535733, 0.000558016]
17   0.270637   [8.8092e-05, 6.80349e-05, 0.0871133, -1.07387, 
-0.535819, 0.000759256]
18   0.285837   [3.58203e-05, 1.68003e-05, 0.0871079, -1.07385, 
-0.535894, 0.000656946]
19   0.270217   [-1.8407e-05, -1.1657e-05, 0.0871026, -1.07386, 
-0.535974, 0.000529341]
Result =
  versor X      = -1.8407e-05
  versor Y      = -1.1657e-05
  versor Z      = 0.0871026
  Translation X = -1.07386
  Translation Y = -0.535974
  Translation Z = 0.000529341
  Iterations    = 21
  Metric value  = 0.26885
Matrix =
0.984826 -0.173543 -2.6432e-05
0.173543 0.984826 3.46433e-05
2.00188e-05 -3.87048e-05 1

Offset =
24.1588  -20.2759  0.00321983

  859.61s user 1.65s system 99% cpu 14:27.69 total
---------------------------------------------------------

As you can see, after iteration 9, the mean square metric is
down to 3.38 and the rotation angle is reporting 9.9 degrees
(your artificil rotation was 10 degrees).

Upto that point the registration has taken 7minutes in a
Pentium V, 1.8Ghz Linux machine (for code compiled with -O3).

With 8 minutes more of processing the registration drives the
metric down to 0.27 and the angle measure to 9.99 degrees.



Regards,



     Luis



------------------------------
Radhika Sivaramakrishna wrote:
> Hi Luis,
...
> 
> To answer your question, both images are T1-weighted MRI brain images.
> 
> Radhika
> 
> 

                                                     
-----------------------------------------------------  
Confidentiality Notice. 
This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message. If you are the intended recipient, please be
advised that the content of this message is subject to access, review and
disclosure by the sender's Email System Administrator.

------_=_NextPart_001_01C3DAB7.682685B2
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2656.87">
<TITLE>RE: [Insight-users] RE: VersorRigid3DTransform &amp; Optimization</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Hi Luis,</FONT>
<BR><FONT SIZE=2>Thanks for the detailed explanation. As usual, thank you for helping to solve the problem.</FONT>
</P>

<P><FONT SIZE=2>Radhika</FONT>
</P>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Luis Ibanez [<A HREF="mailto:luis.ibanez at kitware.com">mailto:luis.ibanez at kitware.com</A>] </FONT>
<BR><FONT SIZE=2>Sent: Tuesday, January 13, 2004 11:55 AM</FONT>
<BR><FONT SIZE=2>To: Radhika Sivaramakrishna</FONT>
<BR><FONT SIZE=2>Cc: 'insight-users at itk.org'</FONT>
<BR><FONT SIZE=2>Subject: Re: [Insight-users] RE: VersorRigid3DTransform &amp; Optimization</FONT>
</P>
<BR>

<P><FONT SIZE=2>Hi Radhika,</FONT>
</P>

<P><FONT SIZE=2>Thanks for sending your code and the images you</FONT>
<BR><FONT SIZE=2>were trying to register.</FONT>
</P>

<P><FONT SIZE=2>The real problem is that your images have set a</FONT>
<BR><FONT SIZE=2>fictitious pixel spacing, specified just as</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.0&nbsp; x&nbsp; 1.0 x 1.0</FONT>
</P>

<P><FONT SIZE=2>while in reality the pixel size is probably</FONT>
<BR><FONT SIZE=2>something like</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.0&nbsp; x&nbsp; 1.0 x 1.5</FONT>
</P>

<P><FONT SIZE=2>Having volumes of 256 x 256 x 164 pixels with</FONT>
<BR><FONT SIZE=2>the fictitious spacing result in a physical</FONT>
<BR><FONT SIZE=2>extent of</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 256mm X 256mm X 164mm</FONT>
</P>

<P><FONT SIZE=2>which you can imagine as a slab of ratio</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 :&nbsp; 1&nbsp; : 0.6</FONT>
</P>

<P><FONT SIZE=2>When the VersorRigid3D optimizer is exploring</FONT>
<BR><FONT SIZE=2>the overlap of two such volumes it attempts the</FONT>
<BR><FONT SIZE=2>combination of small rotations around the X and</FONT>
<BR><FONT SIZE=2>Y axis. In this combination the overlap between</FONT>
<BR><FONT SIZE=2>the two slabs decreases dramatically.</FONT>
</P>

<P><FONT SIZE=2>The reason why the optimizer goes up-hill is that</FONT>
<BR><FONT SIZE=2>the derivatives of the metric are computed with a</FONT>
<BR><FONT SIZE=2>local measure based on the image gradient and the</FONT>
<BR><FONT SIZE=2>transform's Jacobian. However when it comes to</FONT>
<BR><FONT SIZE=2>compute the actual value of the metric, the&nbsp; mean</FONT>
<BR><FONT SIZE=2>squares are computed only over the number of pixels</FONT>
<BR><FONT SIZE=2>in the overlapping regions. The result of&nbsp; this</FONT>
<BR><FONT SIZE=2>discrepancy is that the optimizer trusts the</FONT>
<BR><FONT SIZE=2>direction of the local derivative, increases the</FONT>
<BR><FONT SIZE=2>rotation out of the slab plane and then it is</FONT>
<BR><FONT SIZE=2>surprised by a higher metric value due to the</FONT>
<BR><FONT SIZE=2>reduction of the overlapping region.</FONT>
</P>

<P><FONT SIZE=2>All this unfortunate situation is avoided if you</FONT>
<BR><FONT SIZE=2>set the correct spacing on the images.&nbsp; By setting</FONT>
<BR><FONT SIZE=2>the spacing to ( 1.0 x 1.0 x 1.5 ) and using</FONT>
<BR><FONT SIZE=2>Initial step lengths of 0.1, the optimizer is able</FONT>
<BR><FONT SIZE=2>to walk monotonically until registering the two images.</FONT>
</P>

<P><FONT SIZE=2>Here are the results of running the registration</FONT>
<BR><FONT SIZE=2>with your code (once the image spacing was corrected).</FONT>
</P>

<P><FONT SIZE=2>--------------------------------------------</FONT>
<BR><FONT SIZE=2>time ../bin/register 1000 0.10 0.0001 1000</FONT>
</P>

<P><FONT SIZE=2>TranslationScale = 1000</FONT>
<BR><FONT SIZE=2>MaxStepLength&nbsp;&nbsp;&nbsp; = 0.10</FONT>
<BR><FONT SIZE=2>MinStepLength&nbsp;&nbsp;&nbsp; = 0.0001</FONT>
<BR><FONT SIZE=2>MaxIterations&nbsp;&nbsp;&nbsp; = 100</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp; Finished writing fixed image</FONT>
<BR><FONT SIZE=2>&nbsp; Finished writing moving image</FONT>
<BR><FONT SIZE=2>&nbsp; Transform center before Initializer 0&nbsp; 0&nbsp; 0</FONT>
<BR><FONT SIZE=2>&nbsp; Transform center after Initializer 125.472&nbsp; 134.406&nbsp; 131.728</FONT>
<BR><FONT SIZE=2>Intial Parameters =</FONT>
<BR><FONT SIZE=2>[0, 0, 0, -1.15535, -0.252458, 0.0787966]</FONT>
<BR><FONT SIZE=2>&nbsp; Translationscale&nbsp;&nbsp; = 1000</FONT>
</P>

<P><FONT SIZE=2>Starting Registration</FONT>
<BR><FONT SIZE=2>0&nbsp;&nbsp; 389.774&nbsp;&nbsp; [0.000498096, 0.0041635, 0.0187648, -1.08007, -0.203521, </FONT>
<BR><FONT SIZE=2>0.057368]</FONT>
<BR><FONT SIZE=2>1&nbsp;&nbsp; 317.877&nbsp;&nbsp; [-0.000193999, 0.00613385, 0.0335852, -1.09129, -0.239463, </FONT>
<BR><FONT SIZE=2>0.043748]</FONT>
<BR><FONT SIZE=2>2&nbsp;&nbsp; 263.486&nbsp;&nbsp; [-0.000382412, 0.00324637, 0.0471126, -1.09723, -0.280672, </FONT>
<BR><FONT SIZE=2>0.0436419]</FONT>
<BR><FONT SIZE=2>3&nbsp;&nbsp; 209.872&nbsp;&nbsp; [-0.000527169, 0.0029608, 0.0578632, -1.09992, -0.324779, </FONT>
<BR><FONT SIZE=2>0.0345101]</FONT>
<BR><FONT SIZE=2>4&nbsp;&nbsp; 158.294&nbsp;&nbsp; [-0.000379524, 0.00171905, 0.0670141, -1.10084, -0.370727, </FONT>
<BR><FONT SIZE=2>0.0277727]</FONT>
<BR><FONT SIZE=2>5&nbsp;&nbsp; 111.143&nbsp;&nbsp; [-0.000320991, 0.00114254, 0.0744852, -1.10084, -0.417742, </FONT>
<BR><FONT SIZE=2>0.019784]</FONT>
<BR><FONT SIZE=2>6&nbsp;&nbsp; 68.8284&nbsp;&nbsp; [-0.000143426, 0.000574566, 0.0808036, -1.09816, </FONT>
<BR><FONT SIZE=2>-0.465485, 0.0126217]</FONT>
<BR><FONT SIZE=2>7&nbsp;&nbsp; 29.7093&nbsp;&nbsp; [-0.000108126, 0.00016429, 0.0857882, -1.08819, -0.512831, </FONT>
<BR><FONT SIZE=2>0.00498878]</FONT>
<BR><FONT SIZE=2>8&nbsp;&nbsp; 2.50794&nbsp;&nbsp; [0.000514461, -0.000202424, 0.088728, -1.06125, -0.554066, </FONT>
<BR><FONT SIZE=2>-0.00109605]</FONT>
<BR><FONT SIZE=2>9&nbsp;&nbsp; 3.38161&nbsp;&nbsp; [-0.00236829, -6.93559e-05, 0.0862178, -1.07729, </FONT>
<BR><FONT SIZE=2>-0.537006, -0.00531419]</FONT>
<BR><FONT SIZE=2>10&nbsp;&nbsp; 8.29858&nbsp;&nbsp; [0.00100524, 0.000568953, 0.0866277, -1.07575, -0.531196, </FONT>
<BR><FONT SIZE=2>0.00318725]</FONT>
<BR><FONT SIZE=2>11&nbsp;&nbsp; 2.39999&nbsp;&nbsp; [-0.000579384, -0.000590192, 0.0867204, -1.07504, </FONT>
<BR><FONT SIZE=2>-0.534585, -0.000222387]</FONT>
<BR><FONT SIZE=2>12&nbsp;&nbsp; 1.42702&nbsp;&nbsp; [0.000199617, 0.000551113, 0.0869217, -1.07564, </FONT>
<BR><FONT SIZE=2>-0.534075, 0.000936169]</FONT>
<BR><FONT SIZE=2>13&nbsp;&nbsp; 0.762661&nbsp;&nbsp; [4.30728e-05, -5.54646e-05, 0.0869382, -1.07477, </FONT>
<BR><FONT SIZE=2>-0.534418, 0.000935771]</FONT>
<BR><FONT SIZE=2>14&nbsp;&nbsp; 0.336736&nbsp;&nbsp; [-0.000125978, 0.000172539, 0.0870684, -1.07465, </FONT>
<BR><FONT SIZE=2>-0.535641, 0.00020024]</FONT>
<BR><FONT SIZE=2>15&nbsp;&nbsp; 0.340423&nbsp;&nbsp; [1.00012e-05, 9.79281e-06, 0.0870758, -1.07425, </FONT>
<BR><FONT SIZE=2>-0.535421, 0.000669515]</FONT>
<BR><FONT SIZE=2>16&nbsp;&nbsp; 0.273778&nbsp;&nbsp; [-2.07788e-05, -3.31489e-06, 0.0870919, -1.07405, </FONT>
<BR><FONT SIZE=2>-0.535733, 0.000558016]</FONT>
<BR><FONT SIZE=2>17&nbsp;&nbsp; 0.270637&nbsp;&nbsp; [8.8092e-05, 6.80349e-05, 0.0871133, -1.07387, </FONT>
<BR><FONT SIZE=2>-0.535819, 0.000759256]</FONT>
<BR><FONT SIZE=2>18&nbsp;&nbsp; 0.285837&nbsp;&nbsp; [3.58203e-05, 1.68003e-05, 0.0871079, -1.07385, </FONT>
<BR><FONT SIZE=2>-0.535894, 0.000656946]</FONT>
<BR><FONT SIZE=2>19&nbsp;&nbsp; 0.270217&nbsp;&nbsp; [-1.8407e-05, -1.1657e-05, 0.0871026, -1.07386, </FONT>
<BR><FONT SIZE=2>-0.535974, 0.000529341]</FONT>
<BR><FONT SIZE=2>Result =</FONT>
<BR><FONT SIZE=2>&nbsp; versor X&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = -1.8407e-05</FONT>
<BR><FONT SIZE=2>&nbsp; versor Y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = -1.1657e-05</FONT>
<BR><FONT SIZE=2>&nbsp; versor Z&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0.0871026</FONT>
<BR><FONT SIZE=2>&nbsp; Translation X = -1.07386</FONT>
<BR><FONT SIZE=2>&nbsp; Translation Y = -0.535974</FONT>
<BR><FONT SIZE=2>&nbsp; Translation Z = 0.000529341</FONT>
<BR><FONT SIZE=2>&nbsp; Iterations&nbsp;&nbsp;&nbsp; = 21</FONT>
<BR><FONT SIZE=2>&nbsp; Metric value&nbsp; = 0.26885</FONT>
<BR><FONT SIZE=2>Matrix =</FONT>
<BR><FONT SIZE=2>0.984826 -0.173543 -2.6432e-05</FONT>
<BR><FONT SIZE=2>0.173543 0.984826 3.46433e-05</FONT>
<BR><FONT SIZE=2>2.00188e-05 -3.87048e-05 1</FONT>
</P>

<P><FONT SIZE=2>Offset =</FONT>
<BR><FONT SIZE=2>24.1588&nbsp; -20.2759&nbsp; 0.00321983</FONT>
</P>

<P><FONT SIZE=2>&nbsp; 859.61s user 1.65s system 99% cpu 14:27.69 total</FONT>
<BR><FONT SIZE=2>---------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=2>As you can see, after iteration 9, the mean square metric is</FONT>
<BR><FONT SIZE=2>down to 3.38 and the rotation angle is reporting 9.9 degrees</FONT>
<BR><FONT SIZE=2>(your artificil rotation was 10 degrees).</FONT>
</P>

<P><FONT SIZE=2>Upto that point the registration has taken 7minutes in a</FONT>
<BR><FONT SIZE=2>Pentium V, 1.8Ghz Linux machine (for code compiled with -O3).</FONT>
</P>

<P><FONT SIZE=2>With 8 minutes more of processing the registration drives the</FONT>
<BR><FONT SIZE=2>metric down to 0.27 and the angle measure to 9.99 degrees.</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>Regards,</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp; Luis</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>------------------------------</FONT>
<BR><FONT SIZE=2>Radhika Sivaramakrishna wrote:</FONT>
<BR><FONT SIZE=2>&gt; Hi Luis,</FONT>
<BR><FONT SIZE=2>...</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; To answer your question, both images are T1-weighted MRI brain images.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Radhika</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>-----------------------------------------------------&nbsp; </FONT>
<BR><FONT SIZE=2>Confidentiality Notice. </FONT>
<BR><FONT SIZE=2>This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. If you are the intended recipient, please be advised that the content of this message is subject to access, review and disclosure by the sender's Email System Administrator.</FONT></P>

</BODY>
</HTML>
------_=_NextPart_001_01C3DAB7.682685B2--