[Insight-users] Halting Demons Registration After Convergence

Tim Soper tim_d_soper at yahoo.com
Thu Sep 29 21:13:55 EDT 2005


Hi,
I am using the itkDemonsRegistrationFunction as part
of the MultiResolutionPDEDeformableRegistration. I
would like to be able to halt the registration at each
level once it has reached some convergence criterion.
My plan is to let the registration run until the
registration metric does not decrease significantly
between iterations and then proceed to the next
resolution level. I am using the
CommandIterationUpdate observer to monitor the
progress, but trying to halt the deformation does not
appear to work. Is it possible to terminate the
registration early, and if so how might I accomplish
this using methods in my observer? I've pasted code
from the observer below.

-Tim

  class CommandIterationUpdate : public itk::Command 
  {
  public:
    typedef  CommandIterationUpdate   Self;
    typedef  itk::Command             Superclass;
    typedef  itk::SmartPointer<CommandIterationUpdate>
 Pointer;
    itkNewMacro( CommandIterationUpdate );
	int* CurrentLevel;
	int iteration;
	float lastMetric;
  protected:
    CommandIterationUpdate() {};

    typedef itk::Image< float, 2 > InternalImageType;
    typedef itk::Vector< float, 2 >   
VectorPixelType;
    typedef itk::Image<  VectorPixelType, 2 >
DeformationFieldType;

    typedef itk::DemonsRegistrationFilter<
                                InternalImageType,
                                InternalImageType,
                                DeformationFieldType> 
 RegistrationFilterType;

  public:

    void Execute(itk::Object *caller, const
itk::EventObject & event)
      {
        Execute( (const itk::Object *)caller, event);
      }

    void Execute(const itk::Object * object, const
itk::EventObject & event)
      {
         const RegistrationFilterType * filter = 
          dynamic_cast< const RegistrationFilterType *
>( object );
        
		 if( typeid( event ) != typeid( itk::IterationEvent
) )
          {
          return;
          }
		  float diff = fabs(lastMetric -
filter->GetMetric());
		  std::cout << *CurrentLevel <<",	"
					<< filter->GetMetric()
					<< ",	" << diff << std::endl;
		  lastMetric = filter->GetMetric();
		if(diff < .01)
		  filter->StopRegistration(); //this line returns an
error
	  }
  };


		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the Insight-users mailing list