[Insight-users] RE: potential problem with itkMattesMutualInformationImageToImageMetric when used with fixed image mask

Luis Ibanez luis.ibanez at kitware.com
Tue Apr 24 15:58:50 EDT 2007



Hi Alex,

You seem to be confused by line 430 of the
itkMattesMutualInformationImageToImageMetric.txx file.


Despite the fact that the Random iterator is set to draw a particular
number of samples, its IsAtEnd() method is not the one driving the
main loop of the sampling process. Instead, it is the iterator of
the sample container (initialized in line 441).


With the current code, the RandomImageIterator will continue throwing
random positions, despite the fact of having passed over the number
of samples that it was set to generate. We probably should remove
line 430, in order to avoid this confusing situation.


The drawing of samples is attempted up to a number of times =

         maxcount = m_NumberOfSpatialSamples * 10;



If in that number of attempts, we have not collected the number
of samples expected in samples.size(), then the samples container
is resized and returned with the current number of samples inside
the mask.

As you pointed out, you can always have the unfortunate situation
where the mask is so small that the number of samples is insufficient.
In that case, the user of this metric should provide a better setting
for the FixedImageRegion. In practice, when the metric has a mask,
the FixedImageRegion should be intersected with the bounding box
of the mask. That will reduce the number of wasted attempts during
the sampling process and it will speed up the registration process.



   Please let us know if you have further question,



       Thanks



          Luis



-------------------
Alex Lisovich wrote:
> Hi All,
> 
>  It looks like there is a problem with
> itkMattesMutualInformationImageToImageMetric class I've observed while
> using it with the fixed image mask, namely:
> In case the area/volume of none-zero pixels in the mask image is less
> than ¼ of the fixed image itself, the ::GetValueAndDerivative() method
> of this class is bound to fail the first time it's called. The reason:
> 
>  There is a loop in this method
> (for ( fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter ) {…},
> which among other things checks if each pixel in fixed image pixel set
> (m_FixedImageSamples)  falls into the moving image through the spatial
> transform and counts the number of such valid pixels (nSamples). After
> the end of the loop there is a check (if( nSamples <
> m_NumberOfSpatialSamples / 4 )) {...} which throws an exception if the
> number of such valid pixels is less than ¼ of total number of pixels
> (m_NumberOfSpatialSamples).
>  The problem here seems to be the following: the
> m_NumberOfSpatialSamples is either set to some predefined value
> programmatically or equal to the total number of pixels in image. At
> the same time, the size if m_FixedImageSamples container gets filled
> in the ::SampleFixedImageDomain() method which does random sampling of
> image m_NumberOfSpatialSamples times and puts pixels into the
> container only when they fall inside the fixed image mask (in case the
> mask is used).
>  For example, if m_NumberOfSpatialSamples=1000000 and area/volume of
> fixed mask is 1/10, then the size of m_FixedImageSamples will be
> 100000 and the check at the end of the loop mentioned above will
> ultimately fail.
> 
>  From the other hand, if the mask non-zero area is large enough the
> method will never fail and will pass the test.
> 
> Please let me know if  this is really a bug or I am getting it wrong
> 
> Thank you,
> 
> Alex Lisovich
> _______________________________________________
> 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