MantisBT - ITK
View Issue Details
0009222ITKpublic2009-06-30 18:152010-11-07 01:58
Luis Ibanez 
brian avants 
highminoralways
assignedopen 
 
 
0009222: MattesMutualInformation values change with different number of Threads
The values returned by GetValue() and GetValueAndDerivative() are different depending on how many threads are used when running the metric.
This was identified by Andy Fedorov, during the NAMIC Developers week 2009, and was reported previously as a difficulty for replicating image registration results when running the same code in different computers.
No tags attached.
Issue History
2009-06-30 18:15Luis IbanezNew Issue
2009-06-30 18:15Luis IbanezStatusnew => assigned
2009-06-30 18:15Luis IbanezAssigned To => Luis Ibanez
2009-07-01 15:03Luis IbanezNote Added: 0016799
2009-07-01 15:08Luis IbanezNote Edited: 0016799
2009-07-01 16:54Hans JohnsonNote Added: 0016800
2009-07-01 16:57Luis IbanezNote Added: 0016801
2009-07-01 17:54Luis IbanezNote Added: 0016802
2009-07-01 17:55Luis IbanezNote Added: 0016803
2009-07-01 17:55Luis IbanezStatusassigned => confirmed
2009-07-01 17:55Luis IbanezPrioritynormal => high
2009-07-01 22:45Luis IbanezNote Added: 0016804
2010-11-07 01:58Luis IbanezStatusconfirmed => assigned
2010-11-07 01:58Luis IbanezAssigned ToLuis Ibanez => brian avants
2010-11-07 01:58Luis IbanezNote Added: 0022980

Notes
(0016799)
Luis Ibanez   
2009-07-01 15:03   
(edited on: 2009-07-01 15:08)
The first suspect was the actual list of points (indexes) selected by the random iterator.

However, I have verified that the set of indexes is the same, regardless of how many threads are set in the Metric.

In the same exercise, by running the existing tests:

itkOptImageToImageMetricsTest01
itkOptImageToImageMetricsTest02
itkOptImageToImageMetricsTest03

I have verified that the values of the derivative change
depending on the number of threads used in the computation.]
(which is an indication of a bug).

(0016800)
Hans Johnson   
2009-07-01 16:54   
Luis,

It was also noted during NAMIC that doing a rigid registration where the fixed and moving images are exactly the same image does not result in an identity matrix. It is hypothesized that this is also a problem with the derivatives not being computed correctly.

Perhaps doing a test with exactly the same image as fixed and moving will help you identify the problem more easily.

Hans
(0016801)
Luis Ibanez   
2009-07-01 16:57   
Hans,

Thanks for pointing this out.

This new test is actually using two identical images,
but it is not performing a full registration, only
calls to GetValue() and GetValueAndDerivative().

This should still give us some hints on where the
source of the problem may be.

We probably should add a couple of tests with the
situation that you describe. To verify that a
registration against an identical image results
in Identity transforms.


    Thanks


       Luis
(0016802)
Luis Ibanez   
2009-07-01 17:54   
The same problem happens for the multi-threaded MeanSquares metric.
That is, the values returned by GetValue() and GetValueAndDerivative() change
depending on the number of threads used.

In MeanSquares, we have verified that the metric value returned by GetValue() is the same that the one returned by GetValueAndDerivative(), as well as verified that the value returned by GetDerivative() is the same as the one returned by GetValueAndDerivative().
(0016803)
Luis Ibanez   
2009-07-01 17:55   
a test has been added to the Nightly suite.
(0016804)
Luis Ibanez   
2009-07-01 22:45   
After adding a proper Reinitialization of the Seed (for the random pixel iterator), the results are the same in multiple threads when using less than 50,000 samples.

At 50,000 samples, on the other hand, the values of metric and derivative start
to diverge in the low digits. It start looking like a progressive accumulation of errors...
(0022980)
Luis Ibanez   
2010-11-07 01:58   
This should be addressed as part of the image registration refactoring in ITKv4