<!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> </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 & 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> </DIV>
<DIV><FONT face=Arial size=2>VolumeType::Pointer MakeSymmetrical(
VolumeType::Pointer fixedVol, VolumeType::Pointer movingVol ) {<BR>
typedef itk::ChangeInformationImageFilter< VolumeType >
CentererType;<BR> typedef itk::NormalizeImageFilter< VolumeType,
VolumeType > NormalizerType;<BR> typedef
itk::QuaternionRigidTransform< double > TransformType;<BR> typedef
itk::QuaternionRigidTransformGradientDescentOptimizer OptimizerType;<BR>
typedef itk::MutualInformationImageToImageMetric< VolumeType, VolumeType >
MetricType;<BR> typedef itk::LinearInterpolateImageFunction<
VolumeType, double > InterpolatorType;<BR> typedef
itk::RecursiveMultiResolutionPyramidImageFilter< VolumeType, VolumeType >
FixedImagePyramidType;<BR> typedef
itk::RecursiveMultiResolutionPyramidImageFilter< VolumeType, VolumeType >
MovingImagePyramidType;<BR> typedef
itk::MultiResolutionImageRegistrationMethod< VolumeType, VolumeType >
RegistrationType;<BR> typedef itk::FixedArray< unsigned int, 3 >
ShrinkFactorsArray;<BR> typedef itk::Array< unsigned int >
UnsignedIntArray;<BR> typedef itk::Array< double >
DoubleArray;<BR> typedef itk::AffineTransform< double, 3 >
AffineTransformType;<BR> typedef AffineTransformType::ScalarType
CoordRepType;<BR> typedef itk::LinearInterpolateImageFunction<
VolumeType, CoordRepType > ResampleInterpolatorType;<BR> typedef
itk::ResampleImageFilter< VolumeType, VolumeType >
ResamplerType;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Parameters<BR> unsigned short
noOfLevels = 1;<BR> double translationScale = 1.0;<BR> double
movingVolStdDev = 0.4;<BR> double fixedVolStdDev = 0.4;<BR> unsigned
short noOfSpatialSamples = 50;<BR> DoubleArray learningRates =
DoubleArray( noOfLevels );<BR> learningRates.Fill( 1e-4 );<BR>
UnsignedIntArray noOfIterations = UnsignedIntArray( noOfLevels );<BR>
noOfIterations.Fill( 2500 );<BR> ShrinkFactorsArray
fixedVolShrinkFactors;<BR> fixedVolShrinkFactors.Fill( 1 );<BR>
ShrinkFactorsArray movingVolShrinkFactors;<BR>
movingVolShrinkFactors.Fill( 1 );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Fixed Volume<BR>
CentererType::Pointer centerer = CentererType::New();<BR>
centerer->CenterImageOn();<BR> centerer->SetInput( fixedVol
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> NormalizerType::Pointer normalizer =
NormalizerType::New(); <BR> normalizer->SetInput(
centerer->GetOutput() );<BR> ITK_TRY_MACRO( normalizer->Update()
);<BR> VolumeType::Pointer tFixedVol =
normalizer->GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Moving Volume<BR>
CentererType::Pointer centerer2 = CentererType::New();<BR>
centerer2->CenterImageOn();<BR> centerer2->SetInput( movingVol
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> NormalizerType::Pointer normalizer2 =
NormalizerType::New(); <BR> normalizer2->SetInput(
centerer2->GetOutput() );<BR> ITK_TRY_MACRO( normalizer2->Update()
);<BR> VolumeType::Pointer tMovingVol =
normalizer2->GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Setup the registrator<BR>
TransformType::Pointer transform = TransformType::New();<BR>
RegistrationType::ParametersType transformInitialParameters =
RegistrationType::ParametersType( transform->GetNumberOfParameters()
);<BR> transformInitialParameters.Fill( 0.0 );<BR>
transformInitialParameters[3] = 1.0;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> OptimizerType::Pointer optimizer =
OptimizerType::New();<BR> OptimizerType::ScalesType scales(
transform->GetNumberOfParameters() );<BR> scales.Fill( 1.0 );<BR>
for ( int i = 4; i < 7; i++ )<BR> scales[i] =
translationScale;<BR> optimizer->SetScales( scales );<BR>
optimizer->MaximizeOn();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> MetricType::Pointer metric =
MetricType::New();<BR> metric->SetMovingImageStandardDeviation(
movingVolStdDev );<BR> metric->SetFixedImageStandardDeviation(
fixedVolStdDev );<BR> metric->SetNumberOfSpatialSamples(
noOfSpatialSamples );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> FixedImagePyramidType::Pointer
fixedImagePyramid = FixedImagePyramidType::New();<BR>
fixedImagePyramid->SetNumberOfLevels( noOfLevels );<BR>
fixedImagePyramid->SetStartingShrinkFactors(
fixedVolShrinkFactors.GetDataPointer() );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> MovingImagePyramidType::Pointer
movingImagePyramid = MovingImagePyramidType::New(); <BR>
movingImagePyramid->SetNumberOfLevels( noOfLevels );<BR>
movingImagePyramid->SetStartingShrinkFactors(
movingVolShrinkFactors.GetDataPointer() );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> InterpolatorType::Pointer interpolator =
InterpolatorType::New();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> RegistrationType::Pointer registration
= RegistrationType::New();<BR> registration->SetTransform( transform
);<BR> registration->SetOptimizer( optimizer );<BR>
registration->SetMetric( metric );<BR>
registration->SetInterpolator( interpolator );<BR>
registration->SetFixedImagePyramid( fixedImagePyramid );<BR>
registration->SetMovingImagePyramid( movingImagePyramid );<BR>
registration->SetFixedImage( tFixedVol );<BR>
registration->SetMovingImage( tMovingVol );<BR>
registration->SetNumberOfLevels( noOfLevels );<BR>
registration->SetInitialTransformParameters( transformInitialParameters
);<BR> registration->SetFixedImageRegion(
tFixedVol->GetBufferedRegion() );<BR> ITK_TRY_MACRO(
registration->StartRegistration() );<BR> MESSAGE( "Transform Parameters
(post-reg): " << transform->GetParameters() );<BR> MESSAGE(
"Rotation (post-reg): " << transform->GetRotation() );<BR>
MESSAGE( "Translation (post-reg): " << transform->GetTranslation()
);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Setup the resampler<BR>
AffineTransformType::Pointer resamTransform =
AffineTransformType::New();<BR>
resamTransform->SetIdentity();<BR> resamTransform->SetParameters(
transform->GetParameters() );<BR> resamTransform->SetMatrix(
transform->GetRotationMatrix() );<BR> resamTransform->SetOffset(
transform->GetOffset() );<BR> <BR>
ResampleInterpolatorType::Pointer resamInterpolator =
ResampleInterpolatorType::New();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> ResamplerType::Pointer resampler =
ResamplerType::New();<BR> resampler->SetInput( tMovingVol );<BR>
resampler->SetTransform( resamTransform );<BR>
resampler->SetInterpolator( resamInterpolator );<BR>
resampler->SetSize( tFixedVol->GetLargestPossibleRegion().GetSize()
);<BR> resampler->SetOutputOrigin( tFixedVol->GetOrigin()
);<BR> resampler->SetOutputSpacing( tFixedVol->GetSpacing()
);<BR> resampler->SetDefaultPixelValue( 0 );<BR> ITK_TRY_MACRO(
resampler->Update() );<BR> <BR> return
resampler->GetOutput();<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Andy</DIV></FONT></BODY></HTML>