<br>Dear Insight Users,<br>(sorry if this email appears twice)<br><br>i am quite new to insight and have gotten a code which i would like to modify. <br>I have basically an image on which i want to run a label statistics filter.<br>
The image is thresholded such that the statistcs will be obtained from the <br>
thresholded image. <br>The problem is i cannot set the voxels outside the threshold range to NaN such that they are<br>not included in the statistics later on.<br>Any help can is appreciated. (Code snippet is below)<br>Jaime<br>

<br>.<br>.<br>.<br>.<br> <span style="font-family: courier new,monospace;">typedef itk::ThresholdImageFilter&lt; ImageType &gt; ThresholdFilterType;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ThresholdFilterType::Pointer threshold = ThresholdFilterType::New();</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">threshold-&gt;SetInput( reader-&gt;GetOutput() );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">typedef itk::LabelStatisticsImageFilter&lt; ImageType, Float2BinAdaptorType &gt; ...LabelStatisticsFilterType;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;"><br>LabelStatisticsFilterType::Pointer labelstatistic = LabelStatisticsFilterType::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">labelstatistic-&gt;SetInput( threshold-&gt;GetOutput() );</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> labelstatistic-&gt;SetLabelInput( float2bin );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">for ( int  lowerTInt = -100; lowerTInt &lt;=-20; lowerTInt += 20 ) {</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">   const ImageType::PixelType lowerThresh= static_cast&lt;float&gt;( lowerTInt );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   threshold-&gt;ThresholdBelow(lowerThresh);</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">   threshold-&gt;SetOutsideValue(-20);</span>  // <span style="font-family: courier new,monospace;">SetOutsideValue(NaN) Doesn&#39;t work;</span> <br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">   threshold-&gt;Update();    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   labelstatistic-&gt;Update();</span><br>

   .<br>   . <br>   . <br>   .<br>   // Get Statistics from the image<br>   const RealType min      =  labelstatistic-&gt;GetMinimum( );<br>   const RealType max      =  labelstatistic-&gt;GetMaximum( );<br>   std::cout &lt;&lt;labelstatistic-&gt;GetCount( 0 )<br>

                 &lt;&lt;&quot; label non XCT &quot; &lt;&lt;labelstatistic-&gt;GetCount( 254 )<br>.<br>.<br>.<br>}