<br>Hi Motes,<br><br>The optimizer (by design) doesn&#39;t <br>know anything about the Transforms.<br><br>This is basically guided by the SRP<br><br>    &quot;Single Responsibility Principle&quot;<br><br><a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">http://en.wikipedia.org/wiki/Single_responsibility_principle</a><br>
<br>that is: <br><br> one class should do only one thing<br>
 and should do it well.<br><br><br>What you may want to do is to simply<br>customize the Command Observer<br>to take a pointer to the Transform<br>as part of the set up procedure.<br><br>Then, every time that you get an <br>

event, you could access the Transform<br>via the extra pointer that you hold.<br><br>Note however, that depending of the <br>optimizer that you are using, you may<br>NOT want to modify the transform,<br>and instead you may have to stick to<br>

read-only operations.<br><br>For example, the amoeba optimizer<br>and the OnePlusOneEvolutionary<br>optimizers will perform intermediate<br>evaluations of the Metric (and therefore<br>will use intermediate settings of the <br>
transform) in between sending iterations<br>events.<br><br><br>Your observer could look like the following<br>pseudo-code<br><br><br>class myObserver: public Command<br>{<br><br>  void SetTransform( const TransformType * tt )<br>
   { this-&gt;myTransform = tt; }<br><br>  void Execute(...blah..)<br>    {<br>    this-&gt;myTransform-&gt;Print( std::cout );<br>    // or any other const call to the transform API<br>    }<br><br>private:<br><br>   TransformType::ConstPointer   myTransform;<br>
};<br><br><br><br>and in your code you will have to remember to <br>call SetTransform() in the observer before you <br>run the registration process.<br><br><br><br>     Regards,<br><br><br>            Luis<br><br><br>---------------------------------------------------<br>
<div class="gmail_quote">On Tue, Apr 20, 2010 at 8:43 AM, motes motes <span dir="ltr">&lt;<a href="mailto:mort.motes@gmail.com" target="_blank">mort.motes@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Typically an observer is connected to an optimizer like:<br>
<br>
      optimizer-&gt;SetNumberOfIterations(number_of_iterations);<br>
      optimizer-&gt;MinimizeOn();<br>
      optimizer-&gt;AddObserver(itk::IterationEvent(), observer);<br>
<br>
<br>
In the observer its then possible to retrieve the optimizer and read<br>
(or even modify) the parameters:<br>
<br>
                void Execute( itk::Object * object, const itk::EventObject &amp; event) {<br>
                        OptimizerPointer optimizer = dynamic_cast&lt; OptimizerPointer &gt;( object );<br>
                        if( ! itk::IterationEvent().CheckEvent( &amp;event ) ) {<br>
                                return;<br>
                        }<br>
                        std::cout &lt;&lt; optimizer-&gt;GetCurrentIteration() &lt;&lt; &quot; = &quot; &lt;&lt;<br>
optimizer-&gt;GetValue() &lt;&lt; &quot; : &quot; &lt;&lt; optimizer-&gt;GetCurrentPosition() &lt;&lt;<br>
std::endl;<br>
                         // do modifications...<br>
<br>
<br>
<br>
Now I would like to be able to do the the same thing with a transform<br>
that I have made.<br>
<br>
What I need is to modify some parameters in the transform after a<br>
certain number of iterations.  Is it somehow possible to get the<br>
transform connected to the image registration method in the above<br>
Execute method in each iteration?<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>