Well, that&#39;s good.  Let me know what you find out.    <br /><br /><br /><br />On Oct 14, 2009 8:17pm, Ricardo Ferrari &lt;ricardo.jose.ferrari@gmail.com&gt; wrote:<br />&gt; Hi Nick,<br />&gt; <br />&gt; The most funny thing!!!  The error I was getting was when using my PC-workstation at University. Now, I am at home and I have just checked out the code from my svn repository (the same one I was testing at Univ) and I am not getting the error anymore. <br />&gt; <br />&gt; <br />&gt; I believe it is something related to the ITK lib. I have re-compiled the svn ITK in my home machine last night. <br />&gt; <br />&gt; Tomorrow, I am going to compare the ITK configurations to see if there is any difference. <br />&gt; <br />&gt; <br />&gt; I will keep you update on this. <br />&gt; <br />&gt; Thanks again,<br />&gt; Ricardo<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; On Wed, Oct 14, 2009 at 9:01 PM, Nicholas Tustison ntustison@gmail.com&gt; wrote:<br />&gt; <br />&gt; Hi Ricardo,<br />&gt; <br />&gt; <br />&gt; Okay, now I understand.  In that case, I have two other suggestions:<br />&gt; <br />&gt; <br />&gt; <br />&gt; 1) In the output of your code below<br />&gt; <br />&gt; <br />&gt;  cout GetOrigin()    cout GetSpacing()  <br />&gt;   cout GetLargestPossibleRegion().GetSize()    cout GetDirection()    cout m_NumberOfFittingLevels  <br />&gt;   cout m_SplineOrder    cout m_NumberOfControlPoints  <br />&gt; <br />&gt; <br />&gt; can you also add <br />&gt; <br />&gt; <br />&gt; cout GetNumberOfPoints()  <br />&gt; <br />&gt; <br />&gt; 2) Also, could you see what happens if you convert your minc file to nifti or some other format?<br />&gt; <br />&gt; <br />&gt; Nick<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; On Oct 14, 2009, at 7:55 PM, Ricardo Ferrari wrote:<br />&gt; <br />&gt; Hi Nick,<br />&gt; <br />&gt; Thanks for your e-mail. <br />&gt; <br />&gt; Actually, I am not submitting a mask of all zeros because I am saving and checking the resulting mask image obtained from the Otsu threshold. <br />&gt; <br />&gt; <br />&gt; What I´ve meant by &quot;m_maskImage is purposely equal to zero&quot; in the source code is that I have set the pointer to 0 (NULL) so that the mask could be computed by using the Otsu thresh. As I said, the mask seems to be okay - I have visually checked it.  <br />&gt; <br />&gt; <br />&gt; <br />&gt; The funny thing is if I do not downsample the image (and the mask, of course) I have no problems. I have also checked both the downsampled image & mask, and apparentely (by visually checking) everything is fine.<br />&gt; <br />&gt; <br />&gt; <br />&gt; I will keep trying to figure out the problem!!!  Any suggestion is welcome !!<br />&gt; <br />&gt; Thanks, <br />&gt; Ricardo <br />&gt; <br />&gt; <br />&gt; <br />&gt; On Wed, Oct 14, 2009 at 7:29 PM, Nicholas Tustison ntustison@gmail.com&gt; wrote:<br />&gt; <br />&gt; <br />&gt; Hi Ricardo,<br />&gt; <br />&gt; If you&#39;re submitting a mask of all zeros, that would explain the error message you&#39;re getting.  Instead of submitting a mask of all zeros, just type a non-existent filename and the otsu mask will be calculated.  Let me know if that works out.<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; Nick <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; On Oct 14, 2009, at 5:10 PM, Ricardo Ferrari wrote:<br />&gt; <br />&gt; <br />&gt; Dear itk users,<br />&gt; <br />&gt; I am trying to run the itk N3 algorithm implemented by Nicholas J. Tustison and James C. Gee  and I am getting a &quot;segmentation fault&quot; error.<br />&gt; <br />&gt; <br />&gt; <br />&gt; Above I am sending the main part of my code and the error I am getting. <br />&gt; <br />&gt; <br />&gt; -------------------------------------<br />&gt;     /// m_inputImage is a minc image - you can download it from the following site: http://www.4shared.com/file/140891877/c11d6f0c/20090808_0_DUAL.html<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt;      int m_shrinkFactor = 2;<br />&gt;   <br />&gt;     /// m_maskImage is purposely equal to zero so that it can be computed using Otsu threshold<br />&gt; <br />&gt;     ///<br />&gt;     /// Use Otsu threshold to compute a simple mask, if one is not provided<br />&gt; <br />&gt; <br />&gt; <br />&gt;     ///<br />&gt;     if( ! m_maskImage )<br />&gt;     {<br />&gt;         typedef itk::OtsuThresholdImageFilter ThresholderType;<br />&gt;         typename ThresholderType::Pointer otsu = ThresholderType::New();<br />&gt; <br />&gt; <br />&gt; <br />&gt;         otsu-&gt;SetInput( m_inputImage );<br />&gt;         otsu-&gt;SetNumberOfHistogramBins( 200 );<br />&gt;         otsu-&gt;SetInsideValue( 0 );<br />&gt;         otsu-&gt;SetOutsideValue( 1 );<br />&gt;         otsu-&gt;Update();<br />&gt; <br />&gt;         m_maskImage = otsu-&gt;GetOutput();<br />&gt; <br />&gt; <br />&gt; <br />&gt;     } <br />&gt; <br />&gt;     ///<br />&gt;     /// DownSampling the input image to reduce computation time<br />&gt;     ///<br />&gt;     typedef itk::ShrinkImageFilter ShrinkerImageType;<br />&gt;     typename ShrinkerImageType::Pointer shrinker1 = ShrinkerImageType::New();<br />&gt; <br />&gt; <br />&gt; <br />&gt;     shrinker1-&gt;SetInput( m_inputImage );<br />&gt;     shrinker1-&gt;SetShrinkFactors( 1 );<br />&gt; <br />&gt;     typedef itk::ShrinkImageFilter ShrinkerMaskType;<br />&gt;     typename ShrinkerMaskType::Pointer shrinker2 = ShrinkerMaskType::New();<br />&gt; <br />&gt; <br />&gt; <br />&gt;     shrinker2-&gt;SetInput( m_maskImage );<br />&gt;     shrinker2-&gt;SetShrinkFactors( 1 );<br />&gt;     <br />&gt;     if( m_shrinkFactor &gt; 1 )<br />&gt;     {    <br />&gt;         shrinker1-&gt;SetShrinkFactors( m_shrinkFactor );<br />&gt;         shrinker2-&gt;SetShrinkFactors( m_shrinkFactor );<br />&gt; <br />&gt; <br />&gt; <br />&gt;         shrinker1-&gt;Update();<br />&gt;         shrinker2-&gt;Update();<br />&gt;     }<br />&gt; <br />&gt;     typename TRealImageType::Pointer realInputImage = shrinker1-&gt;GetOutput(); <br />&gt;     typename TMaskImageType::Pointer maskShrinked = shrinker2-&gt;GetOutput();<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt;      <br />&gt;     ///<br />&gt;     /// Run bias field correction<br />&gt;     ///<br />&gt;     typedef itk::N3MRIBiasFieldCorrectionImageFilter CorrectorType;<br />&gt;       typename CorrectorType::Pointer corrector = CorrectorType::New();<br />&gt; <br />&gt; <br />&gt; <br />&gt;       corrector-&gt;SetInput( realInputImage );<br />&gt;       corrector-&gt;SetMaskImage( maskShrinked );<br />&gt;      corrector-&gt;SetMaskLabel( NumericTraits::One );<br />&gt;     corrector-&gt;SetMaximumNumberOfIterations( m_maxNumIter );<br />&gt; <br />&gt; <br />&gt; <br />&gt;     corrector-&gt;SetNumberOfFittingLevels( m_numFittingLevels );<br />&gt; <br />&gt;     try<br />&gt;     {<br />&gt;         corrector-&gt;Update();<br />&gt;     }<br />&gt;     catch ( itk::ExceptionObject & err )<br />&gt;     {<br />&gt;         std::cout  <br />&gt; <br />&gt; <br />&gt;         std::cout          throw err;<br />&gt;     }<br />&gt;     catch (... )<br />&gt;     {<br />&gt;         std::cout  <br />&gt; <br />&gt; <br />&gt;         throw;<br />&gt;     }<br />&gt; <br />&gt; <br />&gt; OUTPUT <br />&gt; --------------------------<br />&gt; Starting<br />&gt; [-116.98, -103.715, -34.2648]<br />&gt; [0.857143, 0.857143, 6]<br />&gt; [280, 280, 25]<br />&gt; 0.999208 -0.00996255 -0.0385217<br />&gt; 0.0108005 0.999708 0.0216062<br />&gt; <br />&gt; <br />&gt; <br />&gt; 0.0382952 -0.0220051 0.999024<br />&gt; <br />&gt; [3, 3, 3]<br />&gt; 3<br />&gt; [4, 4, 4]<br />&gt; Segmentation fault<br />&gt; --------------------------<br />&gt; <br />&gt; <br />&gt; After spending some time looking for the problem I found out that the it is happening in the following part of the itkN3MRIBiasFieldCorrectionImageFilter.txx file.  The problem does not occur if I use the original image without downsampling it.<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; I really appreciate any help on this !!!<br />&gt; <br />&gt; Thanks,<br />&gt; Ricardo<br />&gt; <br />&gt;    <br />&gt; cout  <br />&gt;   cout GetOrigin()    cout GetSpacing()  <br />&gt; <br />&gt; <br />&gt;   cout GetLargestPossibleRegion().GetSize()    cout GetDirection()    cout m_NumberOfFittingLevels  <br />&gt; <br />&gt; <br />&gt;   cout m_SplineOrder    cout m_NumberOfControlPoints     <br />&gt;   typename BSplineFilterType::Pointer bspliner = BSplineFilterType::New();<br />&gt;   bspliner-&gt;SetOrigin( fieldEstimate-&gt;GetOrigin() );<br />&gt; <br />&gt; <br />&gt; <br />&gt;   bspliner-&gt;SetSpacing( fieldEstimate-&gt;GetSpacing() );<br />&gt;   bspliner-&gt;SetSize( fieldEstimate-&gt;GetLargestPossibleRegion().GetSize() );<br />&gt;   bspliner-&gt;SetDirection( fieldEstimate-&gt;GetDirection() );<br />&gt;   bspliner-&gt;SetGenerateOutputImage( true );<br />&gt; <br />&gt; <br />&gt; <br />&gt;   bspliner-&gt;SetNumberOfLevels( this-&gt;m_NumberOfFittingLevels );<br />&gt;   bspliner-&gt;SetSplineOrder( this-&gt;m_SplineOrder );<br />&gt;   bspliner-&gt;SetNumberOfControlPoints( this-&gt;m_NumberOfControlPoints );<br />&gt;   bspliner-&gt;SetInput( fieldPoints );<br />&gt; <br />&gt; <br />&gt; <br />&gt;   bspliner-&gt;Update();<br />&gt;    <br />&gt; cout  <br />&gt; <br />&gt; <br />&gt; _____________________________________<br />&gt; Powered by www.kitware.com<br />&gt; <br />&gt; Visit other Kitware open-source projects at<br />&gt; http://www.kitware.com/opensource/opensource.html<br />&gt; <br />&gt; <br />&gt; <br />&gt; Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ<br />&gt; <br />&gt; Follow this link to subscribe/unsubscribe:<br />&gt; http://www.itk.org/mailman/listinfo/insight-users<br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt; <br />&gt;