Hello again, it seems i could overcome some of my difficulties re-defining a metric. This is what I did:<br><ul><li>First I tried a SpatialObjectToImageStatistis calculator, so that I would be able to sum the values of pixels of the image included inside the Spatial Object. I couln&#39;t make it, and struggled for several days on that. So I decided I would look for another solution that might not be as efficient, but could be used meanwhile.</li>
<li>So I did the following, I used an SpatialObjectToImageFilter and counted the pixels of that Spatial Object. This has given me a metric that uses the points inside the image ratio, and the pixels that includes the spatial object. With this I am able to register, but I face the following problem, which is why I ask you for some guidance:</li>
</ul>Given that my registration algorithm using this unefficient metric is quite slow, i would certainly need to have the right scales for dynamic range of paratemers. So what&#39;s the rule to choose them? I can see examples in the ITK Software Guide, but I&#39;d rather have some more information about why those values were chosen. <br>
<br>Thank you in advance, <br><br><br>Antonio Foncubierta<br>
<br><br><div class="gmail_quote">2009/1/16 Antonio Foncubierta <span dir="ltr">&lt;<a href="mailto:antonio.foncubierta@gmail.com">antonio.foncubierta@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thank you very much for your quick answer, Luis. As requested, I will give as many details as possible:<br><br><ol><li>I create an itkImage using a SpatialObjectToImageFilter. This image contains an ellipsoid with radii 10 15 20, for instance. <br>

</li><li>I want to make a registration of a certain Spatial Object with that Image. The starting Spatial Object is another ellipsoid with radii, for example, 5, 5, 5. I set the Spatial Object offset in a way so that the ellipsoid centre fits the Image Gravity Center (I use a MomentCalculator to get that value).<br>

</li><li>I start the registration method using an Affine Transform, because the starting ellipsoid needs a scale change.</li><li>The result is that the optimizer doesn&#39;t have anything to optimize, because the SimpleModelToImageMetric GetValue method returns the number of Spatial Object points in the Image (every point in the image has value=1). Therefore, the metric is already maximized. The result is a small ellipsoid fully contained inside the image.<br>

</li><li>In some other cases, I located the starting spatial object outside the gravity center of the image and then started the registration method. The result then was a randomly shaped ellipsoid (it depends on where I put the center and the original size of it) which has all of its points inside the image. The Optimizer returns the same parameters once it achieves a maximum in the metric, no matter how many iterations I allow the registration method to run.</li>

</ol>Those results have made me think that I must change the metric so that it has a maximum when all the points are inside the image and the spatial object volume is as high as possible. <br><br>Any ideas?<br><br>I also would like to apologize if you understood that I was reporting a problem in the registration methods or examples (which obviously work perfectly). My intention was to find what I am doing wrong or what I could probably use to solve _my_ problem.<br>

<br>Thank you in advance, <br><br>Antonio Foncubierta<br>
<br><br><div class="gmail_quote">2009/1/16 Luis Ibanez <span dir="ltr">&lt;<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>&gt;</span><div><div></div><div class="Wj3C7c"><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 Antonio,<br>
<br>
the ImageToSpatialObjectRegistrationMethod&lt;&gt; that is illustrated in the<br>
examples<br>
<br>
 &nbsp; &nbsp;Insight/Examples/Registration<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ModelToImageRegistration1.cxx<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ModelToImageRegistration2.cxx<br>
<br>
should, in principle, work with any of the ITK Transforms.<br>
<br>
It is likely that the problem that you faced when using an Affine transform are more related to:<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;A) Poor choice of parameter scaling values (the array<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; that is passed to the Optimizer in order to compensate<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for the difference in dynamic range between Translation<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and Rotation/Scale components.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;B) Poor choice of Optmizer parameters.<br>
<br>
<br>
Of course, the option of writing your own Metric is always worth<br>
considering, but that is independent of the need for solving (A)<br>
and (B) properly.<br>
<br>
<br>
In general, when you report that something &quot;doesn&#39;t work&quot;, it is<br>
very helpful to describe *exactly* what the result was, and how<br>
do you arrive to the conclusion that &quot;it doesn&#39;t work&quot;.<br>
<br>
Please give us more detail on what you observed....<br>
<br>
<br>
 &nbsp; &nbsp;Thanks<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; Luis<br>
<br>
<br>
<br>
---------------------------<br>
Antonio Foncubierta wrote:<br>
<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>
Hello,<br>
<br>
I am trying to develop a Model Based Registration Method, and I started using the example mentioned by the Itk Software Guide and included in the 3.6 version of Insight: ***ModelToImageRegistration1.cxx***. I have been trying to adapt the example to work with my data: 3D Images. Achieving that was not a big deal, but I started to struggle when I wanted the Transform to be an itkAffineTransform, which includes a scale change. The example explicitly says that the SimpleImageToSpatialObjectMetric is designed considering no scale changes, and it says it right, because the metric doesn&#39;t work as I required. (It does work as expected, though).<br>


<br>
So my main problem now is finding a way to define a metric that maximizes both the ****number of Spatial Object Points inside the Image**** and the ****Spatial Object Volume****. The first one is easy, as it is exactly what the above mentioned example does, but I haven&#39;t found a way to compute the Transformed SpatialObject Volume.<br>


<br>
And that&#39;s why I ask you if any of you have found a similar problem and how did you solve it. Also, if any of you know a not-as-simple metric which I could use.<br>
<br>
Thank you in advance,<br>
<br>
PS: The explanation migh be very blurry, so if you don&#39;t undersrtand anything of it, please, just ask. I&#39;d rather repeat things in a different way, or attach images to not having help at all ;)<br>
<br>
Antonio Foncubierta<br>
<br>
<br></div></div>
------------------------------------------------------------------------<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>
</blockquote>
</blockquote></div></div></div><br>
</blockquote></div><br>