Hi Luis<br><br>I changed the transform to Similarity2DTransform as you proposed and had much better results.<br>The changes were ...<br>//// METRIC SCALES<div class="Ih2E3d"><br>typedef MetricType::ScalesType ScalesType;<br>
ScalesType scales( numberOfParameters );<br></div>
scales[0] = 10.0; //scale<br>scales[1] = 1.0; //angle<br>scales[2] = 0.01; //Translation X<br>scales[3] = 0.01; //Translation Y<br> metric->SetDerivativeStepLengt<div id="1fi9" class="ArwC7c ckChnd">hScales(scales);<br>
.......<br>///// OPTIMIZER SCALES <br>
<br> FixedImageType::RegionType region = fixedImage->GetLargestPossibleRegion();<br> FixedImageType::SizeType size = region.GetSize();<br> FixedImageType::SpacingType spacing = fixedImage->GetSpacing();<div class="Ih2E3d">
<br><br>
typedef OptimizerType::ScalesType OptimizerScalesType;<br>
OptimizerScalesType optimizerScales( transform->GetNumberOfParameters() );<br></div> optimizerScales[0] = 10.0;<br> optimizerScales[1] = 10.0;<br> optimizerScales[2] = 1.0 / ( 0.1 * size[0] * spacing[0] );<br>
optimizerScales[3] = 1.0 / ( 0.1 * size[1] * spacing[1] );<br>
optimizer->SetScales( optimizerScales );<br>...............<br>
<p><br></p><p>results (5000 iterations) <span><br></span>scale
0.833371, <span></span>angle
-0.175554,<span> </span>TrX<span> </span>7.3605,<span> </span>TrY<span> </span>7.89029,<span> </span>Metric
1.31231,<span>MSDafter</span>
204.473, CCafter<span></span><span> </span>0.984774</p><p>MSD=MeanSquareDifference after registration, CC=CorrelationCoefficient after registration</p><p>
</p>
<p>results (7000 iterations)<span><br></span>scale
0.833493, <span></span>angle
-0.175483,<span> </span>TrX<span> </span>7.21419,<span></span>TrY<span> </span>7.7625,<span> </span>Metric
1.33357,<span></span>MSDafter
153.119,<span> </span>CC<span>after </span>0.988688</p>
<p>
</p><p>results (15000 iterations)<br>scale
0.833746,<span> </span>angle
-0.174136, <span></span>TrX<span> </span>6.86705,<span></span>TrY<span> </span>7.43349,<span></span>Metric
1.31354, MSDafter 182.968, <span></span>CC<span>after </span><span> </span>0.986441 <br></p><p>The "optimum" results taken from mattes metric where
</p>
<p>results<span><br></span>scale
0.832628<span> </span>angle
-0.174455<span> </span>TrX<span> </span>7.37987<span> </span>TrY<span> </span>8.52768<span> </span>Metric
-1.42415<span> </span>MSDafter
77.9344<span></span> CC<span>after </span>0.994369</p>
<br><div class="gmail_quote">The problem with the results I got, and which are presented above are:<br>1)
NMI metric reached the maximum number of iterations, (and took a rather
long time (approx 3sec/iteration.) although that was expected) Should I
set the number of iterations, approx in that number, that I take the
better results?<br>
2) With the parameters I set the optimizer, and metric scales, the
algorithm was pretty close to the optimum results. But when it reached
some of them, it kept running in a steady mode, not converging towards
them.<br><br>
Is there any possible solution to these problems?<br>Thanks,<br><font color="#888888">Giorgos</font></div></div><br><br><div class="gmail_quote">On Mon, May 12, 2008 at 6:49 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi Giorgos,<br>
<br>
Thanks for posting your progress on this problem.<br>
<br>
Here are some comments:<br>
<br>
1) Yes, when using Normalized Mutual Information<br>
you should set the optimizer to "maximize".<br>
You are doing this right by calling<br>
"optimizer->MaximizeOn();"<br>
<br>
see for example<br>
<br>
Insight/Examples/Registration/ImageRegistration14.cxx<br>
<br>
<br>
2) The Optimizer scales are definitely a good place<br>
to look for a culprit.<br>
<br>
With your current scale selection you are actually<br>
telling the optimizer to avoid changing the values<br>
of the Transform's center of rotation, which is a<br>
good thing.<br>
<br>
One thing you should try is replacing the<br>
<br>
itkCenteredSimilarity2DTransform<br>
<br>
with the<br>
<br>
itkSimilarity2DTransform<br>
<br>
The second one still offers the user the possibility<br>
of setting a customized a center of rotation, but<br>
as opposed to the first one, it doesn't include the<br>
center coordinates in the list of parameters to be<br>
optimized. In other words, with the second transform<br>
the optimizer will not try to change the center of<br>
rotation.<br>
<br>
Historical note: initially ITK transforms didn't<br>
provided a SetCenter() method. E.g. by default,<br>
all rotations and scalings were performed with<br>
respect to the origin (0,0).<br>
<br>
Later on we introduced the variants of Transform with<br>
center of rotation, and we called "Centered" transforms,<br>
however, we made the mistake of including the coordinate<br>
of the center of rotation in the list of parameters to<br>
optimize.<br>
<br>
Later on it was decided that almost all transforms<br>
needed a customizable center of rotation, and the<br>
functionality was added to the basic transform, but<br>
without inserting the coordinates of the center of<br>
rotation in to the parameters array.<br>
<br>
Allowing the optimizer to move the center of rotation<br>
makes the Transform to behave very unstably, and therefore<br>
should only be done by allowing the optimizer to make<br>
very small changes in the center of rotation (as you<br>
already discovered).<br>
<br>
Switching to the itkSimilarity2DTransform may alleviate<br>
some of the stability problems that you are facing.<br>
<br>
Please note that the Similarity2DTransform have *less*<br>
parameters. Only four, instead of the six parameters<br>
in the CenteredSimilarity2DTransform.<br>
<br>
Note also that the "Scale" and "Angle" parameters are<br>
still critical in this transforms and you should apply<br>
the same approach that you have used for the Centered<br>
transform. (e.g. using different optimizer scalings<br>
for these two first parameters of the Transform).<br>
<br>
<br>
<br>
Please give it a try at this modification and<br>
let us know how it works for you.<div class="Ih2E3d"><br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
---------------------<br>
Giorgos Pichis wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
Hi,<br>
I made some changes to the code,<br>
and it seems as it is having better results,<br>
but they are still far from the optimum.<br>
<br>
I am using the BrainProtonDensitySlice.png and BrainProtonDensitySliceR10X13Y17S12.png from<br>
the examples data to test the algorithm.<br>
<br>
As far as the metric parameters are concerned , I did the following changes:<br>
//////////////////////<br>
const unsigned int numberOfParameters = transform->GetNumberOfParameters();<br>
<br>
typedef MetricType::ScalesType ScalesType;<br>
ScalesType scales( numberOfParameters );<br>
double t_scale;<br>
double center_scale;<br>
//scales.Fill( 1.0 );<br>
std::cout<<" enter center_scale : ";<br>
std::cin>>center_scale;<br>
std::cout<<" enter t_scale : ";<br>
std::cin>>t_scale;<br>
std::cout<<" enter scales[0] : "; //scaling<br>
std::cin>>scales[0];<br>
std::cout<<" enter scales[1] : "; //angle<br>
std::cin>>scales[1];<br>
//const double t_scale=0.1; //translation scale<br>
//scales[0] = 10.0;<br>
//scales[1] = 1.0;<br>
scales[2] = center_scale;<br>
scales[3] = center_scale;<br>
scales[4] = t_scale;<br>
scales[5] = t_scale;<br>
<br>
metric->SetDerivativeStepLengthScales(scales);<br>
metric->SetDerivativeStepLength(1.0);<br>
<br>
/////////<br>
... and had some relatively (to the previous ones) good results, using:<br>
center_scale :10000,<br>
t_scale: 0.1<br>
scale[0] :0.1 //for scaling<br>
scale[1] :1 //for the angle<br>
<br>
Also the optimizer setting where changes to:<br>
<br>
<br>
typedef OptimizerType::ScalesType OptimizerScalesType;<br>
OptimizerScalesType optimizerScales( transform->GetNumberOfParameters() );<br>
const double translationScale = 1.0 / 100.0;<br>
const double centerScale =1.0/100.0;<br>
<br>
optimizerScales[0] = 10.0;<br>
optimizerScales[1] = 1.0;<br>
optimizerScales[2] = centerScale;<br>
optimizerScales[3] = centerScale;<br>
optimizerScales[4] = translationScale;<br>
optimizerScales[5] = translationScale;<br>
<br>
optimizer->SetScales( optimizerScales );<br>
<br>
double steplength = 1.0;<br>
if( argc > 9 )<br>
{<br>
steplength = atof( argv[9] );<br>
}<br>
optimizer->SetMaximumStepLength( steplength );<br>
optimizer->SetMinimumStepLength( 0.00001 );<br>
optimizer->SetNumberOfIterations( 500 );<br>
optimizer->MaximizeOn(); //change<br>
.... using step lenght=0.5<br>
The algorithm exited, at iteration number 70,<br>
with<br>
Scale 1.00275<br>
Angle (radians) -0.160493<br>
Angle (degrees) -9.19556<br>
Center X = 90.318<br>
Center Y = 108.849<br>
Translation X=15.2579<br>
Translation Y= 15.4322<br>
Metric Value= 1.07114<br>
<br>
Can I get some help , on what further changes should I do,<br>
in order to get better results?<br>
I had almost optimum results working with Mattes MI,<br>
Scale 0.832628<br>
Angle (radians) -0.174455<br>
Angle (degrees) -9.99554<br>
Center X = 87.1628<br>
Center Y = 107.813<br>
Translation X=7.37987<br>
Translation Y= 8.52768<br>
Metric Value= -1.42415,<br>
but I want to get familiar and work with NMI.<br>
What changes to the scales parameters, should I do?<br>
<br>
Thanks in advance,<br>
Giorgos<br>
<br>
<br>
<br>
<br>
<br></div></div><div class="Ih2E3d">
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></blockquote>
</blockquote></div><br>