[Insight-users] On Interpolation and transform parameters

cspl affable@hd2.dot.net.in
Thu, 26 Sep 2002 19:08:17 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_001E_01C26590.12213F60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Mr.Luis,
 I am working on registration.I have used Affinetranformation class for =
transformation.My registration code is working fine and i could be able =
to resample the image after registration.But,I have some doubts =
regarding initial transform parameters and interpolation.I have observed =
that registration output is dependent on Initial transform parameters.I =
have some other tool to test the registration output.I could not get the =
output matching with that tool.I think by setting Initial transform =
parameters to some values we coud get the output.Because,the final =
registration matrix is close to initial parmeters.I have no idea about =
what these parameters hold.Please, tell me whether my opinion is correct =
or not and tell me how to set these parameters.I am enclosing the =
parameters i have tried.

case1:
=20
   for(int i=3D1;i<12;i++)
    initialParameters[i]=3D0.1;
   initialParameters[3]=3D0.5;
         initialParameters[5]=3D0.3;
   initialParameters[0] =3D 1.0;
   initialParameters[4] =3D 1.0;
   initialParameters[8] =3D 1.0;  =20
case2:
 =20
   for(int i=3D1;i<12;i++)
    initialParameters[i]=3D0.0;
   initialParameters[0] =3D 1.0;
   initialParameters[4] =3D 1.0;
   initialParameters[8] =3D 1.0;
case 3:
=20
   for(int i=3D1;i<12;i++)
    initialParameters[i]=3D0.1;
   initialParameters[3]=3D0.5;
          initialParameters[5]=3D0.1;
   initialParameters[0] =3D 1.0;
   initialParameters[4] =3D 1.0;
   initialParameters[8] =3D 1.0;=20
   initialParameters[10]=3D0.3;=20
   =20

 I am having one more doubt regarding the role of interpolator in   =
registration and resampling.when i registered MRI and SPECT(Mri as   =
Fixed and SPECT as mooving) I could get the registered voilume equal  to =
the fixed volume.But, the Images size is  decreasing.I am getting small =
images.Please,tell me how i could solve  this problem and why it is =
getting.I am enclosing resample code and  registration code also.

Registration code:
  typedef OptimizerType::ScalesType ScalesType;
     ScalesType parametersScales( transform->GetNumberOfParameters() );
   =20
    parametersScales.Fill( 1.0 );
   =20
    double scale =3D 1.0 / vnl_math_sqr( 500);
      =20
    for (int  j =3D 9; j < 12; j++ )
    {

     parametersScales[j] =3D scale;
    }
   =20
    optimizer->SetScales( parametersScales );
   =20
    // need to maximize for mutual information
    optimizer->MaximizeOn();

    ////////////////////////////////////////////////////////////////////
    //Set up the metric.
       =
////////////////////////////////////////////////////////////////////   =20
    metric->SetMovingImageStandardDeviation(      =
movingImageStatisticsFilter->GetSigma() * 0.4 );
    metric->SetFixedImageStandardDeviation(     =
fixedImageStatisticsFilter->GetSigma() * 0.4 );
    metric->SetNumberOfSpatialSamples( 50);
    metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );   =20


      =
////////////////////////////////////////////////////////////////////
      // Set up the registrator.
      =
////////////////////////////////////////////////////////////////////

  // connect up the components
   registration->SetMetric( metric );
   registration->SetOptimizer( optimizer );
   registration->SetTransform( transform );
   registration->SetFixedImage(fixedImage );
   registration->SetMovingImage( movingImage  );
   registration->SetInterpolator( interpolator );
 =20
   // set initial parameters to identity
   RegistrationType::ParametersType initialParameters(=20
     transform->GetNumberOfParameters() );

   initialParameters.Fill( 0.0 );
   for(int i=3D1;i<12;i++)
    initialParameters[i]=3D0.1;
   initialParameters[3]=3D0.5;
         initialParameters[5]=3D0.3;
   initialParameters[0] =3D 1.0;
   initialParameters[4] =3D 1.0;
   initialParameters[8] =3D 1.0;    =20
 =20
      registration->SetInitialTransformParameters( initialParameters );
      optimizer->SetNumberOfIterations(4);

   try
   {
    registration->StartRegistration();    =20

   }catch(itk::ExceptionObject& Eo)
   {  =20
      AfxMessageBox(Eo.GetDescription());
   return NULL;
   }=20





resample code:

    resampleFilter ->SetTransform(transform);
    resampleFilter->SetInput(movingImage);   =20

    resampleFilter->SetSize( =
mriImage->GetLargestPossibleRegion().GetSize());
    resampleFilter->SetOutputOrigin( mriImage->GetOrigin() );
    resampleFilter->SetOutputSpacing( mriImage->GetSpacing() );
    resampleFilter->Update();

Regards,
CSPL


------=_NextPart_000_001E_01C26590.12213F60
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 Mr.Luis,<BR>&nbsp;I am working on=20
registration.I have used Affinetranformation class for transformation.My =

registration code is working fine and i could be able to resample the =
image=20
after registration.But,I have some doubts regarding initial transform =
parameters=20
and interpolation.I have observed that registration output is dependent =
on=20
Initial transform parameters.I have some other tool to test the =
registration=20
output.I could not get the output matching with that tool.I think by =
setting=20
Initial transform parameters to some values we coud get the =
output.Because,the=20
final registration matrix is close to initial parmeters.I have no idea =
about=20
what these parameters hold.Please, tell me whether my opinion is correct =
or not=20
and tell me how to set these parameters.I am enclosing the parameters i =
have=20
tried.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>case1:<BR>&nbsp;<BR>&nbsp;&nbsp; =
for(int=20
i=3D1;i&lt;12;i++)<BR>&nbsp;&nbsp;&nbsp; =
initialParameters[i]=3D0.1;<BR>&nbsp;&nbsp;=20
initialParameters[3]=3D0.5;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;=20
initialParameters[5]=3D0.3;<BR>&nbsp;&nbsp; initialParameters[0] =3D=20
1.0;<BR>&nbsp;&nbsp; initialParameters[4] =3D 1.0;<BR>&nbsp;&nbsp;=20
initialParameters[8] =3D 1.0;&nbsp; &nbsp;<BR>case2:<BR>&nbsp; =
<BR>&nbsp;&nbsp;=20
for(int i=3D1;i&lt;12;i++)<BR>&nbsp;&nbsp;&nbsp;=20
initialParameters[i]=3D0.0;<BR>&nbsp;&nbsp; initialParameters[0] =3D=20
1.0;<BR>&nbsp;&nbsp; initialParameters[4] =3D 1.0;<BR>&nbsp;&nbsp;=20
initialParameters[8] =3D 1.0;<BR>case 3:<BR>&nbsp;<BR>&nbsp;&nbsp; =
for(int=20
i=3D1;i&lt;12;i++)<BR>&nbsp;&nbsp;&nbsp; =
initialParameters[i]=3D0.1;<BR>&nbsp;&nbsp;=20
initialParameters[3]=3D0.5;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
initialParameters[5]=3D0.1;<BR>&nbsp;&nbsp; initialParameters[0] =3D=20
1.0;<BR>&nbsp;&nbsp; initialParameters[4] =3D 1.0;<BR>&nbsp;&nbsp;=20
initialParameters[8] =3D 1.0; <BR>&nbsp;&nbsp;=20
initialParameters[10]=3D0.3;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DI=
V>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;I am having one more doubt =
regarding the role=20
of interpolator in &nbsp;&nbsp;registration and resampling.when i =
registered MRI=20
and SPECT(Mri as &nbsp;&nbsp;Fixed and SPECT as mooving) I could get the =

registered voilume equal &nbsp;to the fixed volume.But, the Images size =
is=20
&nbsp;decreasing.I am getting small images.Please,tell me how i could =
solve=20
&nbsp;this problem and why it is getting.I am enclosing resample code =
and=20
&nbsp;registration code also.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Registration code:<BR>&nbsp; typedef=20
OptimizerType::ScalesType ScalesType;<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
ScalesType=20
parametersScales( transform-&gt;GetNumberOfParameters() =
);<BR>&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp; parametersScales.Fill( 1.0 =
);<BR>&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp; double scale =3D 1.0 / vnl_math_sqr(=20
500);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; for =

(int&nbsp; j =3D 9; j &lt; 12; j++ )<BR>&nbsp;&nbsp;&nbsp; =
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; =
parametersScales[j] =3D=20
scale;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; =
<BR>&nbsp;&nbsp;&nbsp;=20
optimizer-&gt;SetScales( parametersScales );<BR>&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp; // need to maximize for mutual=20
information<BR>&nbsp;&nbsp;&nbsp; =
optimizer-&gt;MaximizeOn();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
////////////////////////////////////////////////////////////////////<BR>&=
nbsp;&nbsp;&nbsp;=20
//Set up the metric.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
////////////////////////////////////////////////////////////////////&nbsp=
;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp; metric-&gt;SetMovingImageStandardDeviation(&nbsp; =

&nbsp;&nbsp;&nbsp; movingImageStatisticsFilter-&gt;GetSigma() * 0.4=20
);<BR>&nbsp;&nbsp;&nbsp; metric-&gt;SetFixedImageStandardDeviation(=20
&nbsp;&nbsp;&nbsp; fixedImageStatisticsFilter-&gt;GetSigma() * 0.4=20
);<BR>&nbsp;&nbsp;&nbsp; metric-&gt;SetNumberOfSpatialSamples(=20
50);<BR>&nbsp;&nbsp;&nbsp; metric-&gt;SetFixedImageRegion(=20
fixedImage-&gt;GetBufferedRegion() );&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
////////////////////////////////////////////////////////////////////<BR>&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
// Set up the registrator.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
////////////////////////////////////////////////////////////////////</DIV=
>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // connect up the components<BR>&nbsp;&nbsp;=20
registration-&gt;SetMetric( metric );<BR>&nbsp;&nbsp;=20
registration-&gt;SetOptimizer( optimizer );<BR>&nbsp;&nbsp;=20
registration-&gt;SetTransform( transform );<BR>&nbsp;&nbsp;=20
registration-&gt;SetFixedImage(fixedImage );<BR>&nbsp;&nbsp;=20
registration-&gt;SetMovingImage( movingImage&nbsp; );<BR>&nbsp;&nbsp;=20
registration-&gt;SetInterpolator( interpolator );<BR>&nbsp; =
<BR>&nbsp;&nbsp; //=20
set initial parameters to identity<BR>&nbsp;&nbsp;=20
RegistrationType::ParametersType initialParameters(=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform-&gt;GetNumberOfParameters() =
);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; initialParameters.Fill( 0.0 );<BR>&nbsp;&nbsp; for(int =

i=3D1;i&lt;12;i++)<BR>&nbsp;&nbsp;&nbsp; =
initialParameters[i]=3D0.1;<BR>&nbsp;&nbsp;=20
initialParameters[3]=3D0.5;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
initialParameters[5]=3D0.3;<BR>&nbsp;&nbsp; initialParameters[0] =3D=20
1.0;<BR>&nbsp;&nbsp; initialParameters[4] =3D 1.0;<BR>&nbsp;&nbsp;=20
initialParameters[8] =3D 1.0;&nbsp; &nbsp;&nbsp; <BR>&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
registration-&gt;SetInitialTransformParameters( initialParameters=20
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
optimizer-&gt;SetNumberOfIterations(4);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; try<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
registration-&gt;StartRegistration();&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; }catch(itk::ExceptionObject&amp; Eo)<BR>&nbsp;&nbsp;=20
{&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
AfxMessageBox(Eo.GetDescription());<BR>&nbsp;&nbsp; return =
NULL;<BR>&nbsp;&nbsp;=20
}&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>resample code:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; resampleFilter=20
-&gt;SetTransform(transform);<BR>&nbsp;&nbsp;&nbsp;=20
resampleFilter-&gt;SetInput(movingImage);&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; resampleFilter-&gt;SetSize(=20
mriImage-&gt;GetLargestPossibleRegion().GetSize());<BR>&nbsp;&nbsp;&nbsp;=
=20
resampleFilter-&gt;SetOutputOrigin( mriImage-&gt;GetOrigin()=20
);<BR>&nbsp;&nbsp;&nbsp; resampleFilter-&gt;SetOutputSpacing(=20
mriImage-&gt;GetSpacing() );<BR>&nbsp;&nbsp;&nbsp;=20
resampleFilter-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards,<BR>CSPL<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_001E_01C26590.12213F60--