<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi Luis,<br><br>&nbsp; Yes, I see the value of m_StopCondition in the debugger and it does not get initialized to 0, if the MaxNumberofIterations is 0.<br>I haven't checked whether this occurs for 0 value alone.<br><br>Emma<br><br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Luis Ibanez &lt;luis.ibanez@kitware.com&gt;<br>To: Emma Ryan &lt;eryanvtk@yahoo.com&gt;<br>Cc: insight-users@itk.org<br>Sent: Friday, August 10, 2007 9:18:58 AM<br>Subject: Re: [Insight-users] Re: SetMaxIterations(0) still computes<br><br><div><br>Hi Emma,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You are right, this is a
 bug.<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Number of Iterations is set to zero,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then the optimizer will runs forever.<br><br><br>We have logged this and Bug #5476<br><a target="_blank" href="http://public.kitware.com/Bug/view.php?id=5476">http://public.kitware.com/Bug/view.php?id=5476</a><br><br><br>The changes should be easy to put in place.<br><br><br><br>A couple of questions first:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;How are you looking at the value of m_StopCondition ?<br>&nbsp;&nbsp;&nbsp;&nbsp;by using a debugger ?<br>&nbsp;&nbsp;&nbsp;&nbsp;by using print outs ?<br><br>StopCondition is *initialized* with "MaximumNumberOfIterations",<br>that's probably the reason why you see that value when you<br>(I assume "manually") stop the optimizer.<br><br>We probably should add a "Unknown" to the enum, and initialize<br>the StopCondition to that value.<br><br><br><br>&nbsp;&nbsp; Please let us
 konw,<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Luis<br><br><br><br>------------------<br>Emma Ryan wrote:<br>&gt; Hi,<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;With reference to my earlier email ( below), I think ITK does not <br>&gt; allow the MaxNumberOfIterations to be zero.&nbsp;&nbsp;It needs to be a minimum of <br>&gt; one because the check<br>&gt; if (m_currentIteration = = m_NumberOfIterations) then quit; is done in a <br>&gt; sort-of 'do-while' loop rather than 'while'. So this condition is never <br>&gt; true for m_NumberofIterations=0.<br>&gt; <br>&gt; I am still confused about Stop_Condition getting a value of 5.<br>&gt; <br>&gt; Also, if Stop_Condition is defined by NumberofIterations, then why <br>&gt; doesn't the optimizer continue iterating till it reaches the number, <br>&gt; rather than terminating at a 'decent' metric value ?<br>&gt; <br>&gt; Obviously
 there is another hidden condition for termination which I dont <br>&gt; see.&nbsp;&nbsp;Could anyone point to me the location ?<br>&gt; <br>&gt; Thank you,<br>&gt; Emma<br>&gt; <br>&gt; ----- Original Message ----<br>&gt; From: Emma Ryan &lt;eryanvtk@yahoo.com&gt;<br>&gt; To: insight-users@itk.org<br>&gt; Sent: Thursday, August 9, 2007 1:35:23 AM<br>&gt; Subject: SetMaxIterations(0) still computes<br>&gt; <br>&gt; Hi,<br>&gt; <br>&gt;&nbsp;&nbsp; I'm trying to debug my rigid registration program and the first step <br>&gt; is to reduce the number of iterations.<br>&gt; So I set it to 0, but when I execute my program it still shows me <br>&gt; several iterations.&nbsp;&nbsp;Any clue as to why this might be happening ?<br>&gt; <br>&gt; Here is the output of the optimizer (segment 1).&nbsp;&nbsp;As you can see, <br>&gt; NumberOfIterations = 0 . The StopCondition which I thought would be 0 is <br>&gt; 5. So based on this and other experiments, I have a few
 questions.<br>&gt; <br>&gt; 1. Shouldn't the StopCondition be 0 ?<br>&gt; 2. If optimizer-&gt;SetNumberOfIterations(0), then what do the following <br>&gt; iterations represent&nbsp;&nbsp;and where do they come from ?<br>&gt; 3. Also, it I set the NumberOfIterations to some otehr number such as <br>&gt; 100000, it still performs 500 iterations (the default value from the <br>&gt; example programs)<br>&gt; 4. The Mean Square error metric that I compute on Binarized input images <br>&gt; is the same as that computed on grayscale images. So what I am doing <br>&gt; here is that I convert the grayscale images to binary. ie. Every tissue, <br>&gt; except bone is black. Then I use these binary images for registration. <br>&gt; The metric value returned by the registration process is compared <br>&gt; against the metric value obtained by applying the same transform on <br>&gt; original grayscale images and checking the mean squared error. <br>&gt; Surprisingly
 these two values are EXACTLY the same. I expect them to be <br>&gt; different for obvious reasons.<br>&gt; The way I compute the metric on the original grayscale images is shown <br>&gt; below under segment 2<br>&gt; <br>&gt; <br>&gt; What is going on ?<br>&gt; <br>&gt; Any clue ?<br>&gt; <br>&gt; Thanks in advance<br>&gt; Emma<br>&gt; <br>&gt; <br>&gt; SEGMENT 1<br>&gt; ---------------<br>&gt; VersorRigid3DTransformOptimizer (019220B8)<br>&gt;&nbsp;&nbsp; RTTI typeinfo:&nbsp;&nbsp; class itk::VersorRigid3DTransformOptimizer<br>&gt;&nbsp;&nbsp; Reference Count: 2<br>&gt;&nbsp;&nbsp; Modified Time: 874<br>&gt;&nbsp;&nbsp; Debug: Off<br>&gt;&nbsp;&nbsp; Observers:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; none<br>&gt;&nbsp;&nbsp; InitialPosition: []<br>&gt;&nbsp;&nbsp; CurrentPosition: []<br>&gt;&nbsp;&nbsp; Scales: [1, 1, 1, 0.001, 0.001, 0.001]<br>&gt;&nbsp;&nbsp; MaximumStepLength: 0.2<br>&gt;&nbsp;&nbsp; MinimumStepLength: 0.001<br>&gt;&nbsp;&nbsp;
 RelaxationFactor: 0.5<br>&gt;&nbsp;&nbsp; GradientMagnitudeTolerance: 0.1<br>&gt;&nbsp;&nbsp; NumberOfIterations: 0<br>&gt;&nbsp;&nbsp; CurrentIteration: 0<br>&gt;&nbsp;&nbsp; Value: 0<br>&gt;&nbsp;&nbsp; Maximize: 0<br>&gt;&nbsp;&nbsp; CostFunction: (None)<br>&gt;&nbsp;&nbsp; CurrentStepLength: 0<br>&gt;&nbsp;&nbsp; StopCondition: 5<br>&gt;&nbsp;&nbsp; Gradient: []<br>&gt; 0&nbsp;&nbsp; 1976.47&nbsp;&nbsp; [0.000460224, -0.0157202, -0.041473, -6.58714, -9.17326, <br>&gt; 0.231981]<br>&gt; <br>&gt; 1&nbsp;&nbsp; 669.48&nbsp;&nbsp; [0.00152886, 0.00402301, -0.0345613, -6.60421, -9.36806, <br>&gt; 0.229234]<br>&gt; 2&nbsp;&nbsp; 576.079&nbsp;&nbsp; [-0.000710302, -0.0100887, -0.0583703, -6.5576, -9.55443, <br>&gt; 0.227974<br>&gt; ]<br>&gt; 3&nbsp;&nbsp; 895.329&nbsp;&nbsp; [0.0024751, 0.017149, -0.0188799, -6.6526, -9.70157, 0.236332]<br>&gt; 4&nbsp;&nbsp; 1454.49&nbsp;&nbsp; [0.000779181, 0.00262768, -0.0415692, -6.57818, -9.73974, <br>&gt;
 0.226865<br>&gt; ]<br>&gt; 5&nbsp;&nbsp; 208.619&nbsp;&nbsp; [-0.000462126, -0.00352645, -0.0488536, -6.56913, <br>&gt; -9.83714, 0.2190<br>&gt; 21]<br>&gt; 6&nbsp;&nbsp; 320.494&nbsp;&nbsp; [0.00156166, 0.00864248, -0.0314357, -6.61138, -9.91627, <br>&gt; 0.207684]<br>&gt; <br>&gt; 7&nbsp;&nbsp; 724.278&nbsp;&nbsp; [0.000322199, -0.00121238, -0.0455856, -6.58293, -9.93788, <br>&gt; 0.20247<br>&gt; 4]<br>&gt; 8&nbsp;&nbsp; 143.422&nbsp;&nbsp; [0.000259716, 0.00266556, -0.0399937, -6.59857, -9.98223, <br>&gt; 0.192322<br>&gt; ]<br>&gt; 9&nbsp;&nbsp; 223.3&nbsp;&nbsp; [-0.000310048, -0.004876, -0.0507685, -6.57875, -10.018, <br>&gt; 0.180773]<br>&gt; 10&nbsp;&nbsp; 419.74&nbsp;&nbsp; [0.00029441, 5.14277e-005, -0.0436893, -6.59453, -10.026, <br>&gt; 0.177275<br>&gt; ]<br>&gt; 1<br>&gt; .......<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; SEGMENT 2<br>&gt; <br>&gt; MetricType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 metricOrig&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = MetricType::New();&nbsp;&nbsp; <br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metricOrig-&gt;SetInterpolator(interpolator);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metricOrig-&gt;SetTransform(transform);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metricOrig-&gt;SetFixedImage(fixedImageReaderOrig-&gt;GetOutput());<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metricOrig-&gt;SetMovingImage(movingImageReaderOrig-&gt;GetOutput());<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metricOrig-&gt;SetTransformParameters(finalParameters);&nbsp;&nbsp; <br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MetricType::TransformParametersType finalParam = <br>&gt; registration-&gt;GetLastTransformParameters();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 std::cout&lt;&lt;" MetricOnOriginalImage = <br>&gt; "&lt;&lt;metric-&gt;GetValue(finalParam)&lt;&lt;std::endl;<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; ------------------------------------------------------------------------<br>&gt; Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user <br>&gt; panel <br>&gt; &lt;<a target="_blank" href="http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7%20">http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7%20</a>&gt; <br>&gt; and lay it on us.<br>&gt; <br>&gt; <br>&gt; ------------------------------------------------------------------------<br>&gt; Be a better Heartthrob. Get better relationship answers <br>&gt; &lt;<a target="_blank"
 href="http://us.rd.yahoo.com/evt=48255/*http://answers.yahoo.com/dir/_ylc=X3oDMTI5MGx2aThyBF9TAzIxMTU1MDAzNTIEX3MDMzk2NTQ1MTAzBHNlYwNCQUJwaWxsYXJfTklfMzYwBHNsawNQcm9kdWN0X3F1ZXN0aW9uX3BhZ2U-?link=list&amp;sid=396545433%3Efrom">http://us.rd.yahoo.com/evt=48255/*http://answers.yahoo.com/dir/_ylc=X3oDMTI5MGx2aThyBF9TAzIxMTU1MDAzNTIEX3MDMzk2NTQ1MTAzBHNlYwNCQUJwaWxsYXJfTklfMzYwBHNsawNQcm9kdWN0X3F1ZXN0aW9uX3BhZ2U-?link=list&amp;sid=396545433&gt;from</a> <br>&gt; someone who knows.<br>&gt; Yahoo! Answers - Check it out.<br>&gt; <br>&gt; <br>&gt; ------------------------------------------------------------------------<br>&gt; <br>&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; Insight-users@itk.org<br>&gt; <a target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br></div></div><br></div></div><br>
      <hr size=1>Boardwalk for $500? In 2007? Ha! <br><a href="http://us.rd.yahoo.com/evt=48223/*http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow">Play Monopoly Here and Now</a> (it's updated for today's economy) at Yahoo! Games.</body></html>