<html>
<head>
</head>
<body style="font-style: normal; margin-right: 4px; font-weight: normal; line-height: normal; margin-top: 4px; font-size: 16pt; font-variant: normal; margin-left: 4px; margin-bottom: 1px; font-family: Times New Roman">
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">Hello ITK experts,</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">I am using the DeformableRegistration16 example as the basis for a program to register mammo images. In that example there are two observers set up, one for the multi-resolution filter, and one for the demons registration filter. The observers for the demons filter and multi-res filters are both looking for the IterationEvent, so I expect the demons observer to fire at the end of every iteration (currently set to 40 per level), and the multi-res observer to see the changes in resolution level (4 levels). I would like to look at the RMS difference at the end of each iteration (mostly for educational purposes) but what I see is that the event does not fire for the demons filter as expected. Instead, it seems to fire only once for each resolution level (i.e. both observers execute the same number of times while the registration is running).</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">What's really confusing, is that every once in a while, the demons observer seems to function as I would expect, so I see for example 40 Iteration Events for a given resolution level of the multi res filter. Could this be a bug? Can anyone shed light on how to get this to function properly? The registration itself seems to work fine, though I'm not sure this is the best algorithm to try to register digital mammos with. I am able to get a warped image and the displacement map output back to Matlab, which I am using for my front end interface, and the results are actually not too bad looking, at least to the eye.</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">Thanks for any light that may be shed on this issue.</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">Kent</font> </p>
<br> <br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">In case someone would like to see the code, this is pretty much verbatim from the example:</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// The following section of code implements a Command observer</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// that will monitor the evolution of the registration process.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// This observer has a layer of intelligence, for deciding what</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// MaximumRMS convergence criteria to use at every resolution level.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">//</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">class CommandIterationUpdate : public itk::Command</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">{</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">public:</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef CommandIterationUpdate Self;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Command Superclass;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::SmartPointer<Self> Pointer;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> itkNewMacro( Self );</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">protected:</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> CommandIterationUpdate() {};</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> // define ITK short-hand types</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef short PixelType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef float InternalPixelType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Image< PixelType, 2 > ImageType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Image< InternalPixelType, 2 > InternalImageType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Vector< float, 2 > VectorPixelType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Image< VectorPixelType, 2 > DisplacementFieldType;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::DemonsRegistrationFilter< InternalImageType,</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> InternalImageType, DisplacementFieldType> RegistrationFilterType;</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">public:</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> void Execute(const itk::Object *, const itk::EventObject & )</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> std::cout << "Warning: The const Execute method shouldn't be called" << std::endl;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> }</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> void Execute(itk::Object *caller, const itk::EventObject & event)</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> RegistrationFilterType * filter =</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> dynamic_cast< RegistrationFilterType * >( caller );</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> if( !(itk::IterationEvent().CheckEvent( &event )) )</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> return;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> }</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> if(filter)</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> filter->SetMaximumRMSError(MaxRmsE[RmsCounter]);</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> std::cout << filter->GetMetric() << " RMS Change: " << filter->GetRMSChange() << std::endl;</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> std::cout << "Level Tolerance= "<<filter->GetMaximumRMSError ()<<std::endl;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> }</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">}</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">};</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// The following command observer reports the progress of the registration</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// inside a given resolution level.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">//</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">class CommandResolutionLevelUpdate : public itk::Command</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">{</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">public:</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef CommandResolutionLevelUpdate Self;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::Command Superclass;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> typedef itk::SmartPointer<Self> Pointer;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> itkNewMacro( Self );</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">protected:</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> CommandResolutionLevelUpdate() {};</font> </p>
<br>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">public:</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> void Execute(itk::Object *caller, const itk::EventObject & event)</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> Execute( (const itk::Object *)caller, event);</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> }</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> void Execute(const itk::Object *, const itk::EventObject & )</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> {</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> std::cout << "----------------------------------" << std::endl;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> RmsCounter = RmsCounter + 1;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> std::cout << "----------------------------------" << std::endl;</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> }</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">};</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">//</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> // Create the Command observer and register it with the demons registration filter.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> //</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> filter->AddObserver( itk::IterationEvent(), observer );</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman">// Create the Command observer and register it with the multi-res registration filter.</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> //</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> CommandResolutionLevelUpdate::Pointer levelobserver = CommandResolutionLevelUpdate::New();</font> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font size="5" face="Times New Roman"> multires->AddObserver( itk::IterationEvent(), levelobserver );</font>
</p>
</body>
</html>