Hi itk-users,<div><br></div><div>I took a further step today.  I derived a class from MattesMutualInformationImageToImageMetric, and made it being the metric, so that, I could sneak into itk and visit the protected member ImageToImageMetric&lt; TFixedImage, TMovingImage &gt;::m_FixedImageSamples. I printed out a couple of sample points (their coordinates and image values), and I also printed out the seed value of the random number generator, which I set as ReinitializeSeed(76926294).  I get the seed value by calling Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()-&gt;GetSeed();</div>
<div>In different runs, I do see same seed were used, but I also do see different sample points.  I tried this on two different computers, at both of which I saw the inconsistent results. Seems to be the random number generator is non-deterministic even with same seed.  However, the weird thing is if I do not use the image mask, it would be consistent. </div>
<div><br></div><div>Any thoughts?</div><div><br><br><div class="gmail_quote">2013/2/26 lien lee <span dir="ltr">&lt;<a href="mailto:lienlee@gmail.com" target="_blank">lienlee@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">Hi Seth,</span><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">By clicking the link you provided, the code I saw there is as partly attached, which is different from what I have with ITK 4.2 on my computer.  </div>
<div class="im">
<div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
I do not have experience with this code, and I am not exactly sure how it works.  But, looks to me, optimizer would call the function during each iteration, and the function would rebuild all the sample points again and again for all the iterations.  If my understanding were correct, this would be quite different from what I have with ITK 4.2 on my computer, where all the samples were created in MattesMutualInformationImageToImageMetric::Initialize() as <b>a one time thing</b>, and the counted points would be determined for each iteration using the current transform by checking whether the mapped points were inside the moving image mask. Therefore, for the code I am working on, to my understanding, if I called ReinitializeSeed(76926294) before generating all the sample points in MattesMutualInformationImageToImageMetric::Initialize(), the results should be deterministic, no matter whether I applied the image masks or not. But, the testing results with image mask applied does NOT support my understanding.</div>

<div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
BTW, to your question, my moving image mask may not be &quot;restrictive&quot; because it occupied pretty much about 80% of the whole moving image.</div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">

<br></div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">Thanks again for your inputs.</div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif"><br></div></div><div><div class="h5"><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
<div style="white-space:pre-wrap;font-family:monospace"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l106" style="font-size:large;color:rgb(153,153,153);text-decoration:initial" target="_blank"> 106</a><span style="font-size:large"> template &lt;class TFixedImage, </span><span style="font-size:large">class TMovingImage&gt;</span></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l107" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 107</a> void</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l108" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 108</a> MutualInformationImageToImageMetric&lt;TFixedImage, TMovingImage&gt;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l109" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 109</a> ::SampleFixedImageDomain(</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l110" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 110</a>   SpatialSampleContainer &amp; samples) const</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l111" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 111</a> {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l112" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 112</a>   typedef ImageRandomConstIteratorWithIndex&lt;FixedImageType&gt; RandomIterator;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l113" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 113</a>   RandomIterator randIter( this-&gt;m_FixedImage, this-&gt;GetFixedImageRegion() );</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l114" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 114</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l115" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 115</a>   randIter.SetNumberOfSamples(m_NumberOfSpatialSamples);</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l116" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 116</a>   randIter.GoToBegin();</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l117" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 117</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l118" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 118</a>   typename SpatialSampleContainer::iterator iter;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l119" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 119</a>   typename SpatialSampleContainer::const_iterator end = samples.end();</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l120" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 120</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l121" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 121</a>   bool allOutside = true;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l122" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 122</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l123" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 123</a>   this-&gt;m_NumberOfPixelsCounted = 0;    // Number of pixels that map into the</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l124" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 124</a>                                         // fixed and moving image mask, if</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l125" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 125</a>                                         // specified</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l126" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 126</a>                                         // and the resampled fixed grid after</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l127" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 127</a>                                         // transformation.</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l128" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 128</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l129" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 129</a>   // Number of random picks made from the portion of fixed image within the</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l130" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 130</a>   // fixed mask</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l131" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 131</a>   SizeValueType numberOfFixedImagePixelsVisited = 0;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l132" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 132</a>   SizeValueType dryRunTolerance = this-&gt;GetFixedImageRegion().GetNumberOfPixels();</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l133" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 133</a>   for( iter = samples.begin(); iter != end; ++iter )</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l134" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 134</a>     {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l135" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 135</a>     // Get sampled index</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l136" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 136</a>     FixedImageIndexType index = randIter.GetIndex();</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l137" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 137</a>     // Get sampled fixed image value</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l138" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 138</a>     ( *iter ).FixedImageValue = randIter.Get();</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l139" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 139</a>     // Translate index to point</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l140" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 140</a>     this-&gt;m_FixedImage-&gt;TransformIndexToPhysicalPoint(index,</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l141" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 141</a>                                                       ( *iter ).FixedImagePointValue);</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l142" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 142</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l143" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 143</a>     // If not inside the fixed mask, ignore the point</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l144" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 144</a>     if( this-&gt;m_FixedImageMask</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l145" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 145</a>         &amp;&amp; !this-&gt;m_FixedImageMask-&gt;IsInside( ( *iter ).FixedImagePointValue ) )</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l146" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 146</a>       {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l147" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 147</a>       ++randIter; // jump to another random position</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l148" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 148</a>       continue;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l149" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 149</a>       }</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l150" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 150</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l151" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 151</a>     if( allOutside )</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l152" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 152</a>       {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l153" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 153</a>       ++numberOfFixedImagePixelsVisited;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l154" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 154</a>       if( numberOfFixedImagePixelsVisited &gt; dryRunTolerance )</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l155" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 155</a>         {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l156" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 156</a>         // We randomly visited as many points as is the size of the fixed image</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l157" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 157</a>         // region.. Too may samples mapped ouside.. go change your transform</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l158" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 158</a>         itkExceptionMacro(&lt;&lt; &quot;Too many samples mapped outside the moving buffer&quot;);</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l159" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 159</a>         }</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l160" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 160</a>       }</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l161" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 161</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l162" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 162</a>     MovingImagePointType mappedPoint =</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l163" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 163</a>       this-&gt;m_Transform-&gt;TransformPoint( ( *iter ).FixedImagePointValue );</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l164" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 164</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l165" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 165</a>     // If the transformed point after transformation does not lie within the</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l166" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 166</a>     // MovingImageMask, skip it.</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l167" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 167</a>     if( this-&gt;m_MovingImageMask</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l168" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 168</a>         &amp;&amp; !this-&gt;m_MovingImageMask-&gt;IsInside(mappedPoint) )</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l169" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 169</a>       {</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l170" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 170</a>       ++randIter;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l171" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 171</a>       continue;</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l172" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 172</a>       }</font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l173" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> 173</a> </font></div>

<div style="white-space:pre-wrap;font-family:monospace"><font size="4"><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD#l174" style="color:rgb(153,153,153);text-decoration:initial" target="_blank"> </a></font></div>

</div><br></div></div><div class="gmail_quote">2013/2/26 Seth Gilchrist <span dir="ltr">&lt;<a href="mailto:seth@mech.ubc.ca" target="_blank">seth@mech.ubc.ca</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi Lien,<div class="im"><div>Unfortunately I have not used masks when performing registrations, so can&#39;t help you with this specific problem.</div><div><br></div><div>I took a look at the git blob for the MattesMutual...Metric and was examining how the decision to keep or reject a give point is handled. If you are setting a mask on both the fixed and moving images, this will change what points are used because a check is done to see if a point is in the fixed mask and if it is in the moving mask after applying the current transform. Could your moving image mask be too restrictive for the early stages of the registration?</div>



<div><br></div><div>You can read the code at:</div><div><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD" target="_blank">http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx;h=1244e5c0be768696cf042f6f39739f4b2bdcbba6;hb=HEAD</a><br>



</div><div><br></div><div>Starting on line 108, specifically on line 162.</div><div><br></div><div>Cheers,</div><div>Seth</div><div class="gmail_extra"><br clear="all"><div><i>Seth Gilchrist, MASc, PhD Candidate<br>

<span style="font-family:courier new,monospace">+---------------------------------------+</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Orthopaedic and Injury Biomechanics Group<br>



UBC Department of Mechanical Engineering</span><span style="font-family:courier new,monospace"></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">6th Floor-2635 Laurel Street</span><br style="font-family:courier new,monospace">



<span style="font-family:courier new,monospace">Vancouver, BC V5Z-1M9<br></span><span style="font-family:courier new,monospace">+---------------------------------------+<br><a href="mailto:seth@mech.ubc.ca" target="_blank">seth@mech.ubc.ca</a><br>



Fax <a href="tel:604-675-2576" value="+16046752576" target="_blank">604-675-2576</a></span></i></div><br></div></div></div>
</blockquote></div><br>
</blockquote></div><br></div>