[Insight-users] Affine registration and Viola-Wells MI

Markus Voigt Markus.Voigt at medizin.uni-leipzig.de
Wed Jun 6 10:32:47 EDT 2007


Hi Xabier,

the error comes after the first iteration. I think I have focused the 
problem:
the Optimizer has no stopping criteria. The optimzer tries to run for 
the assigned numbers of iterations
    optimizer->SetNumberOfIterations( maxNumberOfIterations );
if I set the numbers of iterations to 1 I don't get an error message.
If I set the lerning rate to 0.1 it runs 22 iterations.
I have programmed the affine algorithm with the Mattes MI and it runs 
perfect with good results.
With the affine algorithm with Viola-Wells MI  I get horrible results.
The problem is that I have to use the Viola-Wells MI algorithm
Regards,
Markus

Xabier Artaechevarria Artieda schrieb:
> Hi Markus,
>
> Does the error come out in the first iteration or later?
>
> Regards,
> Xabi
>
>
>
> "Voigt, Markus" <Markus.Voigt at medizin.uni-leipzig.de> ha escrito:
>
>> Hello,
>>
>> I'm trying to create a program where I want to use the Viola-Wells
>> (Mutual Information algorithm) and the affine registration.
>>
>> In the examples of ITK I found the MI algorithm and the affine algorithm
>> but both are using different Optimizer. I tried to match all the things
>> together in one cpp-file so that it should work but it doesn't
>>
>> I got this error message on the command line:
>>
>>  "MutualInformationImageToImageMetric(018CBC40): All the sampled point
>> mapped to outside of the moving image"
>>
>> Could someone help me? I think it is something simple, but I haven't got
>> a clue.
>>
>> Cheers,
>>
>> markus
>>
>>
>>
>>
>>
>> This is the source code
>>
>>
>>
>>   //start Viola-Wells mutual information
>>
>>   metric->SetFixedImageStandardDeviation(  0.4 );
>>
>>   metric->SetMovingImageStandardDeviation( 0.4 );
>>
>>
>>
>>   //load pictures
>>
>>   typedef itk::ImageFileReader< FixedImageType  > FixedImageReaderType;
>>
>>   typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
>>
>>   FixedImageReaderType::Pointer  fixedImageReader  =
>> FixedImageReaderType::New();
>>
>>   MovingImageReaderType::Pointer movingImageReader =
>> MovingImageReaderType::New();
>>
>>   fixedImageReader->SetFileName(  arg1 );
>>
>>   movingImageReader->SetFileName( arg2 );
>>
>>
>>
>>
>>
>>   typedef itk::NormalizeImageFilter<
>>
>>                                 FixedImageType,
>>
>>                                 InternalImageType
>>
>>                                         > FixedNormalizeFilterType;
>>
>>   typedef itk::NormalizeImageFilter<
>>
>>                                 FixedImageType,
>>
>>                                 InternalImageType
>>
>>                                               >
>> MovingNormalizeFilterType;
>>
>>   FixedNormalizeFilterType::Pointer fixedNormalizer =
>> FixedNormalizeFilterType::New();
>>
>>   MovingNormalizeFilterType::Pointer movingNormalizer =
>> MovingNormalizeFilterType::New();
>>
>>
>>
>>
>>
>>   typedef itk::DiscreteGaussianImageFilter<
>>
>>                                 InternalImageType,
>>
>>                                 InternalImageType
>>
>>                                               > GaussianFilterType;
>>
>>   GaussianFilterType::Pointer fixedSmoother  =
>> GaussianFilterType::New();
>>
>>   GaussianFilterType::Pointer movingSmoother =
>> GaussianFilterType::New();
>>
>>
>>
>>   fixedSmoother->SetVariance( 2.0 );
>>
>>   movingSmoother->SetVariance( 2.0 );
>>
>>
>>
>>   fixedNormalizer->SetInput(  fixedImageReader->GetOutput() );
>>
>>   movingNormalizer->SetInput( movingImageReader->GetOutput() );
>>
>>
>>
>>   fixedSmoother->SetInput( fixedNormalizer->GetOutput() );
>>
>>   movingSmoother->SetInput( movingNormalizer->GetOutput() );
>>
>>
>>
>>   registration->SetFixedImage( fixedSmoother->GetOutput() );
>>
>>   registration->SetMovingImage( movingSmoother->GetOutput() );
>>
>>
>>
>>   fixedNormalizer->Update();
>>
>>   FixedImageType::RegionType fixedImageRegion =
>> fixedNormalizer->GetOutput()->GetBufferedRegion();
>>
>>   registration->SetFixedImageRegion( fixedImageRegion );
>>
>>   //end of Viola Wells MI
>>
>>
>>
>>   //start with affine part
>>
>>   typedef itk::CenteredTransformInitializer< TransformType,
>> FixedImageType,MovingImageType >  TransformInitializerType;
>>
>>   TransformInitializerType::Pointer initializer =
>> TransformInitializerType::New();
>>
>>   initializer->SetTransform(   transform );
>>
>>   initializer->SetFixedImage(  fixedImageReader->GetOutput() );
>>
>>   initializer->SetMovingImage( movingImageReader->GetOutput() );
>>
>>   initializer->MomentsOn();
>>
>>   initializer->InitializeTransform();
>>
>>
>>
>>   registration->SetInitialTransformParameters(transform->GetParameters()
>> );
>>
>>   double translationScale = 1.0 / 1000.0;
>>
>>   unsigned int maxNumberOfIterations = atoi( arg7 );
>>
>>
>>
>>   typedef OptimizerType::ScalesType       OptimizerScalesType;
>>
>>   OptimizerScalesType optimizerScales(
>> transform->GetNumberOfParameters() );
>>
>>
>>
>>   //rotation matrix factor
>>
>>   optimizerScales[0] =  1.0;
>>
>>   optimizerScales[1] =  1.0;
>>
>>   //rotation center
>>
>>   optimizerScales[2] =  1.0;
>>
>>   optimizerScales[3] =  1.0;
>>
>>   //components of the translation
>>
>>   optimizerScales[4] =  translationScale;
>>
>>   optimizerScales[5] =  translationScale;
>>
>>   optimizer->SetScales( optimizerScales );
>>
>>
>>
>>
>>
>>   optimizer->SetLearningRate( 15.0 );
>>
>>   optimizer->SetNumberOfIterations( maxNumberOfIterations );
>>
>>   optimizer->MaximizeOn();
>>
>>
>>
>>   CommandIterationUpdate::Pointer observer =
>> CommandIterationUpdate::New();
>>
>>   optimizer->AddObserver( itk::IterationEvent(), observer );
>>
>>   //end with affine part
>>
>>
>
>
>
> ----------------------------------------------------------------
> Este mensaje ha sido enviado desde https://webmail.unav.es
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list