[Insight-users] MR Registration

cspl affable at hd2 . dot . net . in
Thu, 8 Aug 2002 15:12:18 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_0641_01C23EED.FCA46A40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Friends,
 I am working on MRI Registration.I have made my own project using MRI =
Registration example available in ITK examples.It is working well for =
some MRI images.But,It is throwing exception  at StartRegistration() for =
some imagess.I have hard coded the Parameters which I have to set before =
calling StartRegistration().Plese, help me in solving my problem and =
give me some information on setting parameter values. Here I am =
enclosing the code and parameters details.I am also enclosing the =
exception message thrown by startregistration().=20

//Exception message
itk::ERROR: MutualInformationImageToImageMetric(003C6D20): All the =
sampled point mapped to outside of the moving image

//Code and parameter details

typedef itk::QuaternionRigidTransform<double> TransformType;
  typedef itk::QuaternionRigidTransformGradientDescentOptimizer =
OptimizerType;
  typedef itk::MutualInformationImageToImageMetric<ImageType, ImageType> =
MetricType;
  typedef itk::LinearInterpolateImageFunction<ImageType, double> =
InterpolatorType;
  typedef itk::ImageRegistrationMethod<ImageType,ImageType> =
RegistrationType1;


  MetricType::Pointer         metric        =3D MetricType::New();
  TransformType::Pointer      transform     =3D TransformType::New();
  OptimizerType::Pointer      optimizer     =3D OptimizerType::New();
  InterpolatorType::Pointer   interpolator  =3D InterpolatorType::New();
  RegistrationType1::Pointer  registration  =3DRegistrationType1::New();
=20

  RegistrationType1::ParametersType =
guess(transform->GetNumberOfParameters() );
  =20
  guess[0] =3D 0.0;
  guess[1] =3D 0.0;
  guess[2] =3D 0.0;
  guess[3] =3D 1.0;
  guess[4] =3D 20.0;
  guess[5] =3D 40.0;
  guess[6] =3D 0.0;

  registration->SetInitialTransformParameters (guess);
=20
  =20
  //set metric parameters
  metric->SetMovingImageStandardDeviation( 2 );
  metric->SetFixedImageStandardDeviation( 2 );
  metric->SetNumberOfSpatialSamples( 50 );
  =20
 =20
 // Set translation scale
  typedef OptimizerType::ScalesType ScaleType;
  ScaleType scales(transform->GetNumberOfParameters());
  scales.Fill( 1.0 );
  for( unsigned j =3D 4; j < 7; j++ )
    {
  scales[j] =3D 1.0 / vnl_math_sqr(1.0);
    }
 =20
=20

 //Scale parameters=20
  optimizer->SetNumberOfIterations( 2000 );
  optimizer->SetLearningRate( 0.0005 );


  //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);
  //optimizer->MaximizeOn();
=20
=20
  AfxMessageBox("Before registration") ;
  registration->StartRegistration();
  AfxMessageBox("After registration") ;
 =20
  // Get the results
  itk::Array<double>  *arr=3Dnew itk::Array<double>;
  RegistrationType1::ParametersType solution =
=3Dregistration->GetLastTransformParameters();


Regars,
CSPL=20

------=_NextPart_000_0641_01C23EED.FCA46A40
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear Friends,<BR>&nbsp;I am working on =
MRI=20
Registration.I have made my own project using MRI Registration example =
available=20
in ITK examples.It is working well for some MRI images.But,It is =
throwing=20
exception&nbsp; at StartRegistration() for some imagess.I have hard =
coded the=20
Parameters which I have to set before calling StartRegistration().Plese, =
help me=20
in solving my problem and give me some information on setting parameter =
values.=20
Here I am enclosing the code and parameters details.I am also enclosing =
the=20
exception message thrown by startregistration(). </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>//Exception message<BR>itk::ERROR:=20
MutualInformationImageToImageMetric(003C6D20): All the sampled point =
mapped to=20
outside of the moving image</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>//Code and parameter =
details</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>typedef =
itk::QuaternionRigidTransform&lt;double&gt;=20
TransformType;<BR>&nbsp; typedef=20
itk::QuaternionRigidTransformGradientDescentOptimizer =
OptimizerType;<BR>&nbsp;=20
typedef itk::MutualInformationImageToImageMetric&lt;ImageType, =
ImageType&gt;=20
MetricType;<BR>&nbsp; typedef =
itk::LinearInterpolateImageFunction&lt;ImageType,=20
double&gt; InterpolatorType;<BR>&nbsp; typedef=20
itk::ImageRegistrationMethod&lt;ImageType,ImageType&gt;=20
RegistrationType1;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>&nbsp;=20
MetricType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
metric&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D =
MetricType::New();<BR>&nbsp;=20
TransformType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
transform&nbsp;&nbsp;&nbsp;&nbsp; =3D TransformType::New();<BR>&nbsp;=20
OptimizerType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
optimizer&nbsp;&nbsp;&nbsp;&nbsp; =3D OptimizerType::New();<BR>&nbsp;=20
InterpolatorType::Pointer&nbsp;&nbsp; interpolator&nbsp; =3D=20
InterpolatorType::New();<BR>&nbsp; RegistrationType1::Pointer&nbsp;=20
registration&nbsp; =3DRegistrationType1::New();<BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; RegistrationType1::ParametersType=20
guess(transform-&gt;GetNumberOfParameters() );<BR>&nbsp;&nbsp; =
<BR>&nbsp;=20
guess[0] =3D 0.0;<BR>&nbsp; guess[1] =3D 0.0;<BR>&nbsp; guess[2] =3D =
0.0;<BR>&nbsp;=20
guess[3] =3D 1.0;<BR>&nbsp; guess[4] =3D 20.0;<BR>&nbsp; guess[5] =3D =
40.0;<BR>&nbsp;=20
guess[6] =3D 0.0;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; registration-&gt;SetInitialTransformParameters=20
(guess);<BR>&nbsp;<BR>&nbsp;&nbsp; <BR>&nbsp; //set metric =
parameters<BR>&nbsp;=20
metric-&gt;SetMovingImageStandardDeviation( 2 );<BR>&nbsp;=20
metric-&gt;SetFixedImageStandardDeviation( 2 );<BR>&nbsp;=20
metric-&gt;SetNumberOfSpatialSamples( 50 );<BR>&nbsp;&nbsp; <BR>&nbsp;=20
<BR>&nbsp;// Set translation scale<BR>&nbsp; typedef =
OptimizerType::ScalesType=20
ScaleType;<BR>&nbsp; ScaleType=20
scales(transform-&gt;GetNumberOfParameters());<BR>&nbsp; scales.Fill( =
1.0=20
);<BR>&nbsp; for( unsigned j =3D 4; j &lt; 7; j++ =
)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;scales[j] =3D 1.0 / =
vnl_math_sqr(1.0);<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp; <BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;//Scale parameters&nbsp;<BR>&nbsp;=20
optimizer-&gt;SetNumberOfIterations( 2000 );<BR>&nbsp;=20
optimizer-&gt;SetLearningRate( 0.0005 );</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp; //set registration parameters<BR>&nbsp;=20
registration-&gt;SetMetric(metric);<BR>&nbsp;=20
registration-&gt;SetOptimizer(optimizer);<BR>&nbsp;=20
registration-&gt;SetTransform(transform);<BR>&nbsp;=20
registration-&gt;SetInterpolator(interpolator);<BR>&nbsp;=20
registration-&gt;SetFixedImage(FixedImage);<BR>&nbsp;=20
registration-&gt;SetMovingImage(MovingImage);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // Setup the optimizer<BR>&nbsp;=20
optimizer-&gt;SetScales(scales);<BR>&nbsp;=20
//optimizer-&gt;MaximizeOn();<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;=20
AfxMessageBox("Before registration") ;<BR>&nbsp;=20
registration-&gt;StartRegistration();<BR>&nbsp; AfxMessageBox("After=20
registration") ;<BR>&nbsp; <BR>&nbsp; // Get the results<BR>&nbsp;=20
itk::Array&lt;double&gt;&nbsp; *arr=3Dnew =
itk::Array&lt;double&gt;;<BR>&nbsp;=20
RegistrationType1::ParametersType solution=20
=3Dregistration-&gt;GetLastTransformParameters();</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Regars,<BR>CSPL </FONT></DIV></BODY></HTML>

------=_NextPart_000_0641_01C23EED.FCA46A40--