<br>Hi Davoud,<br><br>The TPS class has not implemented its method<br><br> GetJacobian()<br><br>therefore, you can't use it with optimizers that<br>require the computation of metric derivatives.<br><br>You may try then, the following two optimizers:<br>
<br>A) OnePlusOneEvolutionaryOptimizer<br><br>B) AmoebaOptimizer<br><br><br>These two optimizers only require Metrics to <br>compute the GetValue() and therefore do not<br>invoke the GetJacobian() method in the <br>Transforms.<br>
<br><br> Regards,<br><br><br> Luis<br><br><br>----------------------------------------------------<br><div class="gmail_quote">On Thu, Sep 23, 2010 at 5:21 PM, Dav <span dir="ltr"><<a href="mailto:davoud_zzz@yahoo.com">davoud_zzz@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">
<div>Greetings dear members,</div><div>I am trying to register pair of CT images using the Thin-Plate Spline (TPS) transform and the following source code is the section related to TPS registration:</div><div><br></div><div>
**********************************************************************************************************</div><div><br></div><div>const unsigned int Dimension = 2;</div><div> typedef short PixelType;</div><div>
</div><div> typedef itk::Image< PixelType, Dimension > FixedImageType;</div><div> typedef itk::Image< PixelType, Dimension > MovingImageType;</div><div> typedef double CoordinateRepType;</div><div> typedef itk::ThinPlateSplineKernelTransform< CoordinateRepType, Dimension>
TransformType;</div><div> typedef itk::ImageRegistrationMethod< FixedImageType, MovingImageType > RegistrationType;</div><div> typedef itk::Point< CoordinateRepType, Dimension > PointType;</div><div> typedef TransformType::PointSetType PointSetType;</div>
<div> typedef PointSetType::Pointer PointSetPointer;</div><div> typedef PointSetType::PointIdentifier PointIdType;</div><div> </div><div> typedef itk::RegularStepGradientDescentOptimizer OptimizerType;</div>
<div> typedef itk::MutualInformationImageToImageMetric< FixedImageType, MovingImageType > MetricType;</div><div> typedef itk:: LinearInterpolateImageFunction< MovingImageType, double> InterpolatorType;</div>
<div> </div><div> OptimizerType::Pointer
optimizer = OptimizerType::New();</div><div> InterpolatorType::Pointer interpolator = InterpolatorType::New();</div><div> RegistrationType::Pointer registration = RegistrationType::New();</div><div> MetricType::Pointer metric = MetricType::New();</div>
<div> </div><div> //------------------------------------------------------------------------------------------------------//</div><div><br></div><div> PointSetType::Pointer sourceLandMarks = PointSetType::New();</div><div>
PointSetType::Pointer targetLandMarks = PointSetType::New();</div><div> PointType p1; </div><div> PointType p2;</div><div> PointSetType::PointsContainer::Pointer sourceLandMarkContainer =
sourceLandMarks->GetPoints();</div><div> PointSetType::PointsContainer::Pointer targetLandMarkContainer = targetLandMarks->GetPoints();</div><div> PointIdType id = itk::NumericTraits< PointIdType >::Zero;</div>
<div> // Read in the list of landmarks</div><div> std::ifstream infile;</div><div> infile.open( argv[1] );</div><div> while (!infile.eof())</div><div> {</div><div> infile >> p1[0] >> p1[1] >> p2[0] >> p2[1];</div>
<div> sourceLandMarkContainer->InsertElement( id, p1 );</div><div> targetLandMarkContainer->InsertElement( id++, p2 );</div><div> }</div><div> infile.close();</div><div> TransformType::Pointer tps =
TransformType::New();</div><div> tps->SetSourceLandmarks(sourceLandMarks);</div><div> tps->SetTargetLandmarks(targetLandMarks);</div><div> tps->ComputeWMatrix();</div><div> //-------------------------------------------------------------------------------------------------------//</div>
<div><br></div><div> registration->SetOptimizer( optimizer );</div><div> registration->SetTransform( tps );</div><div> registration->SetInterpolator( interpolator );</div><div> registration->SetMetric( metric );</div>
<div> </div><div> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;</div><div> typedef itk::ImageFileReader< MovingImageType >
MovingImageReaderType;</div><div> FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();</div><div> MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();</div><div> fixedImageReader->SetFileName( argv[2] );</div>
<div> movingImageReader->SetFileName( argv[3] );</div><div> </div><div> registration->SetFixedImage( fixedImageReader->GetOutput() );</div><div> registration->SetMovingImage( movingImageReader->GetOutput() );</div>
<div> fixedImageReader->Update();</div><div> registration->SetFixedImageRegion( fixedImageReader->GetOutput()->GetBufferedRegion() );</div><div> </div><div> typedef RegistrationType::ParametersType ParametersType;</div>
<div> ParametersType initialParameters(
tps->GetNumberOfParameters() );</div><div> initialParameters = tps->GetParameters();</div><div> std::cout << " TPS Parameters = " << tps->GetParameters() << std::endl;</div><div> std::cout << " TPS Parameters = " << initialParameters << std::endl;</div>
<div> registration->SetInitialTransformParameters( initialParameters );</div><div> optimizer->SetNumberOfIterations( 200 );</div><div> optimizer->SetRelaxationFactor( 0.9 );</div><div> </div><div> try</div><div>
{</div><div> registration->StartRegistration();</div><div> std::cout << "Optimizer stop condition: "</div><div> << registration->GetOptimizer()->GetStopConditionDescription()</div>
<div>
<< std::endl;</div><div> }</div><div> catch( itk::ExceptionObject & err )</div><div> {</div><div> std::cout << "ExceptionObject caught !" << std::endl;</div><div> std::cout << err << std::endl;</div>
<div> return EXIT_FAILURE;</div><div> }</div><div>*********************************************************************************************************</div><div><br></div><div><br></div><div>This code is suppose to register two CT images with predefined landmarks which are the TPS transformation parameters. The code compiles just fine however in time of execution I get the following error: </div>
<div><br></div><div><br></div><div>*********************************************************************************************************</div><div>Location: "const class itk::Array2D<double>
&__thiscall itk::KernelTransform<double,2>::GetJacobian(const class itk::Point<double,2> &) const"</div><div>File: e:\research programs\[][ir] itk\insighttoolkit-3.18.0\code\common\itkKernelTransform.txx</div>
<div>Line: 455</div><div>Description: itk::ERROR: ThinPlateSplineKernelTransform(01571248): GetJacobian must be implemented in subclasses of KernelTransform.</div><div><br></div><div>***************************************************************************</div>
<div><br></div><div>The used landmark file is similar to what have been used for the ThinPlateSplineWarp example in the ITK framework and I don't think that is the cause of error. My guess is that the parameters initialization of the registration method is not configured properly but I don't know how to correct that. I would appreciate any help to solve this issue.</div>
<div>Best regards,</div><div>Davoud.</div></td></tr></tbody></table><br>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>