[Insight-developers] Issue of working with Masks and MutualRegistration and MattesMutualInformationImageToImageMetric

Kent Williams kent at psychiatry.uiowa.edu
Fri Sep 1 14:00:13 EDT 2006


Here at Iowa we're working on incorporating Mattes Mutual Information 
Registration into our automated image processing pipeline.

We ran into a problem with it, When the 
MattesMutualInformationImageToImageMetric samples the Fixed Image, with 
a Mask specified,  (in SampleFixedImageDomain), it throws an exception, 
because it reaches a limit for the number of times it samples the 
FixedImage.  You tell the metric to acquire a certain number of 
SpatialSamples, and if you have to sample the Image more than ten times 
that number of samples before finding the requested number of samples, 
it throws an exception.

My patch around this problem, is to resize the random sample vector to 
whatever number of points it found inside the mask, and go with that.  
This seems to work fine, and converges on a solution.  But I don't 
really know much about Registration algorithms so I have no idea whether 
this is the acceptable solution in the general case.  So I'm asking, is 
this a terrible idea? If so, who has a better one?

Here's the patch:
*** 
/scratch/kent/brains2/iplFreeware/unpackdir/Insight/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx    
2006-09-01 12:30:54.000000000 -0500
--- itkMattesMutualInformationImageToImageMetric.txx    2006-09-01 
12:28:54.000000000 -0500
***************
*** 2,11 ****
 
    Program:   Insight Segmentation & Registration Toolkit
    Module:    $RCSfile: 
itkMattesMutualInformationImageToImageMetric.txx,v $
    Language:  C++
!   Date:      $Date: 2006/03/28 23:47:09 $
!   Version:   $Revision: 1.36 $
 
    Copyright (c) Insight Software Consortium. All rights reserved.
    See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for 
details.
 
--- 2,11 ----
 
    Program:   Insight Segmentation & Registration Toolkit
    Module:    $RCSfile: 
itkMattesMutualInformationImageToImageMetric.txx,v $
    Language:  C++
!   Date:      $Date: 2006/09/01 17:28:54 $
!   Version:   $Revision: 1.1 $
 
    Copyright (c) Insight Software Consortium. All rights reserved.
    See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for 
details.
 
***************
*** 436,451 ****
--- 436,458 ----
      typename Superclass::InputPointType inputPoint;
 
      iter=samples.begin();
      int count = 0;
+     int samples_found = 0;
      int maxcount = m_NumberOfSpatialSamples * 10;
      while( iter != end )
        {
 
        if ( count > maxcount )
          {
+ #if 0
          itkExceptionMacro( "Drew too many samples from the mask (is it 
too small?): "
                         << maxcount << std::endl );
+ #else
+         samples.resize(samples_found);
+         //        this->SetNumberOfSpatialSamples(sample_found);
+         break;
+ #endif
          }
        count++;
       
        // Get sampled index
***************
*** 463,471 ****
        // Get sampled fixed image value
        (*iter).FixedImageValue = randIter.Get();
        // Translate index to point
        (*iter).FixedImagePointValue = inputPoint;
!
        // Jump to random position
        ++randIter;
        ++iter;
        }
--- 470,478 ----
        // Get sampled fixed image value
        (*iter).FixedImageValue = randIter.Get();
        // Translate index to point
        (*iter).FixedImagePointValue = inputPoint;
!       samples_found++;
        // Jump to random position
        ++randIter;
        ++iter;
        }



More information about the Insight-developers mailing list