<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I'm trying to perform a straightforward rigid 
registration in 3D using sample code from the MultiResMIRegistration 
application. The transform parameters after registration are as follows for my 
MRI (T1 &amp; T2) dataset: [0.61162, 0.0627385, 0.0105601, 0.78859, 1.63678, 
-0.662944, 0.223458]. However, I suspect my post registration resampling is not 
working because the resulting volume from that is completely white. Attached is 
the exact code that I'm running. Any advice is appreciated. 
Thanks!!!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>VolumeType::Pointer MakeSymmetrical( 
VolumeType::Pointer fixedVol, VolumeType::Pointer movingVol ) {<BR>&nbsp; 
typedef itk::ChangeInformationImageFilter&lt; VolumeType &gt; 
CentererType;<BR>&nbsp; typedef itk::NormalizeImageFilter&lt; VolumeType, 
VolumeType &gt; NormalizerType;<BR>&nbsp; typedef 
itk::QuaternionRigidTransform&lt; double &gt; TransformType;<BR>&nbsp; typedef 
itk::QuaternionRigidTransformGradientDescentOptimizer OptimizerType;<BR>&nbsp; 
typedef itk::MutualInformationImageToImageMetric&lt; VolumeType, VolumeType &gt; 
MetricType;<BR>&nbsp; typedef itk::LinearInterpolateImageFunction&lt; 
VolumeType, double &gt; InterpolatorType;<BR>&nbsp; typedef 
itk::RecursiveMultiResolutionPyramidImageFilter&lt; VolumeType, VolumeType &gt; 
FixedImagePyramidType;<BR>&nbsp; typedef 
itk::RecursiveMultiResolutionPyramidImageFilter&lt; VolumeType, VolumeType &gt; 
MovingImagePyramidType;<BR>&nbsp; typedef 
itk::MultiResolutionImageRegistrationMethod&lt; VolumeType, VolumeType &gt; 
RegistrationType;<BR>&nbsp; typedef itk::FixedArray&lt; unsigned int, 3 &gt; 
ShrinkFactorsArray;<BR>&nbsp; typedef itk::Array&lt; unsigned int &gt; 
UnsignedIntArray;<BR>&nbsp; typedef itk::Array&lt; double &gt; 
DoubleArray;<BR>&nbsp; typedef itk::AffineTransform&lt; double, 3 &gt; 
AffineTransformType;<BR>&nbsp; typedef AffineTransformType::ScalarType 
CoordRepType;<BR>&nbsp; typedef itk::LinearInterpolateImageFunction&lt; 
VolumeType, CoordRepType &gt; ResampleInterpolatorType;<BR>&nbsp; typedef 
itk::ResampleImageFilter&lt; VolumeType, VolumeType &gt; 
ResamplerType;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; // Parameters<BR>&nbsp; unsigned short 
noOfLevels = 1;<BR>&nbsp; double translationScale = 1.0;<BR>&nbsp; double 
movingVolStdDev = 0.4;<BR>&nbsp; double fixedVolStdDev = 0.4;<BR>&nbsp; unsigned 
short noOfSpatialSamples = 50;<BR>&nbsp; DoubleArray learningRates = 
DoubleArray( noOfLevels );<BR>&nbsp; learningRates.Fill( 1e-4 );<BR>&nbsp; 
UnsignedIntArray noOfIterations = UnsignedIntArray( noOfLevels );<BR>&nbsp; 
noOfIterations.Fill( 2500 );<BR>&nbsp; ShrinkFactorsArray 
fixedVolShrinkFactors;<BR>&nbsp; fixedVolShrinkFactors.Fill( 1 );<BR>&nbsp; 
ShrinkFactorsArray movingVolShrinkFactors;<BR>&nbsp; 
movingVolShrinkFactors.Fill( 1 );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; // Fixed Volume<BR>&nbsp; 
CentererType::Pointer centerer =&nbsp; CentererType::New();<BR>&nbsp; 
centerer-&gt;CenterImageOn();<BR>&nbsp; centerer-&gt;SetInput( fixedVol 
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; NormalizerType::Pointer normalizer = 
NormalizerType::New();&nbsp; <BR>&nbsp; normalizer-&gt;SetInput( 
centerer-&gt;GetOutput() );<BR>&nbsp; ITK_TRY_MACRO( normalizer-&gt;Update() 
);<BR>&nbsp; VolumeType::Pointer tFixedVol = 
normalizer-&gt;GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; // Moving Volume<BR>&nbsp; 
CentererType::Pointer centerer2 =&nbsp; CentererType::New();<BR>&nbsp; 
centerer2-&gt;CenterImageOn();<BR>&nbsp; centerer2-&gt;SetInput( movingVol 
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; NormalizerType::Pointer normalizer2 = 
NormalizerType::New();&nbsp; <BR>&nbsp; normalizer2-&gt;SetInput( 
centerer2-&gt;GetOutput() );<BR>&nbsp; ITK_TRY_MACRO( normalizer2-&gt;Update() 
);<BR>&nbsp; VolumeType::Pointer tMovingVol = 
normalizer2-&gt;GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; // Setup the registrator<BR>&nbsp; 
TransformType::Pointer transform = TransformType::New();<BR>&nbsp; 
RegistrationType::ParametersType transformInitialParameters = 
RegistrationType::ParametersType( transform-&gt;GetNumberOfParameters() 
);<BR>&nbsp; transformInitialParameters.Fill( 0.0 );<BR>&nbsp; 
transformInitialParameters[3] = 1.0;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; OptimizerType::Pointer optimizer = 
OptimizerType::New();<BR>&nbsp; OptimizerType::ScalesType scales( 
transform-&gt;GetNumberOfParameters() );<BR>&nbsp; scales.Fill( 1.0 );<BR>&nbsp; 
for ( int i = 4; i &lt; 7; i++ )<BR>&nbsp;&nbsp;&nbsp; scales[i] = 
translationScale;<BR>&nbsp; optimizer-&gt;SetScales( scales );<BR>&nbsp; 
optimizer-&gt;MaximizeOn();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; MetricType::Pointer metric = 
MetricType::New();<BR>&nbsp; metric-&gt;SetMovingImageStandardDeviation( 
movingVolStdDev );<BR>&nbsp; metric-&gt;SetFixedImageStandardDeviation( 
fixedVolStdDev );<BR>&nbsp; metric-&gt;SetNumberOfSpatialSamples( 
noOfSpatialSamples );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; FixedImagePyramidType::Pointer 
fixedImagePyramid = FixedImagePyramidType::New();<BR>&nbsp; 
fixedImagePyramid-&gt;SetNumberOfLevels( noOfLevels );<BR>&nbsp; 
fixedImagePyramid-&gt;SetStartingShrinkFactors( 
fixedVolShrinkFactors.GetDataPointer() );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; MovingImagePyramidType::Pointer 
movingImagePyramid = MovingImagePyramidType::New();&nbsp; <BR>&nbsp; 
movingImagePyramid-&gt;SetNumberOfLevels( noOfLevels );<BR>&nbsp; 
movingImagePyramid-&gt;SetStartingShrinkFactors( 
movingVolShrinkFactors.GetDataPointer() );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; InterpolatorType::Pointer interpolator = 
InterpolatorType::New();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; RegistrationType::Pointer registration&nbsp; 
= RegistrationType::New();<BR>&nbsp; registration-&gt;SetTransform( transform 
);<BR>&nbsp; registration-&gt;SetOptimizer( optimizer );<BR>&nbsp; 
registration-&gt;SetMetric( metric );<BR>&nbsp; 
registration-&gt;SetInterpolator( interpolator );<BR>&nbsp; 
registration-&gt;SetFixedImagePyramid( fixedImagePyramid );<BR>&nbsp; 
registration-&gt;SetMovingImagePyramid( movingImagePyramid );<BR>&nbsp; 
registration-&gt;SetFixedImage( tFixedVol );<BR>&nbsp; 
registration-&gt;SetMovingImage( tMovingVol );<BR>&nbsp; 
registration-&gt;SetNumberOfLevels( noOfLevels );<BR>&nbsp; 
registration-&gt;SetInitialTransformParameters( transformInitialParameters 
);<BR>&nbsp; registration-&gt;SetFixedImageRegion( 
tFixedVol-&gt;GetBufferedRegion() );<BR>&nbsp; ITK_TRY_MACRO( 
registration-&gt;StartRegistration() );<BR>&nbsp; MESSAGE( "Transform Parameters 
(post-reg): " &lt;&lt; transform-&gt;GetParameters() );<BR>&nbsp; MESSAGE( 
"Rotation (post-reg): " &lt;&lt; transform-&gt;GetRotation() );<BR>&nbsp; 
MESSAGE( "Translation (post-reg): " &lt;&lt; transform-&gt;GetTranslation() 
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; // Setup the resampler<BR>&nbsp; 
AffineTransformType::Pointer resamTransform = 
AffineTransformType::New();<BR>&nbsp; 
resamTransform-&gt;SetIdentity();<BR>&nbsp; resamTransform-&gt;SetParameters( 
transform-&gt;GetParameters() );<BR>&nbsp; resamTransform-&gt;SetMatrix( 
transform-&gt;GetRotationMatrix() );<BR>&nbsp; resamTransform-&gt;SetOffset( 
transform-&gt;GetOffset() );<BR>&nbsp; <BR>&nbsp; 
ResampleInterpolatorType::Pointer resamInterpolator = 
ResampleInterpolatorType::New();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; ResamplerType::Pointer resampler = 
ResamplerType::New();<BR>&nbsp; resampler-&gt;SetInput( tMovingVol );<BR>&nbsp; 
resampler-&gt;SetTransform( resamTransform );<BR>&nbsp; 
resampler-&gt;SetInterpolator( resamInterpolator );<BR>&nbsp; 
resampler-&gt;SetSize( tFixedVol-&gt;GetLargestPossibleRegion().GetSize() 
);<BR>&nbsp; resampler-&gt;SetOutputOrigin( tFixedVol-&gt;GetOrigin() 
);<BR>&nbsp; resampler-&gt;SetOutputSpacing( tFixedVol-&gt;GetSpacing() 
);<BR>&nbsp; resampler-&gt;SetDefaultPixelValue( 0 );<BR>&nbsp; ITK_TRY_MACRO( 
resampler-&gt;Update() );<BR>&nbsp; <BR>&nbsp; return 
resampler-&gt;GetOutput();<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Andy</DIV></FONT></BODY></HTML>