<DIV>Hi, Luis,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Sorry I didn't put my code in the previous email. Here's the code. </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Class modified to save parameters in the process of registration</DIV>
<DIV>class CommandIterationUpdate : public itk::Command <BR>{<BR>public:<BR>&nbsp; typedef&nbsp; CommandIterationUpdate&nbsp;&nbsp; Self;<BR>&nbsp; typedef&nbsp; itk::Command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Superclass;<BR>&nbsp; typedef itk::SmartPointer&lt;Self&gt;&nbsp; Pointer;<BR>&nbsp; itkNewMacro( Self );<BR>&nbsp; itk::Optimizer::ParametersType&nbsp; X[100]; // Array to save the first parameter of GetCurrentPosition<BR>&nbsp; double MTC[100];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Array to save the metric value<BR>protected:<BR>&nbsp; CommandIterationUpdate() {};<BR>public:<BR>&nbsp; typedef itk::RegularStepGradientDescentOptimizer&nbsp;&nbsp;&nbsp;&nbsp; OptimizerType;<BR>&nbsp; typedef&nbsp;&nbsp; const OptimizerType&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp; OptimizerPointer;</DIV>
<DIV>&nbsp; void Execute(itk::Object *caller, const itk::EventObject &amp; event)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Execute( (const itk::Object *)caller, event);<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp; void Execute(const itk::Object * object, const itk::EventObject &amp; event)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp; <BR>&nbsp; int i=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OptimizerPointer optimizer = <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic_cast&lt; OptimizerPointer &gt;( object );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( typeid( event ) != typeid( itk::IterationEvent ) )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetCurrentIteration() &lt;&lt; "&nbsp;&nbsp; ";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i= optimizer-&gt;GetCurrentIteration();<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; // Metric<BR>&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetValue() &lt;&lt; "&nbsp;&nbsp; ";<BR>&nbsp;&nbsp; MTC[i] = optimizer-&gt;GetValue();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; // the first parameter of
 GetCurrentPosition<BR>&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetCurrentPosition()[0] &lt;&lt; std::endl;<BR>&nbsp;&nbsp; X[i] = optimizer-&gt;GetCurrentPosition()[0];<BR>&nbsp;&nbsp;&nbsp; }<BR>};</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Code to save parameters to a file </DIV>
<DIV>&nbsp;// Print the the first parameter of GetCurrentPosition to the file<BR></DIV>
<DIV>&nbsp; vcl_ofstream Parameterfile ("C:\\Angle.txt");<BR>&nbsp; if (Parameterfile.is_open())<BR>&nbsp; {&nbsp;&nbsp; <BR>&nbsp;&nbsp; int i = 0;<BR>&nbsp;&nbsp; for(i=0;i&lt;numberOfIterations;i++)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parameterfile &lt;&lt; observer-&gt;X[i]&lt;&lt;std::endl; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parameterfile&lt;&lt; observer-&gt;MTC[i]&lt;&lt;std::endl;<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; Parameterfile.close();<BR>&nbsp; }<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>Here's the output of the file Angle.txt</DIV>
<DIV>&nbsp;</DIV>
<DIV>[]<BR>2098.33<BR>[]<BR>1840.37<BR>[]<BR>1561.14<BR>[]<BR>556.306<BR>[]<BR>492.576<BR>[]<BR>422.589<BR>[]<BR>341.925<BR>[]<BR>249.167<BR>[]<BR>131.887<BR>[]<BR>69.1155<BR>[]<BR>60.9398<BR>[]<BR>60.4099<BR>[]<BR>61.379<BR>[]<BR>60.7183<BR>[]<BR>60.3914<BR>[]<BR>60.3819<BR>[]<BR>60.3803<BR>[]<BR>60.3868<BR>[]<BR>60.3816<BR>[]<BR>-6.27744e+066<BR></DIV>
<DIV>Thanks a lot. </DIV>
<DIV><EM>Regards,</EM></DIV>
<DIV><EM></EM>&nbsp;</DIV>
<DIV><EM>Jay</EM></DIV>
<DIV><BR><B><I>Luis Ibanez &lt;luis.ibanez@kitware.com&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi Jay,<BR><BR>How can you get square brackets when<BR>you write a number to a file ?<BR><BR>Please post to the list the lines of code that<BR>you are using for writing the CurrentPosition<BR>to the file.<BR><BR>Thanks<BR><BR><BR>Luis<BR><BR><BR><BR>---------------------<BR>Jay Li wrote:<BR><BR>&gt; Dear all,<BR>&gt; <BR>&gt; Here I have a question about the GetCurrentPosition().<BR>&gt; I'm trying to save the first parameter of this<BR>&gt; function to a file. I used the<BR>&gt; optimizer-&gt;GetCurrentPosition()[0] to show the first<BR>&gt; parameter on the screen, but when I tried to save it<BR>&gt; to a file, I always got squre brackets. I also tried<BR>&gt; to save GetCurrentPosition()[1], this time it gave me<BR>&gt; an array of a lot numbers with the same value<BR>&gt; -6.27744e+066. Could anyone please give me some hints?<BR>&gt; <BR>&gt; Thanks a lot!<BR>&gt; <BR>&gt; Jay
 <BR>&gt; <BR>&gt; <BR><BR><BR><BR><BR></BLOCKQUOTE><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com