[Insight-users] Problem with MeanSquaresImageToImageMetric

Luis Ibanez luis . ibanez at kitware . com
Fri, 23 Aug 2002 10:09:30 -0400


Hi Suresh,


Could you please tell us what the error message is ?



Note that "StartRegistration()" verifies if all the
required components have been connected to the
registration method. If any component is missing,
the RegistrationMethod class throws an exception.

You must then, put StartRegistration() inside a
try/catch block.

Something like:

   try {
     registration->StartRegistration();
   }
   catch( itk::ExceptionObject & err )
   {
      std::cout << err << std::endl;
   }


Note that itk::ExceptionObject derives from
the std::exception class. So you can catch
ITK exceptions by doing:

   catch( std::exception & err )
   {
     std::cout << err.what() << std::endl;
   }


Please let us know what error message is
carried by the exception object in your
example.

   Thanks

     Luis


===================================

suresh wrote:
> 
> Hi friends,
> 
>    I'm getting a windows illegal operation error while runing the 
> following code.
>    I've coded this following the MIRegistration example. I could not run 
> this.
>    When i call registration->StartRegistyration() the error is thrown..
> 
> NOTE: The images are of type Image<unsigned short, 3>
> 
> *********CODE SNIPPET****************
>     typedef itk::QuaternionRigidTransform<double> TransformType;
>     typedef itk::QuaternionRigidTransformGradientDescentOptimizer 
> OptimizerType;
>     typedef itk::LinearInterpolateImageFunction<ImageType, double> 
> InterpolatorType;
>     typedef itk::ImageRegistrationMethod<ImageType,ImageType> 
> RegistrationType1;
> 
>     typedef itk::MeanSquaresImageToImageMetric<ImageType, ImageType> 
> MetricType;
>     MetricType::Pointer         metric        = MetricType::New();
>     TransformType::Pointer      transform     = TransformType::New();
>     OptimizerType::Pointer      optimizer     = OptimizerType::New();
>     InterpolatorType::Pointer   interpolator  = InterpolatorType::New();
>     RegistrationType1::Pointer  registration  = RegistrationType1::New();
>     RegistrationType1::ParametersType 
> guess(transform->GetNumberOfParameters() );
> 
>     guess[0] = 0.0; guess[1] = 0.0; guess[2] = 0.0; guess[3] = 1.0;
>     guess[4] = 20.0; guess[5] = 40.0; guess[6] = 0.0;
> 
>     ImagePointer fixedImage = BufferToImage(MRI);// built from an pixel 
> buffer
>     ImagePointer movingImage = BufferToImage(SPECT);
> 
> 
>     registration->SetInitialTransformParameters (guess);
>     //Set translation scale
>     typedef OptimizerType::ScalesType ScaleType;
>     ScaleType scales(transform->GetNumberOfParameters());
>     scales.Fill( 1.0 );
>     for( unsigned j = 4; j < 7; j++ )
>     {
>             scales[j] = 1.0 / vnl_math_sqr(300.0);
>     }
>     //Scale parameters
>     optimizer->SetNumberOfIterations( 1 );
>     optimizer->SetLearningRate( 0.0000001 );
>     //set registration parameters
>     registration->SetMetric(metric);
>     registration->SetOptimizer(optimizer);
>     registration->SetTransform(transform);
>     registration->SetInterpolator(interpolator);
>     registration->SetFixedImage(fixedImage);
>     registration->SetMovingImage(movingImage);
>     // Setup the optimizer
>     optimizer->SetScales(scales);
>     registration->StartRegistration();
> ***********************************************************************
> can anybody help me with this.??
> 
> Thank you
> 
> suresh
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>