[Insight-users] DeformableRegistration8 with Normalized Mutual Information

Serena Fabbri fabbri at u.washington.edu
Tue Jul 14 12:59:54 EDT 2009


Hi Luise,

yes it hangs as the code ran over 1 nigth and it didn't terminate and the observer didn't write 
anything. I didn't get error message.

scales.Fill( 0.0001 )  sets the derivative step length scales, rigth?
it is small value but I thought that a finer search  was necessary as with value=1 the registration didn't 
start.

I paste the diff:

D-69-91-146-228:Code physics$ diff DeformableRegistration8.cxx BSpline_NMI.cxx

39c39,40
< #include "itkMattesMutualInformationImageToImageMetric.h"
---
> 
> #include "itkNormalizedMutualInformationHistogramImageToImageMetric.h"
130c131
<       //std::cout << optimizer->GetInfinityNormOfProjectedGradient() << std::endl;
---
>       std::cout << optimizer->GetInfinityNormOfProjectedGradient() << std::endl;
205,207c206,214
<   typedef itk::MattesMutualInformationImageToImageMetric< 
<                                     FixedImageType, 
<                                     MovingImageType >    MetricType;
---
>  // typedef itk::MattesMutualInformationImageToImageMetric< 
>  //                                   FixedImageType, 
>  //                                   MovingImageType >    MetricType;
> //	
> 	
> 	typedef itk::NormalizedMutualInformationHistogramImageToImageMetric< 
> 	FixedImageType, 
> 	MovingImageType >    MetricType;
> 	
336,338c343,345
< 	gridSizeOnImage[0]= 10 ;
< 	gridSizeOnImage[1]= 10 ;
< 	gridSizeOnImage[2]= 10 ;
---
> 	gridSizeOnImage[0]= 3 ;
> 	gridSizeOnImage[1]= 3 ;
> 	gridSizeOnImage[2]= 3 ;
434c441
<   optimizer->	MinimizeOn();	
---
>   optimizer->	MaximizeOn();
452,493c459,473
<   metric->SetNumberOfHistogramBins( 25 );
<   
< 	const unsigned int numberOfSamples = static_cast<unsigned int>( 
fixedRegion.GetNumberOfPixels() * 20.0 / 100.0 );
< 	std::cout<<numberOfSamples<<std::endl;
<   metric->SetNumberOfSpatialSamples( numberOfSamples );
<   // Software Guide : EndCodeSnippet
<  
< 
<   //  Software Guide : BeginLatex
<   //  
<   //  Given that the Mattes Mutual Information metric uses a random iterator in
<   //  order to collect the samples from the images, it is usually convenient to
<   //  initialize the seed of the random number generator.
<   //
<   //  \index{itk::Mattes\-Mutual\-Information\-Image\-To\-Image\-Metric!ReinitializeSeed()}
<   //
<   //  Software Guide : EndLatex 
< 
<   // Software Guide : BeginCodeSnippet
<   metric->ReinitializeSeed( 76926294 );
<   // Software Guide : EndCodeSnippet
< 
<   if( argc > 7 )
<     {
<     // Define whether to calculate the metric derivative by explicitly
<     // computing the derivatives of the joint PDF with respect to the Transform
<     // parameters, or doing it by progressively accumulating contributions from
<     // each bin in the joint PDF.
<     metric->SetUseExplicitPDFDerivatives( atoi( argv[7] ) );
<     }
< 
<   if( argc > 8 )
<     {
<     // Define whether to cache the BSpline weights and indexes corresponding to
<     // each one of the samples used to compute the metric. Enabling caching will
<     // make the algorithm run faster but it will have a cost on the amount of memory
<     // that needs to be allocated. This option is only relevant when using the 
<     // BSplineDeformableTransform.
<     metric->SetUseCachingOfBSplineWeights( atoi( argv[8] ) );
<     }
< 
< 
---
> 	
> 	unsigned int numberOfHistogramBins = 32;
> 	const unsigned int numberOfParameters2 = transform->GetNumberOfParameters();
> 	
> 	typedef MetricType::ScalesType ScalesType;
> 	ScalesType scales( numberOfParameters2 );
> 	scales.Fill( 0.0001 );
>     metric->SetDerivativeStepLengthScales(scales);
> 	
> 	MetricType::HistogramType::SizeType histogramSize;
> 	histogramSize[0] = 25;
> 	histogramSize[1] = 25;
> 	metric->SetHistogramSize( histogramSize );
> 	
> 	 
537c517
< 	resample->SetDefaultPixelValue( 0 );resample->Update();
---
>   resample->SetDefaultPixelValue( 0 );resample->Update();



Thank you for your help.
Serena.








On Tue, 14 Jul 2009, Luis Ibanez wrote:

> Hi Serena,
>
> When you say that the code
>
>         "doesn't write anything"
>
> do you mean that it:
>
> A) hangs ?
> B) seg faults ?
> C) throws an exception ?
> D) terminate without errors, but without running any iteration ?
>
>
> Also,
> the value of
>
>       scales.Fill( 0.0001 );
>
> is a bit extreme....
>
> Why are you using such a small value ?
>
>
>     Please let us know,
>
>
>           Thanks
>
>
>                 Luis
>
>
>
> PS. It will be useful is you post a "diff" between
> the original file and yours.
>
> -----------------------------------------------------
> On Mon, Jul 13, 2009 at 1:01 PM, Serena Fabbri <fabbri at u.washington.edu>wrote:
>
>>
>> Hi All,
>>
>> I am registering MRI and CT image and I use Normalized Mutual Information.
>> I am using DeformableRegistration8 (BSpline Tranformtion) and I have
>> replaced in the code only the line about the metric.
>> So I have written:
>>
>>
>>        const unsigned int numberOfParameters2 =
>> transform->GetNumberOfParameters();
>>
>>        typedef MetricType::ScalesType ScalesType;
>>        ScalesType scales( numberOfParameters2 );
>>        scales.Fill( 0.0001 );
>>        metric->SetDerivativeStepLengthScales(scales);
>>
>>        MetricType::HistogramType::SizeType histogramSize;
>>        histogramSize[0] = 25;
>>        histogramSize[1] = 25;
>>        metric->SetHistogramSize( histogramSize );
>>
>>      optimizer->MaximizeOn();
>>
>> the problem is the program seems blocked  as the observer associated to
>> registration pipeline doesn't write anything.
>> Did i miss to write some instructions? any idea?
>> I appreciate any suggestion.
>>
>> Thank you.
>>
>> Serena.
>>
>>
>>
>>
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>





More information about the Insight-users mailing list