<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">Hi Seth,</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
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-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
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-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">Thanks again for your inputs.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">
<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" target="_blank" style="font-size:large;color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> 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" target="_blank" style="color:rgb(153,153,153);text-decoration:initial"> </a></font></div>
</div><br><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>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>
</blockquote></div><br>