Hi Luis,<br><br>I finally could use the SpatialObjectToImageStatisticsCalculator, so I solved the unefficiency problem. The algorithm is now much quicker, between 10 and 100 times faster! This lets me increase the number of iterations so that in, say 10 minutes, i have a good result, which isn't still perfect, but approximate. By the way, the problem why I couldn't use the SpatialObjectToImageStatisticsCalculator seemed to be related with having a GroupSpatialObject, since when I switched to EllipseSpatialObject, it just worked perfectly and could calculate real numbers (otherwise the results were NaN).<br>
<br>Thank you very much for your advice, I really appreciate your interest. I'll try that as soon as possible, and will let you know what my results are. <br><br><br clear="all">Antonio Foncubierta<br>
<br><br><div class="gmail_quote">2009/2/2 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>></span><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>
It seems that part of the difficulty that you are facing is<br>
rooted in the fact that the metric that computes a binary<br>
overlap between the spatial object and the image will have<br>
a plateau for all the transform parameters that map the<br>
spatial object inside the object in the image.<br>
<br>
You may want to consider blurring the image, or computing<br>
its distance map, as a way of breaking that plateau, and<br>
converting it in to a function with a monotonic profile<br>
that could be tracked by an optimizer.<br>
<br>
The metric illustrated in the ModelToImage examples is<br>
a very basic one...<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<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 class="Ih2E3d">
Hello again, it seems i could overcome some of my difficulties re-defining a metric. This is what I did:<br>
<br>
* First I tried a SpatialObjectToImageStatistis calculator, so that<br>
I would be able to sum the values of pixels of the image included<br>
inside the Spatial Object. I couln't make it, and struggled for<br>
several days on that. So I decided I would look for another<br>
solution that might not be as efficient, but could be used meanwhile.<br>
* So I did the following, I used an SpatialObjectToImageFilter and<br>
counted the pixels of that Spatial Object. This has given me a<br>
metric that uses the points inside the image ratio, and the pixels<br>
that includes the spatial object. With this I am able to register,<br>
but I face the following problem, which is why I ask you for some<br>
guidance:<br>
<br>
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's the rule to choose them? I can see examples in the ITK Software Guide, but I'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>
2009/1/16 Antonio Foncubierta <<a href="mailto:antonio.foncubierta@gmail.com" target="_blank">antonio.foncubierta@gmail.com</a> <mailto:<a href="mailto:antonio.foncubierta@gmail.com" target="_blank">antonio.foncubierta@gmail.com</a>>><div class="Ih2E3d">
<br>
<br>
Thank you very much for your quick answer, Luis. As requested, I<br>
will give as many details as possible:<br>
<br></div>
1. I create an itkImage using a SpatialObjectToImageFilter. This<div class="Ih2E3d"><br>
image contains an ellipsoid with radii 10 15 20, for instance.<br>
2. I want to make a registration of a certain Spatial Object with<br>
that Image. The starting Spatial Object is another ellipsoid<br>
with radii, for example, 5, 5, 5. I set the Spatial Object<br>
offset in a way so that the ellipsoid centre fits the Image<br>
Gravity Center (I use a MomentCalculator to get that value).<br></div>
3. I start the registration method using an Affine Transform,<div class="Ih2E3d"><br>
because the starting ellipsoid needs a scale change.<br></div>
4. The result is that the optimizer doesn't have anything to<div class="Ih2E3d"><br>
optimize, because the SimpleModelToImageMetric GetValue method<br>
returns the number of Spatial Object points in the Image<br>
(every point in the image has value=1). Therefore, the metric<br>
is already maximized. The result is a small ellipsoid fully<br>
contained inside the image.<br></div>
5. In some other cases, I located the starting spatial object<div class="Ih2E3d"><br>
outside the gravity center of the image and then started the<br>
registration method. The result then was a randomly shaped<br>
ellipsoid (it depends on where I put the center and the<br>
original size of it) which has all of its points inside the<br>
image. The Optimizer returns the same parameters once it<br>
achieves a maximum in the metric, no matter how many<br>
iterations I allow the registration method to run.<br>
<br>
Those results have made me think that I must change the metric so<br>
that it has a maximum when all the points are inside the image and<br>
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<br>
reporting a problem in the registration methods or examples (which<br>
obviously work perfectly). My intention was to find what I am doing<br>
wrong or what I could probably use to solve _my_ problem.<br>
<br>
Thank you in advance,<br>
<br>
Antonio Foncubierta<br>
<br>
<br>
2009/1/16 Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a><br></div>
<mailto:<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>>><div><div></div><div class="Wj3C7c"><br>
<br>
<br>
Hi Antonio,<br>
<br>
the ImageToSpatialObjectRegistrationMethod<> that is illustrated<br>
in the<br>
examples<br>
<br>
Insight/Examples/Registration<br>
<br>
ModelToImageRegistration1.cxx<br>
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<br>
Affine transform are more related to:<br>
<br>
<br>
A) Poor choice of parameter scaling values (the array<br>
that is passed to the Optimizer in order to compensate<br>
for the difference in dynamic range between Translation<br>
and Rotation/Scale components.<br>
<br>
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 "doesn't work", it is<br>
very helpful to describe *exactly* what the result was, and how<br>
do you arrive to the conclusion that "it doesn't work".<br>
<br>
Please give us more detail on what you observed....<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
<br>
---------------------------<br>
Antonio Foncubierta wrote:<br>
<br>
Hello,<br>
<br>
I am trying to develop a Model Based Registration Method,<br>
and I started using the example mentioned by the Itk<br>
Software Guide and included in the 3.6 version of Insight:<br>
***ModelToImageRegistration1.cxx***. I have been trying to<br>
adapt the example to work with my data: 3D Images. Achieving<br>
that was not a big deal, but I started to struggle when I<br>
wanted the Transform to be an itkAffineTransform, which<br>
includes a scale change. The example explicitly says that<br>
the SimpleImageToSpatialObjectMetric is designed considering<br>
no scale changes, and it says it right, because the metric<br>
doesn'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<br>
that maximizes both the ****number of Spatial Object Points<br>
inside the Image**** and the ****Spatial Object Volume****.<br>
The first one is easy, as it is exactly what the above<br>
mentioned example does, but I haven't found a way to compute<br>
the Transformed SpatialObject Volume.<br>
<br>
And that's why I ask you if any of you have found a similar<br>
problem and how did you solve it. Also, if any of you know a<br>
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't<br>
undersrtand anything of it, please, just ask. I'd rather<br>
repeat things in a different way, or attach images to not<br>
having help at all ;)<br>
<br>
Antonio Foncubierta<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Insight-users mailing list<br></div></div>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a> <mailto:<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a>><div class="Ih2E3d"><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
<br>
<br>
</div></blockquote>
</blockquote></div><br>